Fix pytest-asyncio deprecation warning in test (#1584)

Introduced in pytest-asyncio in:
https://github.com/pytest-dev/pytest-asyncio/pull/648
This commit is contained in:
Carl Smedstad 2024-09-28 00:33:14 +02:00 committed by GitHub
parent 718910f5b5
commit 080878be86
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 4 additions and 2 deletions

1
CHANGES/1584.bugfix.rst Normal file
View file

@ -0,0 +1 @@
Fix PytestDeprecationWarning thrown by pytest-asyncio when running the tests

View file

@ -13,9 +13,10 @@ from tests.mocked_bot import MockedBot
class TestChatActionSender: class TestChatActionSender:
async def test_wait(self, bot: Bot, event_loop: asyncio.BaseEventLoop): async def test_wait(self, bot: Bot):
sender = ChatActionSender.typing(bot=bot, chat_id=42) sender = ChatActionSender.typing(bot=bot, chat_id=42)
event_loop.call_soon(sender._close_event.set) loop = asyncio.get_running_loop()
loop.call_soon(sender._close_event.set)
start = time.monotonic() start = time.monotonic()
await sender._wait(1) await sender._wait(1)
assert time.monotonic() - start < 1 assert time.monotonic() - start < 1