bpo-28655: Fix test_import.test_missing_source_legacy() (GH-9589) · python/cpython@43500a5

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.