How to use the pyee.TwistedEventEmitter function in pyee

To help you get started, we’ve selected a few pyee examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github jfhbrook / pyee / tests / test_async.py View on Github external
    (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')
github jfhbrook / pyee / tests / test_async.py View on Github external
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()