File tree Expand file tree Collapse file tree 1 file changed +20
-0
lines changed Expand file tree Collapse file tree 1 file changed +20
-0
lines changed Original file line number Diff line number Diff line change 1+ import os
2+ from collections .abc import Generator
3+
4+ import pytest
5+
6+ from any_agent .config import AgentFramework
7+
8+
9+ @pytest .fixture (autouse = True )
10+ def mock_api_keys_for_unit_tests (
11+ request : pytest .FixtureRequest ,
12+ ) -> Generator [None , None , None ]:
13+ """Automatically provide dummy API keys for unit tests to avoid API key requirements."""
14+ if "agent_framework" in request .fixturenames :
15+ agent_framework = request .getfixturevalue ("agent_framework" )
16+ # Only set dummy API key if we're in a test that uses the agent_framework fixture
17+ # and the framework is OPENAI (which uses any-llm with the AnyLLM.create class-based interface)
18+ if agent_framework == AgentFramework .OPENAI :
19+ os .environ ["MISTRAL_API_KEY" ] = "dummy-mistral-key-for-unit-tests"
20+ yield
You can’t perform that action at this time.
0 commit comments