diff --git a/Lib/test/test_import/__init__.py b/Lib/test/test_import/__init__.py index b06096700d1332a..ff19fd1c1c91e69 100644 --- a/Lib/test/test_import/__init__.py +++ b/Lib/test/test_import/__init__.py @@ -487,6 +487,7 @@ def test_with_extension(ext): forget(TESTFN) unlink(source) unlink(pyc) + rmtree('__pycache__') sys.path.insert(0, os.curdir) try: @@ -666,6 +667,7 @@ def __del__(self): import importlib sys.argv.insert(0, C()) """)) + self.addCleanup(unlink, testfn) script_helper.assert_python_ok(testfn) @skip_if_dont_write_bytecode @@ -2063,6 +2065,7 @@ def test_unencodable_filename(self): # encode filenames, especially on Windows pyname = script_helper.make_script('', TESTFN_UNENCODABLE, 'pass') self.addCleanup(unlink, pyname) + self.addCleanup(rmtree, '__pycache__') name = pyname[:-3] script_helper.assert_python_ok("-c", "mod = __import__(%a)" % name, __isolated=False)