@@ -990,17 +990,22 @@ def test_connections_registry(mock_post_requests):
990990@mock .patch ("snowflake.connector.connection.CRLCacheFactory" )
991991def test_connections_registry_stops_crl_task_if_empty (crl_mock , mock_post_requests ):
992992 """Test the individual methods of _ConnectionsPool."""
993- from snowflake .connector .connection import _connections_registry
994-
995- # Create a connection
996- conn1 = fake_connector ()
997- conn2 = fake_connector ()
993+ from snowflake .connector .connection import _ConnectionsRegistry
998994
999- # Don't stop the task if pool is not empty
1000- conn1 .close ()
1001- crl_mock .stop_periodic_cleanup .assert_not_called ()
1002-
1003- # Stop the task if the pool is emptied
1004- conn2 .close ()
1005- assert _connections_registry .get_connection_count () == 0
1006- crl_mock .stop_periodic_cleanup .assert_called_once ()
995+ # Mock the registry to avoid side effects from other tests due to _ConnectionsRegistry being a singleton
996+ with mock .patch (
997+ "snowflake.connector.connection._connections_registry" , _ConnectionsRegistry ()
998+ ) as mock_registry :
999+ # Create a connection
1000+ conn1 = fake_connector ()
1001+ conn2 = fake_connector ()
1002+ assert mock_registry .get_connection_count () == 2
1003+
1004+ # Don't stop the task if pool is not empty
1005+ conn1 .close ()
1006+ crl_mock .stop_periodic_cleanup .assert_not_called ()
1007+
1008+ # Stop the task if the pool is emptied
1009+ conn2 .close ()
1010+ assert mock_registry .get_connection_count () == 0
1011+ crl_mock .stop_periodic_cleanup .assert_called_once ()
0 commit comments