@@ -263,6 +263,7 @@ def test_issue16421_multiple_modules_in_one_dll(self):
263
263
with self .assertRaises (ImportError ):
264
264
imp .load_dynamic ('nonexistent' , pathname )
265
265
266
+ @unittest .skip ('known refleak (temporarily skipping)' )
266
267
@requires_subinterpreters
267
268
@requires_load_dynamic
268
269
def test_singlephase_multiple_interpreters (self ):
@@ -329,9 +330,10 @@ def clean_up():
329
330
# However, globals are still shared.
330
331
_interpreters .run_string (interp2 , script % 2 )
331
332
333
+ @unittest .skip ('known refleak (temporarily skipping)' )
332
334
@requires_load_dynamic
333
335
def test_singlephase_variants (self ):
334
- ''' Exercise the most meaningful variants described in Python/import.c.'''
336
+ # Exercise the most meaningful variants described in Python/import.c.
335
337
self .maxDiff = None
336
338
337
339
basename = '_testsinglephase'
@@ -343,6 +345,11 @@ def clean_up():
343
345
_testsinglephase ._clear_globals ()
344
346
self .addCleanup (clean_up )
345
347
348
+ def add_ext_cleanup (name ):
349
+ def clean_up ():
350
+ _testinternalcapi .clear_extension (name , pathname )
351
+ self .addCleanup (clean_up )
352
+
346
353
modules = {}
347
354
def load (name ):
348
355
assert name not in modules
@@ -440,6 +447,7 @@ def check_with_reinit_reloaded(module, lookedup, initialized,
440
447
# Check the "basic" module.
441
448
442
449
name = basename
450
+ add_ext_cleanup (name )
443
451
expected_init_count = 1
444
452
with self .subTest (name ):
445
453
mod = load (name )
@@ -457,6 +465,7 @@ def check_with_reinit_reloaded(module, lookedup, initialized,
457
465
# Check its indirect variants.
458
466
459
467
name = f'{ basename } _basic_wrapper'
468
+ add_ext_cleanup (name )
460
469
expected_init_count += 1
461
470
with self .subTest (name ):
462
471
mod = load (name )
@@ -480,6 +489,7 @@ def check_with_reinit_reloaded(module, lookedup, initialized,
480
489
# Check its direct variant.
481
490
482
491
name = f'{ basename } _basic_copy'
492
+ add_ext_cleanup (name )
483
493
expected_init_count += 1
484
494
with self .subTest (name ):
485
495
mod = load (name )
@@ -500,6 +510,7 @@ def check_with_reinit_reloaded(module, lookedup, initialized,
500
510
# Check the non-basic variant that has no state.
501
511
502
512
name = f'{ basename } _with_reinit'
513
+ add_ext_cleanup (name )
503
514
with self .subTest (name ):
504
515
mod = load (name )
505
516
lookedup , initialized , cached = check_common (name , mod )
@@ -518,6 +529,7 @@ def check_with_reinit_reloaded(module, lookedup, initialized,
518
529
# Check the basic variant that has state.
519
530
520
531
name = f'{ basename } _with_state'
532
+ add_ext_cleanup (name )
521
533
with self .subTest (name ):
522
534
mod = load (name )
523
535
lookedup , initialized , cached = check_common (name , mod )
0 commit comments