@@ -1102,8 +1102,8 @@ def test_bad_uri(self):
11021102 async def test_auth_from_uri (self ):
11031103 host , port = await async_client_context .host , await async_client_context .port
11041104 await async_client_context .create_user ("admin" , "admin" , "pass" )
1105- self .addToCleanup (async_client_context .drop_user , "admin" , "admin" )
1106- self .addToCleanup (remove_all_users , self .client .pymongo_test )
1105+ self .addAsyncCleanup (async_client_context .drop_user , "admin" , "admin" )
1106+ self .addAsyncCleanup (remove_all_users , self .client .pymongo_test )
11071107
11081108 await async_client_context .create_user (
11091109 "pymongo_test" , "user" , "pass" , roles = ["userAdmin" , "readWrite" ]
@@ -1149,7 +1149,7 @@ async def test_auth_from_uri(self):
11491149 @async_client_context .require_auth
11501150 async def test_username_and_password (self ):
11511151 await async_client_context .create_user ("admin" , "ad min" , "pa/ss" )
1152- self .addToCleanup (async_client_context .drop_user , "admin" , "ad min" )
1152+ self .addAsyncCleanup (async_client_context .drop_user , "admin" , "ad min" )
11531153
11541154 c = await self .async_rs_or_single_client_noauth (username = "ad min" , password = "pa/ss" )
11551155
@@ -1258,7 +1258,6 @@ async def test_socket_timeout(self):
12581258 no_timeout = self .client
12591259 timeout_sec = 1
12601260 timeout = await self .async_rs_or_single_client (socketTimeoutMS = 1000 * timeout_sec )
1261- self .addToCleanup (timeout .close )
12621261
12631262 await no_timeout .pymongo_test .drop_collection ("test" )
12641263 await no_timeout .pymongo_test .test .insert_one ({"x" : 1 })
@@ -1325,7 +1324,7 @@ async def test_tz_aware(self):
13251324 self .assertRaises (ValueError , AsyncMongoClient , tz_aware = "foo" )
13261325
13271326 aware = await self .async_rs_or_single_client (tz_aware = True )
1328- self .addToCleanup (aware .close )
1327+ self .addAsyncCleanup (aware .close )
13291328 naive = self .client
13301329 await aware .pymongo_test .drop_collection ("test" )
13311330
@@ -1477,7 +1476,7 @@ async def test_lazy_connect_w0(self):
14771476 # Use a separate collection to avoid races where we're still
14781477 # completing an operation on a collection while the next test begins.
14791478 await async_client_context .client .drop_database ("test_lazy_connect_w0" )
1480- self .addToCleanup (async_client_context .client .drop_database , "test_lazy_connect_w0" )
1479+ self .addAsyncCleanup (async_client_context .client .drop_database , "test_lazy_connect_w0" )
14811480
14821481 client = await self .async_rs_or_single_client (connect = False , w = 0 )
14831482 await client .test_lazy_connect_w0 .test .insert_one ({})
@@ -2160,7 +2159,7 @@ async def test_exhaust_getmore_server_error(self):
21602159 await collection .drop ()
21612160
21622161 await collection .insert_many ([{} for _ in range (200 )])
2163- self .addToCleanup (async_client_context .client .pymongo_test .test .drop )
2162+ self .addAsyncCleanup (async_client_context .client .pymongo_test .test .drop )
21642163
21652164 pool = await async_get_pool (client )
21662165 pool ._check_interval_seconds = None # Never check.
@@ -2407,7 +2406,7 @@ async def test_discover_primary(self):
24072406 replicaSet = "rs" ,
24082407 heartbeatFrequencyMS = 500 ,
24092408 )
2410- self .addToCleanup (c .close )
2409+ self .addAsyncCleanup (c .close )
24112410
24122411 await async_wait_until (lambda : len (c .nodes ) == 3 , "connect" )
24132412
@@ -2434,7 +2433,7 @@ async def test_reconnect(self):
24342433 retryReads = False ,
24352434 serverSelectionTimeoutMS = 1000 ,
24362435 )
2437- self .addToCleanup (c .close )
2436+ self .addAsyncCleanup (c .close )
24382437
24392438 await async_wait_until (lambda : len (c .nodes ) == 3 , "connect" )
24402439
@@ -2472,7 +2471,7 @@ async def _test_network_error(self, operation_callback):
24722471 serverSelectionTimeoutMS = 1000 ,
24732472 )
24742473
2475- self .addToCleanup (c .close )
2474+ self .addAsyncCleanup (c .close )
24762475
24772476 # Set host-specific information so we can test whether it is reset.
24782477 c .set_wire_version_range ("a:1" , 2 , MIN_SUPPORTED_WIRE_VERSION )
@@ -2548,7 +2547,7 @@ async def test_rs_client_does_not_maintain_pool_to_arbiters(self):
25482547 minPoolSize = 1 , # minPoolSize
25492548 event_listeners = [listener ],
25502549 )
2551- self .addToCleanup (c .close )
2550+ self .addAsyncCleanup (c .close )
25522551
25532552 await async_wait_until (lambda : len (c .nodes ) == 3 , "connect" )
25542553 self .assertEqual (await c .address , ("a" , 1 ))
@@ -2578,7 +2577,7 @@ async def test_direct_client_maintains_pool_to_arbiter(self):
25782577 minPoolSize = 1 , # minPoolSize
25792578 event_listeners = [listener ],
25802579 )
2581- self .addToCleanup (c .close )
2580+ self .addAsyncCleanup (c .close )
25822581
25832582 await async_wait_until (lambda : len (c .nodes ) == 1 , "connect" )
25842583 self .assertEqual (await c .address , ("c" , 3 ))
0 commit comments