@@ -183,6 +183,9 @@ def load_dfk_session(request, pytestconfig, tmpd_cwd_session):
183
183
this_process = psutil .Process ()
184
184
start_fds = this_process .num_fds ()
185
185
logger .error (f"BENC: start open fds: { start_fds } " )
186
+
187
+ assert threading .active_count () == 1 , "precondition: only one thread can be running before this test: " + repr (threading .enumerate ())
188
+
186
189
spec = importlib .util .spec_from_file_location ('' , config )
187
190
module = importlib .util .module_from_spec (spec )
188
191
spec .loader .exec_module (module )
@@ -217,6 +220,8 @@ def load_dfk_session(request, pytestconfig, tmpd_cwd_session):
217
220
logger .error (f"BENC: end open fds: { end_fds } (vs { start_fds } at start)" )
218
221
assert start_fds == end_fds , "number of open fds changed across test run"
219
222
223
+ assert threading .active_count () == 1 , "test left threads running: " + repr (threading .enumerate ())
224
+
220
225
else :
221
226
yield
222
227
@@ -243,6 +248,7 @@ def load_dfk_local_module(request, pytestconfig, tmpd_cwd_session):
243
248
logger .error (f"BENC: start open fds: { start_fds } " )
244
249
logger .error (f"BENC: start threads: { threading .active_count ()} " )
245
250
251
+ assert threading .active_count () == 1 , "precondition: only one thread can be running before this test"
246
252
local_setup = getattr (request .module , "local_setup" , None )
247
253
local_teardown = getattr (request .module , "local_teardown" , None )
248
254
local_config = getattr (request .module , "local_config" , None )
@@ -285,6 +291,8 @@ def load_dfk_local_module(request, pytestconfig, tmpd_cwd_session):
285
291
os .system (f"ls -l /proc/{ os .getpid ()} /fd" )
286
292
pytest .fail ("BENC: number of open fds increased across test" )
287
293
294
+ assert threading .active_count () == 1 , "test left threads running: " + repr (threading .enumerate ())
295
+
288
296
else :
289
297
yield
290
298
0 commit comments