mirror of
https://github.com/BerriAI/litellm.git
synced 2026-09-13 23:11:40 +00:00
tests(zai): use monkeypatch.setattr for litellm.api_key to satisfy test-quality rules
This commit is contained in:
parent
1b19dea96d
commit
234a4b6908
1 changed files with 8 additions and 11 deletions
|
|
@ -83,17 +83,14 @@ def test_zai_responses_headers_fall_back_to_environment_key(monkeypatch):
|
|||
|
||||
def test_zai_responses_headers_prefer_zai_key_over_global_key(monkeypatch):
|
||||
monkeypatch.setenv("ZAI_API_KEY", "sk-zai-env")
|
||||
original_api_key = litellm.api_key
|
||||
litellm.api_key = "sk-global-other-provider"
|
||||
try:
|
||||
config = ZAIResponsesAPIConfig()
|
||||
monkeypatch.setattr(litellm, "api_key", "sk-global-other-provider", raising=False)
|
||||
|
||||
headers = config.validate_environment(
|
||||
headers={},
|
||||
model="glm-5.3",
|
||||
litellm_params=GenericLiteLLMParams(),
|
||||
)
|
||||
finally:
|
||||
litellm.api_key = original_api_key
|
||||
config = ZAIResponsesAPIConfig()
|
||||
|
||||
headers = config.validate_environment(
|
||||
headers={},
|
||||
model="glm-5.3",
|
||||
litellm_params=GenericLiteLLMParams(),
|
||||
)
|
||||
|
||||
assert headers["Authorization"] == "Bearer sk-zai-env"
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue