8000 gh-101758: Fix Refleak Testing With test_singlephase_variants by ericsnowcurrently · Pull Request #101969 · python/cpython · GitHub
[go: up one dir, main page]

Skip to content

gh-101758: Fix Refleak Testing With test_singlephase_variants #101969

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Changes from all commits
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
14 changes: 13 additions & 1 deletion Lib/test/test_imp.py
Original file line number Diff line number Diff line change
Expand Up @@ -263,6 +263,7 @@ def test_issue16421_multiple_modules_in_one_dll(self):
with self.assertRaises(ImportError):
imp.load_dynamic('nonexistent', pathname)

@unittest.skip('known refleak (temporarily skipping)')
@requires_subinterpreters
@requires_load_dynamic
def test_singlephase_multiple_interpreters(self):
Expand Down Expand Up @@ -329,9 +330,10 @@ def clean_up():
# However, globals are still shared.
_interpreters.run_string(interp2, script % 2)

@unittest.skip('known refleak (temporarily skipping)')
@requires_load_dynamic
def test_singlephase_variants(self):
'''Exercise the most meaningful variants described in Python/import.c.'''
# Exercise the most meaningful variants described in Python/import.c.
self.maxDiff = None

basename = '_testsinglephase'
Expand All @@ -343,6 +345,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 @@ -440,6 +447,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 @@ -457,6 +465,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 @@ -480,6 +489,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 @@ -500,6 +510,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 @@ -518,6 +529,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
0