@@ -328,34 +328,23 @@ def test_trimming_with_untokenizable_field(caplog: pytest.LogCaptureFixture) ->
328328
329329
330330def test_aget_valid_models ():
331- old_environ = os .environ
332- os .environ = {"OPENAI_API_KEY" : "temp" } # mock set only openai key in environ
331+ with mock .patch .dict (os .environ , {"OPENAI_API_KEY" : "temp" }, clear = True ):
332+ valid_models = get_valid_models ()
333+ print (valid_models )
333334
334- valid_models = get_valid_models ()
335- print (valid_models )
336-
337- # list of openai supported llms on litellm
338- expected_models = (
339- litellm .open_ai_chat_completion_models | litellm .open_ai_text_completion_models
340- )
341-
342- assert set (valid_models ) == set (expected_models )
335+ # list of openai supported llms on litellm
336+ expected_models = (
337+ litellm .open_ai_chat_completion_models | litellm .open_ai_text_completion_models
338+ )
343339
344- # reset replicate env key
345- os .environ = old_environ
340+ assert set (valid_models ) == set (expected_models )
346341
347342 # GEMINI
348- expected_models = litellm .gemini_models
349- old_environ = os .environ
350- os .environ = {"GEMINI_API_KEY" : "temp" } # mock set only openai key in environ
351-
352- valid_models = get_valid_models ()
353-
354- print (valid_models )
355- assert set (valid_models ) == set (expected_models )
343+ with mock .patch .dict (os .environ , {"GEMINI_API_KEY" : "temp" }, clear = True ):
344+ valid_models = get_valid_models ()
356345
357- # reset replicate env key
358- os . environ = old_environ
346+ print ( valid_models )
347+ assert set ( valid_models ) == set ( litellm . gemini_models )
359348
360349
361350@pytest .mark .parametrize ("custom_llm_provider" , ["anthropic" , "xai" ])
0 commit comments