Skip to content

Commit b9e8927

Browse files
Update Lib/test/test_import/__init__.py
Co-authored-by: Eric Snow <[email protected]>
1 parent 80b6eec commit b9e8927

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

Lib/test/test_import/__init__.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2719,14 +2719,17 @@ def tearDown(self):
27192719
rmtree(self.dir_name)
27202720

27212721
def assert_importing_possible(self, name):
2722+
normalized = unicodedata.normalize('NFKC', name)
27222723
filename = os.path.join(self.dir_name, f"{name}.py")
27232724
with open(filename, "w") as stream:
27242725
stream.write("SPAM = 'spam'\n")
27252726

27262727
values = {}
27272728
exec(f"from {name} import SPAM", values, values)
2728-
self.assertEqual(values["SPAM"], "spam")
2729-
del sys.modules[unicodedata.normalize('NFKC', name)]
2729+
try:
2730+
self.assertEqual(values["SPAM"], "spam")
2731+
finally:
2732+
del sys.modules[normalized]
27302733

27312734
def test_import_precomposed(self):
27322735
name = 'M\u00E4dchen'

0 commit comments

Comments
 (0)