Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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>
  • Loading branch information
serhiy-storchaka authored and miss-islington committed Aug 13, 2026
commit 9c6c125e6c547a32b1247512778edf6f35f340c1
3 changes: 3 additions & 0 deletions Lib/test/test_import/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -490,6 +490,7 @@ def test_with_extension(ext):
forget(TESTFN)
unlink(source)
unlink(pyc)
rmtree('__pycache__')

sys.path.insert(0, os.curdir)
try:
Expand Down Expand Up @@ -668,6 +669,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
Expand Down Expand Up @@ -2033,6 +2035,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)
Expand Down
Loading