Skip to content

Commit

Permalink
tell by has_state instead of name
Browse files Browse the repository at this point in the history
  • Loading branch information
sunmy2019 committed May 30, 2023
1 parent a0f5bb7 commit 26a9ede
Showing 1 changed file with 8 additions and 7 deletions.
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 comments on commit 26a9ede

Please # to comment.