fix: Ensure dummy API keys are set for tests with no_mock_provider marker

The test failures in CI were caused by tests with @pytest.mark.no_mock_provider
that prevented dummy API keys from being set. In CI with no real API keys,
this led to 'Model not available' errors.

Changed pytest_collection_modifyitems to always set dummy keys if missing,
regardless of markers. This ensures tests work in CI while still allowing
real API keys to be used when present.

Fixes test_conversation_field_mapping.py failures in CI across Python 3.10-3.12.
This commit is contained in:
Josh Vera
2025-07-13 11:29:02 -06:00
parent f00a5eaa36
commit 6fa7cbcf0d

View File

@@ -88,15 +88,9 @@ def pytest_configure(config):
def pytest_collection_modifyitems(session, config, items):
"""Hook that runs after test collection to check for no_mock_provider markers."""
# Check if any test has the no_mock_provider marker
for item in items:
if item.get_closest_marker("no_mock_provider"):
config._needs_dummy_keys = False
break
# Set dummy keys only if no test needs real keys
if config._needs_dummy_keys:
_set_dummy_keys_if_missing()
# Always set dummy keys if real keys are missing
# This ensures tests work in CI even with no_mock_provider marker
_set_dummy_keys_if_missing()
@pytest.fixture(autouse=True)