diff --git a/pytest.ini b/pytest.ini index 824b868..43eede1 100644 --- a/pytest.ini +++ b/pytest.ini @@ -3,3 +3,4 @@ testpaths = tests/ addopts = --cov=src/ --cov-report=xml -W ignore::schematics.deprecated.SchematicsDeprecationWarning markers = bot: mark a test as Bot-based rather than IRCClient-based +asyncio_mode = auto diff --git a/src/csbot/events.py b/src/csbot/events.py index fbd98ce..4624936 100644 --- a/src/csbot/events.py +++ b/src/csbot/events.py @@ -116,8 +116,7 @@ def _get_pending(self): self.pending_event.clear() return pending - @asyncio.coroutine - def _run(self): + async def _run(self): # Use self as context manager so an escaping exception doesn't break # the event runner instance permanently (i.e. we clean up the future) with self: diff --git a/tests/test_events.py b/tests/test_events.py index e4d100a..fd27360 100644 --- a/tests/test_events.py +++ b/tests/test_events.py @@ -138,16 +138,13 @@ def test_values(self, async_runner): @pytest.mark.asyncio def test_event_chain(self, async_runner): """Check that chains of events get handled.""" - @asyncio.coroutine - def f1(): + async def f1(): async_runner.runner.post_event(f2) - @asyncio.coroutine - def f2(): + async def f2(): async_runner.runner.post_event(f3) - @asyncio.coroutine - def f3(): + async def f3(): pass yield from async_runner.runner.post_event(f1) @@ -159,21 +156,17 @@ def test_exception_recovery(self, async_runner): """Check that exceptions are handled but don't block other tasks or leave the runner in a broken state. """ - @asyncio.coroutine - def f1(): + async def f1(): async_runner.runner.post_event(f2) raise Exception() - @asyncio.coroutine - def f2(): + async def f2(): pass - @asyncio.coroutine - def f3(): + async def f3(): async_runner.runner.post_event(f4) - @asyncio.coroutine - def f4(): + async def f4(): pass assert async_runner.exception_handler.call_count == 0