Skip to content

Automate browser based workflows with AI

Freeze the import-time heap once pytest collection finishes (#8851)

Shuchang Zheng093ba6471066
diff --git a/tests/conftest.py b/tests/conftest.py
index ce76b31f7..8b6169aee 100644
--- a/tests/conftest.py
+++ b/tests/conftest.py
@@ -1,5 +1,6 @@
"""Fixtures shared by every suite."""
+import gc
import inspect
import io
import logging
@@ -22,6 +23,13 @@ from skyvern.forge.sdk.workflow.models.block import CodeBlock
from skyvern.services import organization_log_scope
+def pytest_collection_finish(session: pytest.Session) -> None:
+ # Every full GC would re-scan the objects imports and collection leave, a main-thread pause long enough to fail
+ # short-deadline tests late in a CI shard. Freezing them hides them from the GC and from gc.get_objects().
+ gc.collect()
+ gc.freeze()
+
+
@pytest.fixture(autouse=True, scope="session")
def _configure_logging_once_per_process() -> None:
"""Configure logging the way the app does, once, before the first test runs.