@@ -28,20 +28,14 @@ def test_web___all__(pytester: pytest.Pytester) -> None:
2828 result .assert_outcomes (passed = 0 , errors = 0 )
2929
3030
31- _IS_CI_ENV = os .getenv ("CI" ) == "true"
32- _XDIST_WORKER_COUNT = int (os .getenv ("PYTEST_XDIST_WORKER_COUNT" , 0 ))
33- _IS_XDIST_RUN = _XDIST_WORKER_COUNT > 1
34-
35- _TARGET_TIMINGS_BY_PYTHON_VERSION = {
36- "3.12" : (
37- # 3.12+ is expected to be a bit slower due to performance trade-offs,
38- # and even slower under pytest-xdist, especially in CI
39- _XDIST_WORKER_COUNT * 100 * (1 if _IS_CI_ENV else 1.53 )
40- if _IS_XDIST_RUN
41- else 295
42- ),
43- }
44- _TARGET_TIMINGS_BY_PYTHON_VERSION ["3.13" ] = _TARGET_TIMINGS_BY_PYTHON_VERSION ["3.12" ]
31+ _IMPORT_TIME_THRESHOLD_PY312 = 350
32+ _IMPORT_TIME_THRESHOLD_DEFAULT = 200
33+
34+
35+ def _get_import_time_threshold () -> float :
36+ if sys .version_info >= (3 , 12 ):
37+ return _IMPORT_TIME_THRESHOLD_PY312
38+ return _IMPORT_TIME_THRESHOLD_DEFAULT
4539
4640
4741@pytest .mark .internal
@@ -67,7 +61,7 @@ def test_import_time(pytester: pytest.Pytester) -> None:
6761 for _ in range (3 ):
6862 r = pytester .run (sys .executable , "-We" , "-c" , cmd )
6963
70- assert not r .stderr .str ()
64+ assert not r .stderr .str (), r . stderr . str ()
7165 runtime_ms = int (r .stdout .str ())
7266 if runtime_ms < best_time_ms :
7367 best_time_ms = runtime_ms
@@ -77,7 +71,6 @@ def test_import_time(pytester: pytest.Pytester) -> None:
7771 else :
7872 os .environ ["PYTHONPATH" ] = old_path
7973
80- expected_time = _TARGET_TIMINGS_BY_PYTHON_VERSION .get (
81- f"{ sys .version_info .major } .{ sys .version_info .minor } " , 200
82- )
74+ expected_time = _get_import_time_threshold ()
8375 assert best_time_ms < expected_time
76+
0 commit comments