Skip to content

Commit

Permalink
Fixed the tests. The use of assert_raises was "hiding" other errors, …
Browse files Browse the repository at this point in the history
…since it only checks to make sure that our particular exception was raised
  • Loading branch information
jfhbrook committed Jul 21, 2011
1 parent 766dc88 commit 37d1847
Showing 1 changed file with 19 additions and 9 deletions.
28 changes: 19 additions & 9 deletions test/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,18 @@ def test_emit():

#Used in a decorator style.
@ee.on('event')
def event_handler(data):
def event_handler(data, error=None):
nt.assert_equals(data, 'emitter is emitted!')
# Raise exception to prove it fired.
raise ItWorkedException
if (error):
raise ItWorkedException

#Making sure data is passed propers.
ee.emit('event', 'emitter is emitted!')

# Some nose bullshit to check for the firings
# Some nose bullshit to check for the firings. "Hides" other exceptions.
with nt.assert_raises(ItWorkedException) as it_worked:
ee.emit('event', 'emitter is emitted!')
ee.emit('event', 'emitter is emitted!', True)


def test_new_listener_event():
Expand Down Expand Up @@ -85,14 +89,20 @@ def test_once():

ee = Event_emitter()

@ee.once('event')
def event_handler(data):
def once_handler(data, error=None):
nt.assert_equals(data, 'emitter is emitted!')
raise ItWorkedException
if (error):
raise ItWorkedException

#Tests to make sure that after event is emitted that it's gone.
ee.once('event', once_handler)
ee.emit('event', 'emitter is emitted!')
nt.assert_equal(ee._events['event'], [])

#Tests to make sure callback fires. "Hides" other exceptions.
with nt.assert_raises(ItWorkedException) as it_worked:
ee.emit('event', 'emitter is emitted!')
nt.assert_equal(ee._events['event'], [])
ee.once('event', once_handler)
ee.emit('event', 'emitter is emitted!', True)

def test_listeners():
"""
Expand Down

0 comments on commit 37d1847

Please sign in to comment.