diff --git a/packages/google-cloud-bigquery/tests/system/test_client.py b/packages/google-cloud-bigquery/tests/system/test_client.py index 9ddec48428b1..8e7ed8c47e56 100644 --- a/packages/google-cloud-bigquery/tests/system/test_client.py +++ b/packages/google-cloud-bigquery/tests/system/test_client.py @@ -2182,6 +2182,11 @@ def test_dbapi_dry_run_query(self): def test_dbapi_connection_does_not_leak_sockets(self): pytest.importorskip("google.cloud.bigquery_storage") + + # Ensure any garbage collection from previous tests is done to avoid false positives. + import gc + gc.collect() + current_process = psutil.Process() conn_start = current_process.net_connections() conn_count_start = len(conn_start)