@@ -53,21 +53,16 @@ def test_to_url_githubcopilot(self):
5353 endpoint = AI_API_ENDPOINT_ENUM .AI_API_GITHUBCOPILOT
5454 assert endpoint .to_url () == 'https://api.githubcopilot.com'
5555
56- def test_unsupported_endpoint (self ):
56+ def test_unsupported_endpoint (self , monkeypatch ):
5757 """Test that unsupported API endpoint raises ValueError."""
58- try :
59- original_env = os .environ .pop ('AI_API_ENDPOINT' , None )
60- api_endpoint = 'https://unsupported.example.com'
61- os .environ ['AI_API_ENDPOINT' ] = api_endpoint
58+ api_endpoint = 'https://unsupported.example.com'
59+ monkeypatch .setenv ('AI_API_ENDPOINT' , api_endpoint )
60+ with pytest .raises (ValueError ) as excinfo :
61+ list_capi_models ("abc" )
62+ msg = str (excinfo .value )
63+ assert 'Unsupported Model Endpoint' in msg
64+ assert 'https://models.github.ai/inference' in msg
65+ assert 'https://api.githubcopilot.com' in msg
6266
63- with pytest .raises (ValueError ) as excinfo :
64- list_capi_models ("abc" )
65- msg = str (excinfo .value )
66- assert 'Unsupported Model Endpoint' in msg
67- assert 'https://models.github.ai/inference' in msg
68- assert 'https://api.githubcopilot.com' in msg
69- finally :
70- if original_env :
71- os .environ ['AI_API_ENDPOINT' ] = original_env
7267if __name__ == '__main__' :
7368 pytest .main ([__file__ , '-v' ])
0 commit comments