Skip to content

Commit

Permalink
Update Lib/test/test_import/__init__.py
Browse files Browse the repository at this point in the history
Co-authored-by: Eric Snow <[email protected]>
  • Loading branch information
ronaldoussoren and ericsnowcurrently authored Dec 29, 2023
1 parent 80b6eec commit b9e8927
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions Lib/test/test_import/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2719,14 +2719,17 @@ def tearDown(self):
rmtree(self.dir_name)

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

values = {}
exec(f"from {name} import SPAM", values, values)
self.assertEqual(values["SPAM"], "spam")
del sys.modules[unicodedata.normalize('NFKC', name)]
try:
self.assertEqual(values["SPAM"], "spam")
finally:
del sys.modules[normalized]

def test_import_precomposed(self):
name = 'M\u00E4dchen'
Expand Down

0 comments on commit b9e8927

Please sign in to comment.