chore: restructure test env, cassettes, and conftest; fix flaky tests
Some checks failed
Build uv cache / build-cache (3.10) (push) Has been cancelled
Build uv cache / build-cache (3.11) (push) Has been cancelled
Build uv cache / build-cache (3.12) (push) Has been cancelled
Build uv cache / build-cache (3.13) (push) Has been cancelled
CodeQL Advanced / Analyze (actions) (push) Has been cancelled
CodeQL Advanced / Analyze (python) (push) Has been cancelled
Notify Downstream / notify-downstream (push) Has been cancelled
Mark stale issues and pull requests / stale (push) Has been cancelled

Consolidates pytest config, standardizes env handling, reorganizes cassette layout, removes outdated VCR configs, improves sync with threading.Condition, updates event-waiting logic, ensures cleanup, regenerates Gemini cassettes, and reverts unintended test changes.
This commit is contained in:
Greyson LaLonde
2025-11-29 16:55:24 -05:00
committed by GitHub
parent bc4e6a3127
commit c925d2d519
200 changed files with 2070 additions and 1891 deletions

View File

@@ -686,7 +686,7 @@ def test_anthropic_stop_sequences_sync():
assert llm.stop == []
@pytest.mark.vcr(filter_headers=["authorization", "x-api-key"])
@pytest.mark.vcr()
def test_anthropic_stop_sequences_sent_to_api():
"""Test that stop_sequences are properly sent to the Anthropic API."""
llm = LLM(model="anthropic/claude-3-5-haiku-20241022")

View File

@@ -64,7 +64,7 @@ class TestAnthropicInterceptorIntegration:
assert llm.interceptor is interceptor
@pytest.mark.vcr(filter_headers=["authorization", "x-api-key"])
@pytest.mark.vcr()
def test_anthropic_call_with_interceptor_tracks_requests(self) -> None:
"""Test that interceptor tracks Anthropic API requests."""
interceptor = AnthropicTestInterceptor()
@@ -164,7 +164,7 @@ class TestAnthropicLoggingInterceptor:
assert llm.interceptor is interceptor
assert isinstance(llm.interceptor, AnthropicLoggingInterceptor)
@pytest.mark.vcr(filter_headers=["authorization", "x-api-key"])
@pytest.mark.vcr()
def test_logging_interceptor_tracks_details(self) -> None:
"""Test that logging interceptor tracks request/response details."""
interceptor = AnthropicLoggingInterceptor()
@@ -257,7 +257,7 @@ class TestAnthropicHeaderInterceptor:
assert "X-Custom-Client" in modified_request.headers
assert modified_request.headers["X-Custom-Client"] == "crewai-interceptor"
@pytest.mark.vcr(filter_headers=["authorization", "x-api-key"])
@pytest.mark.vcr()
def test_header_interceptor_with_real_call(self) -> None:
"""Test that header interceptor works with real Anthropic API call."""
interceptor = AnthropicHeaderInterceptor(workspace_id="ws-999", user_id="u-888")

View File

@@ -55,7 +55,7 @@ class TestOpenAIInterceptorIntegration:
assert llm.interceptor is interceptor
@pytest.mark.vcr(filter_headers=["authorization"])
@pytest.mark.vcr()
def test_openai_call_with_interceptor_tracks_requests(self) -> None:
"""Test that interceptor tracks OpenAI API requests."""
interceptor = OpenAITestInterceptor()
@@ -152,7 +152,7 @@ class TestOpenAILoggingInterceptor:
assert llm.interceptor is interceptor
assert isinstance(llm.interceptor, LoggingInterceptor)
@pytest.mark.vcr(filter_headers=["authorization"])
@pytest.mark.vcr()
def test_logging_interceptor_tracks_details(self) -> None:
"""Test that logging interceptor tracks request/response details."""
interceptor = LoggingInterceptor()
@@ -241,7 +241,7 @@ class TestOpenAIAuthInterceptor:
assert "X-Organization-ID" in modified_request.headers
assert modified_request.headers["X-Organization-ID"] == "test-org"
@pytest.mark.vcr(filter_headers=["authorization"])
@pytest.mark.vcr()
def test_auth_interceptor_with_real_call(self) -> None:
"""Test that auth interceptor works with real OpenAI API call."""
interceptor = AuthInterceptor(api_key="custom-123", org_id="org-789")

View File

@@ -34,7 +34,7 @@ def test_openai_completion_is_used_when_no_provider_prefix():
assert llm.provider == "openai"
assert llm.model == "gpt-4o"
@pytest.mark.vcr(filter_headers=["authorization"])
@pytest.mark.vcr()
def test_openai_is_default_provider_without_explicit_llm_set_on_agent():
"""
Test that OpenAI is the default provider when no explicit LLM is set on the agent
@@ -302,7 +302,7 @@ def test_openai_completion_with_tools():
assert call_kwargs['tools'] is not None
assert len(call_kwargs['tools']) > 0
@pytest.mark.vcr(filter_headers=["authorization"])
@pytest.mark.vcr()
def test_openai_completion_call_returns_usage_metrics():
"""
Test that OpenAICompletion.call returns usage metrics
@@ -530,7 +530,7 @@ def test_openai_streaming_with_response_model():
assert "text_format" not in call_kwargs
@pytest.mark.vcr(filter_headers=["authorization"])
@pytest.mark.vcr()
def test_openai_response_format_with_pydantic_model():
"""
Test that response_format with a Pydantic BaseModel returns structured output.
@@ -551,7 +551,7 @@ def test_openai_response_format_with_pydantic_model():
assert 0 <= result.confidence <= 1
@pytest.mark.vcr(filter_headers=["authorization"])
@pytest.mark.vcr()
def test_openai_response_format_with_dict():
"""
Test that response_format with a dict returns JSON output.
@@ -565,7 +565,7 @@ def test_openai_response_format_with_dict():
assert "status" in parsed
@pytest.mark.vcr(filter_headers=["authorization"])
@pytest.mark.vcr()
def test_openai_response_format_none():
"""
Test that when response_format is None, the API returns plain text.