10000 gh-102251: Explicitly free state for test modules with state in test_import by sunmy2019 · Pull Request #105085 · python/cpython · GitHub
[go: up one dir, main page]

Skip to content

gh-102251: Explicitly free state for test modules with state in test_import #105085

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
merged 8 commits into from
May 31, 2023
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
tell by has_state instead of name
  • Loading branch information
sunmy2019 committed May 30, 2023
commit 26a9ede0800fdb6ba15d161ee3fa7a85024a82e9
15 changes: 8 additions & 7 deletions Lib/test/test_import/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2380,17 +2380,18 @@ def test_with_reinit_reloaded(self):
# Keep a reference around.
basic = self.load(self.NAME)

for name in [
f'{self.NAME}_with_reinit', # m_size == 0
f'{self.NAME}_with_state', # m_size > 0
for name, has_state in [
(f'{self.NAME}_with_reinit', False), # m_size == 0
(f'{self.NAME}_with_state', True), # m_size > 0
]:
self.add_module_cleanup(name)
with self.subTest(name):
with self.subTest(name=name, has_state=has_state):
loaded = self.load(name)
reloaded = self.re_load(name, loaded.module)

if name.endswith("_with_state"):
if has_state:
self.addCleanup(loaded.module._clear_module_state)

reloaded = self.re_load(name, loaded.module)
if has_state:
self.addCleanup(reloaded.module._clear_module_state)

self.check_common(loaded)
Expand Down
0