Skip to content

Commit b0ba60e

Browse files
gh-155731: Clean up files left by test_import (GH-155735)
test_import() and test_unencodable_filename() left the __pycache__ directory created for a temporary module, and test_import_in_del_does_not_crash() left the script it created.
1 parent dd1194e commit b0ba60e

1 file changed

Lines changed: 3 additions & 0 deletions

File tree

Lib/test/test_import/__init__.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -490,6 +490,7 @@ def test_with_extension(ext):
490490
forget(TESTFN)
491491
unlink(source)
492492
unlink(pyc)
493+
rmtree('__pycache__')
493494

494495
sys.path.insert(0, os.curdir)
495496
try:
@@ -668,6 +669,7 @@ def __del__(self):
668669
import importlib
669670
sys.argv.insert(0, C())
670671
"""))
672+
self.addCleanup(unlink, testfn)
671673
script_helper.assert_python_ok(testfn)
672674

673675
@skip_if_dont_write_bytecode
@@ -2033,6 +2035,7 @@ def test_unencodable_filename(self):
20332035
# encode filenames, especially on Windows
20342036
pyname = script_helper.make_script('', TESTFN_UNENCODABLE, 'pass')
20352037
self.addCleanup(unlink, pyname)
2038+
self.addCleanup(rmtree, '__pycache__')
20362039
name = pyname[:-3]
20372040
script_helper.assert_python_ok("-c", "mod = __import__(%a)" % name,
20382041
__isolated=False)

0 commit comments

Comments
 (0)