fix: Resolve test isolation issues for o3-pro test
- Fixed test_fallback_with_shorthand_restrictions to clear restriction service singleton in finally block, preventing state leakage - Updated o3-pro test to use @patch.dict for OPENAI_ALLOWED_MODELS, following standard pattern and allowing both o3-pro and o3-pro-2025-06-10 - Removed invalid cassette file that had wrong request content The test now passes in both isolated and full suite runs. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
File diff suppressed because one or more lines are too long
@@ -694,3 +694,6 @@ class TestAutoModeWithRestrictions:
|
|||||||
registry._initialized_providers.clear()
|
registry._initialized_providers.clear()
|
||||||
registry._providers.update(original_providers)
|
registry._providers.update(original_providers)
|
||||||
registry._initialized_providers.update(original_initialized)
|
registry._initialized_providers.update(original_initialized)
|
||||||
|
|
||||||
|
# Clear the restriction service to prevent state leakage
|
||||||
|
utils.model_restrictions._restriction_service = None
|
||||||
|
|||||||
@@ -10,8 +10,10 @@ the OpenAI SDK to create real response objects that we can test.
|
|||||||
RECORDING: To record new responses, delete the cassette file and run with real API keys.
|
RECORDING: To record new responses, delete the cassette file and run with real API keys.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
import os
|
||||||
import unittest
|
import unittest
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
|
from unittest.mock import patch
|
||||||
|
|
||||||
import pytest
|
import pytest
|
||||||
from dotenv import load_dotenv
|
from dotenv import load_dotenv
|
||||||
@@ -34,11 +36,6 @@ class TestO3ProOutputTextFix:
|
|||||||
|
|
||||||
def setup_method(self):
|
def setup_method(self):
|
||||||
"""Set up the test by ensuring clean registry state."""
|
"""Set up the test by ensuring clean registry state."""
|
||||||
# Clear the restriction service singleton to ensure clean state
|
|
||||||
import utils.model_restrictions
|
|
||||||
|
|
||||||
utils.model_restrictions._restriction_service = None
|
|
||||||
|
|
||||||
# Use the new public API for registry cleanup
|
# Use the new public API for registry cleanup
|
||||||
ModelProviderRegistry.reset_for_testing()
|
ModelProviderRegistry.reset_for_testing()
|
||||||
# Provider registration is now handled by inject_transport helper
|
# Provider registration is now handled by inject_transport helper
|
||||||
@@ -49,6 +46,7 @@ class TestO3ProOutputTextFix:
|
|||||||
ModelProviderRegistry.reset_for_testing()
|
ModelProviderRegistry.reset_for_testing()
|
||||||
|
|
||||||
@pytest.mark.no_mock_provider # Disable provider mocking for this test
|
@pytest.mark.no_mock_provider # Disable provider mocking for this test
|
||||||
|
@patch.dict(os.environ, {"OPENAI_ALLOWED_MODELS": "o3-pro,o3-pro-2025-06-10"})
|
||||||
async def test_o3_pro_uses_output_text_field(self, monkeypatch):
|
async def test_o3_pro_uses_output_text_field(self, monkeypatch):
|
||||||
"""Test that o3-pro parsing uses the output_text convenience field via ChatTool."""
|
"""Test that o3-pro parsing uses the output_text convenience field via ChatTool."""
|
||||||
# Set API key inline - helper will handle provider registration
|
# Set API key inline - helper will handle provider registration
|
||||||
|
|||||||
@@ -22,11 +22,10 @@ def inject_transport(monkeypatch, cassette_path: str):
|
|||||||
transport = inject_transport(monkeypatch, "path/to/cassette.json")
|
transport = inject_transport(monkeypatch, "path/to/cassette.json")
|
||||||
"""
|
"""
|
||||||
# Ensure OpenAI provider is registered - always needed for transport injection
|
# Ensure OpenAI provider is registered - always needed for transport injection
|
||||||
import os
|
|
||||||
from providers.base import ProviderType
|
from providers.base import ProviderType
|
||||||
from providers.openai_provider import OpenAIModelProvider
|
from providers.openai_provider import OpenAIModelProvider
|
||||||
from providers.registry import ModelProviderRegistry
|
from providers.registry import ModelProviderRegistry
|
||||||
|
|
||||||
# Always register OpenAI provider for transport tests (API key might be dummy)
|
# Always register OpenAI provider for transport tests (API key might be dummy)
|
||||||
ModelProviderRegistry.register_provider(ProviderType.OPENAI, OpenAIModelProvider)
|
ModelProviderRegistry.register_provider(ProviderType.OPENAI, OpenAIModelProvider)
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user