@@ -478,6 +478,21 @@ async def insert_initial_data(self, initial_data):
478478 # Ensure collection exists
479479 await db .create_collection (coll_name , write_concern = wc , ** opts )
480480
481+ @classmethod
482+ def setUpClass (cls ) -> None :
483+ # Speed up the tests by decreasing the heartbeat frequency.
484+ cls .knobs = client_knobs (
485+ heartbeat_frequency = 0.1 ,
486+ min_heartbeat_interval = 0.1 ,
487+ kill_cursor_frequency = 0.1 ,
488+ events_queue_frequency = 0.1 ,
489+ )
490+ cls .knobs .enable ()
491+
492+ @classmethod
493+ def tearDownClass (cls ) -> None :
494+ cls .knobs .disable ()
495+
481496 async def asyncSetUp (self ):
482497 # super call creates internal client cls.client
483498 await super ().asyncSetUp ()
@@ -503,15 +518,6 @@ async def asyncSetUp(self):
503518 for address in async_client_context .mongoses :
504519 self .mongos_clients .append (await self .async_single_client ("{}:{}" .format (* address )))
505520
506- # Speed up the tests by decreasing the heartbeat frequency.
507- self .knobs = client_knobs (
508- heartbeat_frequency = 0.1 ,
509- min_heartbeat_interval = 0.1 ,
510- kill_cursor_frequency = 0.1 ,
511- events_queue_frequency = 0.1 ,
512- )
513- self .knobs .enable ()
514-
515521 # process schemaVersion
516522 # note: we check major schema version during class generation
517523 version = Version .from_string (self .TEST_SPEC ["schemaVersion" ])
@@ -525,7 +531,6 @@ async def asyncSetUp(self):
525531 self .match_evaluator = MatchEvaluatorUtil (self )
526532
527533 async def asyncTearDown (self ):
528- self .knobs .disable ()
529534 for client in self .mongos_clients :
530535 await client .close ()
531536 await super ().asyncTearDown ()
0 commit comments