Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
(TwistedEventEmitter, dict()),
(EventEmitter, dict(scheduler=ensureDeferred))
])
def test_twisted_emit(cls, kwargs):
"""Test that twisted-supporting event emitters can handle wrapping
coroutines
"""
ee = cls(**kwargs)
should_call = Mock()
@ee.on('event')
async def event_handler():
_ = await succeed('yes!')
should_call(True)
ee.emit('event')
def test_twisted_error():
"""Test that TwistedEventEmitters handle Failures when wrapping coroutines.
"""
ee = TwistedEventEmitter()
should_call = Mock()
@ee.on('event')
async def event_handler():
raise PyeeTestError()
@ee.on('failure')
def handle_error(e):
should_call(e)
ee.emit('event')
should_call.assert_called_once()