Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Get test_singlephase_variants working under refleak detection.
  • Loading branch information
ericsnowcurrently committed Feb 16, 2023
commit fc8e344dfaed8955a3289dfb80232b436882c060
10 changes: 10 additions & 0 deletions Lib/test/test_imp.py
Original file line number Diff line number Diff line change
Expand Up @@ -333,6 +333,11 @@ def clean_up():
_testsinglephase._clear_globals()
self.addCleanup(clean_up)

def add_ext_cleanup(name):
def clean_up():
_testinternalcapi.clear_extension(name, pathname)
self.addCleanup(clean_up)

modules = {}
def load(name):
assert name not in modules
Expand Down Expand Up @@ -430,6 +435,7 @@ def check_with_reinit_reloaded(module, lookedup, initialized,
# Check the "basic" module.

name = basename
add_ext_cleanup(name)
expected_init_count = 1
with self.subTest(name):
mod = load(name)
Expand All @@ -447,6 +453,7 @@ def check_with_reinit_reloaded(module, lookedup, initialized,
# Check its indirect variants.

name = f'{basename}_basic_wrapper'
add_ext_cleanup(name)
expected_init_count += 1
with self.subTest(name):
mod = load(name)
Expand All @@ -470,6 +477,7 @@ def check_with_reinit_reloaded(module, lookedup, initialized,
# Check its direct variant.

name = f'{basename}_basic_copy'
add_ext_cleanup(name)
expected_init_count += 1
with self.subTest(name):
mod = load(name)
Expand All @@ -490,6 +498,7 @@ def check_with_reinit_reloaded(module, lookedup, initialized,
# Check the non-basic variant that has no state.

name = f'{basename}_with_reinit'
add_ext_cleanup(name)
with self.subTest(name):
mod = load(name)
lookedup, initialized, cached = check_common(name, mod)
Expand All @@ -508,6 +517,7 @@ def check_with_reinit_reloaded(module, lookedup, initialized,
# Check the basic variant that has state.

name = f'{basename}_with_state'
add_ext_cleanup(name)
with self.subTest(name):
mod = load(name)
lookedup, initialized, cached = check_common(name, mod)
Expand Down