Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 047b7ae

Browse files
committed
Issue #22390: Remove files created by tests
1 parent 8f437aa commit 047b7ae

7 files changed

Lines changed: 10 additions & 3 deletions

File tree

Lib/test/test_imp.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -198,6 +198,7 @@ def test_issue5604(self):
198198
support.unlink(temp_mod_name + ext)
199199
support.unlink(init_file_name + ext)
200200
support.rmtree(test_package_name)
201+
support.rmtree('__pycache__')
201202

202203
def test_issue9319(self):
203204
path = os.path.dirname(__file__)

Lib/test/test_import.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1062,6 +1062,7 @@ def test_unencodable_filename(self):
10621062
# Issue #11619: The Python parser and the import machinery must not
10631063
# encode filenames, especially on Windows
10641064
pyname = script_helper.make_script('', TESTFN_UNENCODABLE, 'pass')
1065+
self.addCleanup(unlink, pyname)
10651066
name = pyname[:-3]
10661067
script_helper.assert_python_ok("-c", "mod = __import__(%a)" % name,
10671068
__isolated=False)

Lib/test/test_pdb.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -916,6 +916,7 @@ def run_pdb(self, script, commands):
916916
with open(filename, 'w') as f:
917917
f.write(textwrap.dedent(script))
918918
self.addCleanup(support.unlink, filename)
919+
self.addCleanup(support.rmtree, '__pycache__')
919920
cmd = [sys.executable, '-m', 'pdb', filename]
920921
stdout = stderr = None
921922
with subprocess.Popen(cmd, stdout=subprocess.PIPE,

Lib/test/test_posix.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1125,7 +1125,7 @@ def test_path_error2(self):
11251125
"""
11261126
Test functions that call path_error2(), providing two filenames in their exceptions.
11271127
"""
1128-
for name in ("rename", "replace", "link", "symlink"):
1128+
for name in ("rename", "replace", "link"):
11291129
function = getattr(os, name, None)
11301130

11311131
if function:

Lib/test/test_source_encoding.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# -*- coding: koi8-r -*-
22

33
import unittest
4-
from test.support import TESTFN, unlink, unload
4+
from test.support import TESTFN, unlink, unload, rmtree
55
import importlib
66
import os
77
import sys
@@ -129,6 +129,7 @@ def test_file_parse(self):
129129
unlink(filename + "c")
130130
unlink(filename + "o")
131131
unload(TESTFN)
132+
rmtree('__pycache__')
132133

133134
def test_error_from_string(self):
134135
# See http://bugs.python.org/issue6289

Lib/test/test_support.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@ def test_forget(self):
6969
finally:
7070
del sys.path[0]
7171
support.unlink(mod_filename)
72+
support.rmtree('__pycache__')
7273

7374
def test_HOST(self):
7475
s = socket.socket()

Lib/test/test_threaded_import.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,8 @@
1313
import shutil
1414
import unittest
1515
from test.support import (
16-
verbose, import_module, run_unittest, TESTFN, reap_threads, forget, unlink)
16+
verbose, import_module, run_unittest, TESTFN, reap_threads,
17+
forget, unlink, rmtree)
1718
threading = import_module('threading')
1819

1920
def task(N, done, done_tasks, errors):
@@ -222,6 +223,7 @@ def target():
222223
f.write(code.encode('utf-8'))
223224
self.addCleanup(unlink, filename)
224225
self.addCleanup(forget, TESTFN)
226+
self.addCleanup(rmtree, '__pycache__')
225227
importlib.invalidate_caches()
226228
__import__(TESTFN)
227229

0 commit comments

Comments
 (0)