Skip to content

Commit

Permalink
Fix a few deprecation warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
alanbriolat committed Feb 14, 2022
1 parent 55d0386 commit 361bd5c
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 16 deletions.
1 change: 1 addition & 0 deletions pytest.ini
Original file line number Diff line number Diff line change
Expand Up @@ -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
3 changes: 1 addition & 2 deletions src/csbot/events.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
21 changes: 7 additions & 14 deletions tests/test_events.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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
Expand Down

0 comments on commit 361bd5c

Please sign in to comment.