mirror of
https://github.com/crewAIInc/crewAI.git
synced 2026-07-01 05:08:12 +00:00
Fix test isolation: reset TraceCollectionListener singleton in cleanup_event_handlers fixture
Prevents singleton state pollution (trace_batch_id="debug-trace-batch") from test_flow_conversation.py leaking into test_trace_enable_disable.py when both files run in the same pytest-xdist worker under --dist=loadfile. The polluted singleton caused a background HTTP request to fake.crewai.com that corrupted VCR cassette state, preventing the OpenAI LLM entry from matching.
This commit is contained in:
committed by
GitHub
parent
fea0764647
commit
0344f74755
15
conftest.py
15
conftest.py
@@ -197,6 +197,21 @@ def cleanup_event_handlers() -> Generator[None, Any, None]:
|
||||
except Exception: # noqa: S110
|
||||
pass
|
||||
|
||||
try:
|
||||
from crewai.events.listeners.tracing.trace_listener import (
|
||||
TraceCollectionListener,
|
||||
)
|
||||
|
||||
if TraceCollectionListener._instance is not None:
|
||||
instance_dict = TraceCollectionListener._instance.__dict__
|
||||
if "_initialized" in instance_dict:
|
||||
del TraceCollectionListener._instance._initialized
|
||||
if "_listeners_setup" in instance_dict:
|
||||
del TraceCollectionListener._instance._listeners_setup
|
||||
TraceCollectionListener._instance = None
|
||||
except Exception: # noqa: S110
|
||||
pass
|
||||
|
||||
|
||||
@pytest.fixture(autouse=True, scope="function")
|
||||
def reset_event_state() -> None:
|
||||
|
||||
Reference in New Issue
Block a user