mirror of
https://github.com/BerriAI/litellm.git
synced 2026-09-07 08:26:10 +00:00
fix: clear litellm.api_key in OpenRouter validate_environment test
The test_validate_environment_raises_without_key test was failing because litellm.api_key may be set globally in the test environment. Clear it along with OPENROUTER_API_KEY and OR_API_KEY env vars using monkeypatch. Co-authored-by: Ishaan Jaff <ishaan-jaff@users.noreply.github.com>
This commit is contained in:
parent
1f3d9f0428
commit
fb238777c1
1 changed files with 6 additions and 1 deletions
|
|
@ -60,11 +60,16 @@ class TestOpenRouterResponsesAPIConfig:
|
|||
)
|
||||
assert headers["Authorization"] == "Bearer sk-or-test-key"
|
||||
|
||||
def test_validate_environment_raises_without_key(self):
|
||||
def test_validate_environment_raises_without_key(self, monkeypatch):
|
||||
"""validate_environment should raise when no API key is available."""
|
||||
config = OpenRouterResponsesAPIConfig()
|
||||
from litellm.types.router import GenericLiteLLMParams
|
||||
|
||||
# Clear any globally set API keys so the validation correctly raises
|
||||
monkeypatch.setattr(litellm, "api_key", None)
|
||||
monkeypatch.delenv("OPENROUTER_API_KEY", raising=False)
|
||||
monkeypatch.delenv("OR_API_KEY", raising=False)
|
||||
|
||||
try:
|
||||
config.validate_environment(
|
||||
headers={},
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue