heynemann / pyvows

Python implementation of Vows.js

Home Page:http://pyvows.org

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Problem testing topics used as decorator

Zearin opened this issue · comments

I’m having some weird errors I haven’t yet been able to debug in another project. (For this project, I am converting a small unittest suite to a PyVows suite.)

The topic object has one particular method, which can be called normally or used to decorate functions.

I’m trying to test whether, after doing something like:

@topic.decorator('thing')
def some_function():
    # some statements
    ...

So that after this decoration occurs, the topic reflects the changes.

Since PyVows does some complex VooDoo with nested contexts, I wasn’t sure if this would be an issue.

Can anybody verify whether this is a potential problem?

Okay, so… @heynemann , you modeled PyVows after Vows.js, so I assume you are familiar with Node.js’s EventEmitter.

The project I am trying (and failing) to write PyVows for is PyEE, a Python port of EventEmitter.

So, ee is an instance of EventEmitter. If I call ee.emit('event'), it’s going to call whatever functions I previously registered for the event 'event'.

The emit() method itself currently returns a boolean (in the original repo) or nothing (in my repo—because that is more consistent with the original EventEmitter API; going to submit a pull request for this change to the author).

I’ve been trying to write Vows for this, but I’m not having any luck.


Update!

Fixed. I’m not sure why, but the problem had to do with event listeners that raised Exceptions. Since the topic wasn’t raising the exceptions itself, it would somehow screw up the rest of the tests. But if I just added an extra try: ... except: ... handler in certain tests—that is, the topic emitted an event, which, in turn, raised an Exception—everything works as normal.

Yay!


Never mind

Not fixed. See below.

I take it back ☺

Apparently I stumbled on a flook. I don’t know how, but it’s very broken again. The only way I can get the tests to pass is by manually creating a new topic at the top of each Vows.Context…which is kind of against the whole philosophy of PyVows and topics. :-/

Does this still reproduce against the latest version?

Grr…inconsistentThingsMakeMePullMyHairOut!

I recently gave it another shot. Rewrote my pyvows for PyEE from scratch. This time, I’m not having any issues like this.

So, uh…as you were. (I suppose…)