@@ -61,11 +61,14 @@ def test_inject_is_noop_on_non_judge_evaluator(self, caplog):
6161
6262
6363class TestFailClosed :
64- async def test_unresolved_credential_errors_instead_of_ambient_auth (self ):
64+ async def test_unresolved_credential_errors_instead_of_ambient_auth (self , monkeypatch ):
65+ monkeypatch .delenv ("OPENAI_API_KEY" , raising = False )
66+ # hallucinations_v1 is judge-backed but not in METRICS_NEEDING_EXPECTED, so the
67+ # credential check is reached with no golden eval set or sentinel invocations.
6568 result = await evaluate_builtin_metric (
66- metric_name = "final_response_match_v2 " ,
69+ metric_name = "hallucinations_v1 " ,
6770 actual_invocations = [],
68- expected_invocations = [ object ()] ,
71+ expected_invocations = None ,
6972 judge_model = "openai/gpt-4o" ,
7073 threshold = 0.5 ,
7174 credential_ref = "judge-openai" ,
@@ -86,8 +89,10 @@ async def run_one(key: str) -> str:
8689 # read back. With a shared global instead of a ContextVar, both tasks
8790 # would observe the last writer's key and this assertion would fail.
8891 await asyncio .sleep (0 )
92+ resolved = get_resolved_credential ("judge" )
93+ assert resolved is not None
8994 evaluator = _judge_evaluator ()
90- _inject_judge_credential (evaluator , get_resolved_credential ( "judge" ) )
95+ _inject_judge_credential (evaluator , resolved )
9196 return evaluator ._judge_model ._additional_args ["api_key" ]
9297
9398 first , second = await asyncio .gather (run_one ("sk-AAA" ), run_one ("sk-BBB" ))
0 commit comments