Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions tests/conftest.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import asyncio
import gc
import multiprocessing.context
import os
import sys
Expand Down Expand Up @@ -58,6 +59,12 @@ def pytest_runtest_setup(item): # type: ignore[reportMissingParameterType]
print()


def pytest_collection_finish() -> None:
# Freeze the import-time heap once so full GC passes only cover test allocations
gc.collect()
gc.freeze()


def pytest_addoption(parser): # type: ignore[reportMissingParameterType]
parser.addoption(
"-E",
Expand Down
20 changes: 16 additions & 4 deletions tests/contrib/langgraph/test_replay.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import sys
import warnings
from datetime import timedelta
from uuid import uuid4

Expand Down Expand Up @@ -52,10 +53,21 @@ async def test_replay(client: Client):
)
await handle.result()

await Replayer(
workflows=[TwoNodesWorkflow],
plugins=[plugin],
).replay_workflow(await handle.fetch_history())
with warnings.catch_warnings(record=True) as recorder:
warnings.filterwarnings(
"always", message=r"Module .* was imported after initial workflow load"
)
await Replayer(
workflows=[TwoNodesWorkflow],
plugins=[plugin],
).replay_workflow(await handle.fetch_history())

# Sandbox imports during an activation count toward the deadlock timeout
assert not [
str(w.message)
for w in recorder
if "was imported after initial workflow load" in str(w.message)
]


@pytest.mark.skipif(
Expand Down
Loading