From 9c69838a40c7181035190a14c01787daa323e4fd Mon Sep 17 00:00:00 2001 From: rhatgadkar-goog Date: Mon, 18 Nov 2024 22:08:55 +0000 Subject: [PATCH] chore: use sync instead of async in test `test_Connector_remove_cached_bad_instance` doesn't need to be async, because it can use the event loop that is generated by `Connector.__init__()` function. --- tests/unit/test_connector.py | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/tests/unit/test_connector.py b/tests/unit/test_connector.py index 6afc366..a02ad30 100644 --- a/tests/unit/test_connector.py +++ b/tests/unit/test_connector.py @@ -209,7 +209,7 @@ def test_Connector_close_called_multiple_times(credentials: FakeCredentials) -> connector.close() -async def test_Connector_remove_cached_bad_instance( +def test_Connector_remove_cached_bad_instance( credentials: FakeCredentials, ) -> None: """When a Connector attempts to retrieve connection info for a @@ -219,14 +219,8 @@ async def test_Connector_remove_cached_bad_instance( """ instance_uri = "projects/test-project/locations/test-region/clusters/test-cluster/instances/bad-test-instance" with Connector(credentials) as connector: - connector._keys = asyncio.wrap_future( - asyncio.run_coroutine_threadsafe( - generate_keys(), asyncio.get_running_loop() - ), - loop=asyncio.get_running_loop(), - ) with pytest.raises(ClientResponseError): - await connector.connect_async(instance_uri, "pg8000") + connector.connect(instance_uri, "pg8000") assert instance_uri not in connector._cache