[3.14] gh-155731: Clean up files left by test_import (GH-155735) (GH-155740)

serhiy-storchaka <[email protected]>
Newsgroups gmane.comp.python.cvs
Message-ID <[email protected]>
https://github.com/python/cpython/commit/23bba2ff0759f914371a97ebb83b42fadda73d95
commit: 23bba2ff0759f914371a97ebb83b42fadda73d95
branch: 3.14
author: Miss Islington (bot) <[email protected]>
committer: serhiy-storchaka <[email protected]>
date: 2026-08-13T18:00:08Z
summary:

[3.14] gh-155731: Clean up files left by test_import (GH-155735) (GH-155740)

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 b0ba60e28906c75dd43afe49791740c62205660f)

Co-authored-by: Serhiy Storchaka <[email protected]>

files:
M Lib/test/test_import/__init__.py

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)

_______________________________________________
Python-checkins mailing list -- [email protected]
To unsubscribe send an email to [email protected]
https://mail.python.org/mailman3//lists/python-checkins.python.org
Member address: [email protected]
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.