Skip to content

Commit 1e2357b

Browse files
chore: use pytest.raises
1 parent ae5df0e commit 1e2357b

File tree

1 file changed

+4
-8
lines changed

1 file changed

+4
-8
lines changed

tests/unit/test_client.py

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -169,16 +169,14 @@ async def test_cloud_sql_error_messages_get_metadata(
169169
payload=resp_body,
170170
repeat=True,
171171
)
172-
try:
172+
with pytest.raises(ClientResponseError) as e:
173173
await client._get_metadata("my-project", "my-region", "my-instance")
174-
except ClientResponseError as e:
175174
assert e.status == 403
176175
assert (
177176
e.message
178177
== "Cloud SQL Admin API has not been used in project 123456789 before or it is disabled"
179178
)
180-
finally:
181-
await client.close()
179+
await client.close()
182180

183181

184182
async def test_cloud_sql_error_messages_get_ephemeral(
@@ -207,10 +205,8 @@ async def test_cloud_sql_error_messages_get_ephemeral(
207205
payload=resp_body,
208206
repeat=True,
209207
)
210-
try:
208+
with pytest.raises(ClientResponseError) as e:
211209
await client._get_ephemeral("my-project", "my-instance", "my-key")
212-
except ClientResponseError as e:
213210
assert e.status == 404
214211
assert e.message == "The Cloud SQL instance does not exist."
215-
finally:
216-
await client.close()
212+
await client.close()

0 commit comments

Comments
 (0)