diff --git a/tests/test_imports.py b/tests/test_imports.py index e7519ea..88cbe27 100644 --- a/tests/test_imports.py +++ b/tests/test_imports.py @@ -5,7 +5,9 @@ @pytest.mark.skipif( - not sys.platform.startswith("linux") or platform.python_implementation() == "PyPy", + not sys.platform.startswith("linux") + or platform.python_implementation() == "PyPy" + or sys.version_info[:2] == (3, 12), reason="Unreliable", ) def test_import_time(pytester: pytest.Pytester) -> None: @@ -14,9 +16,14 @@ def test_import_time(pytester: pytest.Pytester) -> None: from time to time, but this should provide an early warning if something is added that significantly increases import time. """ - r = pytester.run( - sys.executable, "-We", "-c", "import aiohttp_debugtoolbar", timeout=0.95 - ) + best_time_ms = 1000 + cmd = "import timeit; print(int(timeit.timeit('import aiohttp_debugtoolbar', number=1)*1000))" + for _ in range(3): + r = pytester.run(sys.executable, "-We", "-c", cmd) - assert not r.stdout.str() - assert not r.stderr.str() + assert not r.stderr.str() + runtime_ms = int(r.stdout.str()) + if runtime_ms < best_time_ms: + best_time_ms = runtime_ms + + assert best_time_ms < 350