Skip to content

Commit

Permalink
test for #34 reproduced
Browse files Browse the repository at this point in the history
  • Loading branch information
Mark Harviston authored and Mark Harviston committed Jun 30, 2015
1 parent d0b1810 commit 72c9b7f
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions tests/test_qeventloop.py
Original file line number Diff line number Diff line change
Expand Up @@ -688,3 +688,29 @@ def fut_cb(fut):
fut.add_done_callback(fut_cb)
loop.add_writer(fd, writer_cb, fut)
loop.run_until_complete(cb_called)


def test_exception_handler(application):
handler_called = False
coro_run = False
loop = quamash.QEventLoop(application)
asyncio.set_event_loop(loop)

@asyncio.coroutine
def future_except():
nonlocal coro_run
coro_run = True
raise ExceptionTester()

def exct_handler(loop, data):
nonlocal handler_called
handler_called = True

try:
loop.set_exception_handler(exct_handler)
asyncio.async(future_except())
loop.run_until_complete(asyncio.sleep(.1))
finally:
asyncio.set_event_loop(None)
assert coro_run
assert handler_called

0 comments on commit 72c9b7f

Please sign in to comment.