Skip to content

Commit 43500a5

Browse files
vstinnerncoghlan
andauthored
bpo-28655: Fix test_import.test_missing_source_legacy() (GH-9589)
bpo-28655, bpo-33053: test_import.test_missing_source_legacy() now removes the .pyc file that it creates to avoid leaking a file. Fix extract from commit d5d9e02. Co-Authored-By: Nick Coghlan <[email protected]>
1 parent dfa1113 commit 43500a5

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
@@ -779,8 +779,11 @@ def test_missing_source_legacy(self):
779779
unload(TESTFN)
780780
importlib.invalidate_caches()
781781
m = __import__(TESTFN)
782-
self.assertEqual(m.__file__,
783-
os.path.join(os.curdir, os.path.relpath(pyc_file)))
782+
try:
783+
self.assertEqual(m.__file__,
784+
os.path.join(os.curdir, os.path.relpath(pyc_file)))
785+
finally:
786+
os.remove(pyc_file)
784787

785788
def test___cached__(self):
786789
# Modules now also have an __cached__ that points to the pyc file.

0 commit comments

Comments
 (0)