Skip to content

Commit de63e6e

Browse files
[3.13] gh-155731: Clean up files left by test_import (GH-155735) (GH-155741)
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 412feb8 commit de63e6e

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
@@ -506,6 +506,7 @@ def test_with_extension(ext):
506506
forget(TESTFN)
507507
unlink(source)
508508
unlink(pyc)
509+
rmtree('__pycache__')
509510

510511
sys.path.insert(0, os.curdir)
511512
try:
@@ -685,6 +686,7 @@ def __del__(self):
685686
import importlib
686687
sys.argv.insert(0, C())
687688
"""))
689+
self.addCleanup(unlink, testfn)
688690
script_helper.assert_python_ok(testfn)
689691

690692
@skip_if_dont_write_bytecode
@@ -2082,6 +2084,7 @@ def test_unencodable_filename(self):
20822084
# encode filenames, especially on Windows
20832085
pyname = script_helper.make_script('', TESTFN_UNENCODABLE, 'pass')
20842086
self.addCleanup(unlink, pyname)
2087+
self.addCleanup(rmtree, '__pycache__')
20852088
name = pyname[:-3]
20862089
script_helper.assert_python_ok("-c", "mod = __import__(%a)" % name,
20872090
__isolated=False)

0 commit comments

Comments
 (0)