@@ -88,6 +88,7 @@ def _segment_task_init_mock(self, api, storage, split_storage, period, event):
8888 factory .block_until_ready ()
8989 time .sleep (1 ) # give a chance for the bg thread to set the ready status
9090 assert factory .ready
91+ factory .destroy ()
9192
9293 def test_redis_client_creation (self , mocker ):
9394 """Test that a client with redis storage is created correctly."""
@@ -165,6 +166,7 @@ def test_redis_client_creation(self, mocker):
165166 factory .block_until_ready ()
166167 time .sleep (1 ) # give a chance for the bg thread to set the ready status
167168 assert factory .ready
169+ factory .destroy ()
168170
169171
170172 def test_uwsgi_client_creation (self ):
@@ -182,6 +184,7 @@ def test_uwsgi_client_creation(self):
182184 factory .block_until_ready ()
183185 time .sleep (1 ) # give a chance for the bg thread to set the ready status
184186 assert factory .ready
187+ factory .destroy ()
185188
186189 def test_destroy (self , mocker ):
187190 """Test that tasks are shutdown and data is flushed when destroy is called."""
@@ -366,7 +369,7 @@ def _make_factory_with_apikey(apikey, *_, **__):
366369 assert _INSTANTIATED_FACTORIES ['some_api_key' ] == 1
367370 assert factory_module_logger .warning .mock_calls == []
368371
369- get_factory ('some_api_key' )
372+ factory2 = get_factory ('some_api_key' )
370373 assert _INSTANTIATED_FACTORIES ['some_api_key' ] == 2
371374 assert factory_module_logger .warning .mock_calls == [mocker .call (
372375 "factory instantiation: You already have %d %s with this API Key. "
@@ -377,7 +380,7 @@ def _make_factory_with_apikey(apikey, *_, **__):
377380 )]
378381
379382 factory_module_logger .reset_mock ()
380- get_factory ('some_api_key' )
383+ factory3 = get_factory ('some_api_key' )
381384 assert _INSTANTIATED_FACTORIES ['some_api_key' ] == 3
382385 assert factory_module_logger .warning .mock_calls == [mocker .call (
383386 "factory instantiation: You already have %d %s with this API Key. "
@@ -388,7 +391,7 @@ def _make_factory_with_apikey(apikey, *_, **__):
388391 )]
389392
390393 factory_module_logger .reset_mock ()
391- get_factory ('some_other_api_key' )
394+ factory4 = get_factory ('some_other_api_key' )
392395 assert _INSTANTIATED_FACTORIES ['some_api_key' ] == 3
393396 assert _INSTANTIATED_FACTORIES ['some_other_api_key' ] == 1
394397 assert factory_module_logger .warning .mock_calls == [mocker .call (
@@ -403,3 +406,6 @@ def _make_factory_with_apikey(apikey, *_, **__):
403406 event .wait ()
404407 assert _INSTANTIATED_FACTORIES ['some_other_api_key' ] == 1
405408 assert _INSTANTIATED_FACTORIES ['some_api_key' ] == 2
409+ factory2 .destroy ()
410+ factory3 .destroy ()
411+ factory4 .destroy ()
0 commit comments