summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorVictor Stinner <vstinner@redhat.com>2018-09-26 16:09:32 (GMT)
committerGitHub <noreply@github.com>2018-09-26 16:09:32 (GMT)
commit43500a5907eb9ae2e470dcbffe73012cd456f5a1 (patch)
tree07661e1f6b40f534f22fb9642b19525f4f469dba
parentdfa11135ce53967ac97550d0a9343d32c9958ac0 (diff)
downloadcpython-43500a5907eb9ae2e470dcbffe73012cd456f5a1.zip
cpython-43500a5907eb9ae2e470dcbffe73012cd456f5a1.tar.gz
cpython-43500a5907eb9ae2e470dcbffe73012cd456f5a1.tar.bz2
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 d5d9e02dd3c6df06a8dd9ce75ee9b52976420a8b. Co-Authored-By: Nick Coghlan <ncoghlan@gmail.com>
-rw-r--r--Lib/test/test_import/__init__.py7
1 files changed, 5 insertions, 2 deletions
diff --git a/Lib/test/test_import/__init__.py b/Lib/test/test_import/__init__.py
index b73a96f..6fb7cb0 100644
--- a/Lib/test/test_import/__init__.py
+++ b/Lib/test/test_import/__init__.py
@@ -779,8 +779,11 @@ class PycacheTests(unittest.TestCase):
unload(TESTFN)
importlib.invalidate_caches()
m = __import__(TESTFN)
- self.assertEqual(m.__file__,
- os.path.join(os.curdir, os.path.relpath(pyc_file)))
+ try:
+ self.assertEqual(m.__file__,
+ os.path.join(os.curdir, os.path.relpath(pyc_file)))
+ finally:
+ os.remove(pyc_file)
def test___cached__(self):
# Modules now also have an __cached__ that points to the pyc file.