Skip to content

Commit c3a54ac

Browse files
Update tests/test_api_endpoint_config.py
Co-authored-by: Copilot <[email protected]>
1 parent 04d729b commit c3a54ac

File tree

1 file changed

+12
-11
lines changed

1 file changed

+12
-11
lines changed

tests/test_api_endpoint_config.py

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -53,17 +53,18 @@ def test_to_url_githubcopilot(self):
5353

5454
def test_unsupported_endpoint(self):
5555
original_env = os.environ.pop('AI_API_ENDPOINT', None)
56-
api_endpoint = 'https://unsupported.example.com'
57-
os.environ['AI_API_ENDPOINT'] = api_endpoint
58-
59-
with pytest.raises(ValueError) as excinfo:
60-
list_capi_models("abc")
61-
msg = str(excinfo.value)
62-
assert 'Unsupported Model Endpoint' in msg
63-
assert 'https://models.github.ai/inference' in msg
64-
assert 'https://api.githubcopilot.com' in msg
65-
if original_env:
66-
os.environ['AI_API_ENDPOINT'] = original_env
56+
try:
57+
api_endpoint = 'https://unsupported.example.com'
58+
os.environ['AI_API_ENDPOINT'] = api_endpoint
6759

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
66+
finally:
67+
if original_env:
68+
os.environ['AI_API_ENDPOINT'] = original_env
6869
if __name__ == '__main__':
6970
pytest.main([__file__, '-v'])

0 commit comments

Comments
 (0)