From 3e0b292632835218f8d085aea33b08c6a1dc652e Mon Sep 17 00:00:00 2001 From: evgfilim1 Date: Fri, 19 Aug 2022 13:18:04 +0500 Subject: [PATCH] Adjust timeout when testing on pypy Running the tests with coverage pytest plugin makes some tests run slower than expected --- tests/test_dispatcher/test_dispatcher.py | 6 +++++- tests/test_webhook/test_aiohtt_server.py | 6 +++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/tests/test_dispatcher/test_dispatcher.py b/tests/test_dispatcher/test_dispatcher.py index f501ed75..43684bb4 100644 --- a/tests/test_dispatcher/test_dispatcher.py +++ b/tests/test_dispatcher/test_dispatcher.py @@ -1,5 +1,6 @@ import asyncio import datetime +import sys import time import warnings from collections import Counter @@ -702,7 +703,10 @@ class TestDispatcher: dispatcher = Dispatcher() dispatcher.message.register(simple_message_handler) - response = await dispatcher.feed_webhook_update(bot, RAW_UPDATE, _timeout=0.3) + # Running this test on PyPy with coverage pytest plugin makes the test run slower + # than expected, so we adjust the timeout accordingly. + timeout = 0.5 if sys.implementation.name == "pypy" else 0.3 + response = await dispatcher.feed_webhook_update(bot, RAW_UPDATE, _timeout=timeout) assert isinstance(response, dict) assert response["method"] == "sendMessage" assert response["text"] == "ok" diff --git a/tests/test_webhook/test_aiohtt_server.py b/tests/test_webhook/test_aiohtt_server.py index ceb24243..f7aa0f4b 100644 --- a/tests/test_webhook/test_aiohtt_server.py +++ b/tests/test_webhook/test_aiohtt_server.py @@ -1,4 +1,5 @@ import asyncio +import sys import time from asyncio import Event from dataclasses import dataclass @@ -115,7 +116,10 @@ class TestSimpleRequestHandler: handler_event.clear() resp = await self.make_reqest(client=client) assert resp.status == 200 - await asyncio.wait_for(handler_event.wait(), timeout=1) + # Running this test on PyPy with coverage pytest plugin makes the test run slower + # than expected, so we adjust the timeout accordingly. + timeout = 1.5 if sys.implementation.name == "pypy" else 1 + await asyncio.wait_for(handler_event.wait(), timeout=timeout) mocked_silent_call_request.assert_awaited() result = await resp.json() assert not result