Skip to content

Commit 3621e7d

Browse files
serhiy-storchakamiss-islington
authored andcommitted
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. (cherry picked from commit b0ba60e) Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
1 parent 65fa1a0 commit 3621e7d

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
@@ -487,6 +487,7 @@ def test_with_extension(ext):
487487
forget(TESTFN)
488488
unlink(source)
489489
unlink(pyc)
490+
rmtree('__pycache__')
490491

491492
sys.path.insert(0, os.curdir)
492493
try:
@@ -666,6 +667,7 @@ def __del__(self):
666667
import importlib
667668
sys.argv.insert(0, C())
668669
"""))
670+
self.addCleanup(unlink, testfn)
669671
script_helper.assert_python_ok(testfn)
670672

671673
@skip_if_dont_write_bytecode
@@ -2063,6 +2065,7 @@ def test_unencodable_filename(self):
20632065
# encode filenames, especially on Windows
20642066
pyname = script_helper.make_script('', TESTFN_UNENCODABLE, 'pass')
20652067
self.addCleanup(unlink, pyname)
2068+
self.addCleanup(rmtree, '__pycache__')
20662069
name = pyname[:-3]
20672070
script_helper.assert_python_ok("-c", "mod = __import__(%a)" % name,
20682071
__isolated=False)

0 commit comments

Comments
 (0)