Skip to content

Commit c6f282f

Browse files
authored
bpo-40275: Use new test.support helper submodules in tests (GH-21785)
1 parent d94af3f commit c6f282f

File tree

4 files changed

+17
-16
lines changed

4 files changed

+17
-16
lines changed

‎Lib/test/libregrtest/save_env.py‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ def get_urllib_requests__url_tempfiles(self):
7777
return list(urllib.request._url_tempfiles)
7878
def restore_urllib_requests__url_tempfiles(self, tempfiles):
7979
for filename in tempfiles:
80-
support.unlink(filename)
80+
os_helper.unlink(filename)
8181

8282
def get_urllib_requests__opener(self):
8383
return urllib.request._opener
@@ -245,9 +245,9 @@ def restore_files(self, saved_value):
245245
fn = os_helper.TESTFN
246246
if fn not in saved_value and (fn + '/') not in saved_value:
247247
if os.path.isfile(fn):
248-
support.unlink(fn)
248+
os_helper.unlink(fn)
249249
elif os.path.isdir(fn):
250-
support.rmtree(fn)
250+
os_helper.rmtree(fn)
251251

252252
_lc = [getattr(locale, lc) for lc in dir(locale)
253253
if lc.startswith('LC_')]

‎Lib/test/test__osx_support.py‎

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
import unittest
1010

1111
import test.support
12+
from test.support import os_helper
1213

1314
import _osx_support
1415

@@ -39,9 +40,9 @@ def test__find_executable(self):
3940
if self.env['PATH']:
4041
self.env['PATH'] = self.env['PATH'] + ':'
4142
self.env['PATH'] = self.env['PATH'] + os.path.abspath(self.temp_path_dir)
42-
test.support.unlink(self.prog_name)
43+
os_helper.unlink(self.prog_name)
4344
self.assertIsNone(_osx_support._find_executable(self.prog_name))
44-
self.addCleanup(test.support.unlink, self.prog_name)
45+
self.addCleanup(os_helper.unlink, self.prog_name)
4546
with open(self.prog_name, 'w') as f:
4647
f.write("#!/bin/sh\n/bin/echo OK\n")
4748
os.chmod(self.prog_name, stat.S_IRWXU)
@@ -52,8 +53,8 @@ def test__read_output(self):
5253
if self.env['PATH']:
5354
self.env['PATH'] = self.env['PATH'] + ':'
5455
self.env['PATH'] = self.env['PATH'] + os.path.abspath(self.temp_path_dir)
55-
test.support.unlink(self.prog_name)
56-
self.addCleanup(test.support.unlink, self.prog_name)
56+
os_helper.unlink(self.prog_name)
57+
self.addCleanup(os_helper.unlink, self.prog_name)
5758
with open(self.prog_name, 'w') as f:
5859
f.write("#!/bin/sh\n/bin/echo ExpectedOutput\n")
5960
os.chmod(self.prog_name, stat.S_IRWXU)
@@ -143,8 +144,8 @@ def test__find_appropriate_compiler(self):
143144
suffix = (':' + self.env['PATH']) if self.env['PATH'] else ''
144145
self.env['PATH'] = os.path.abspath(self.temp_path_dir) + suffix
145146
for c_name, c_output in compilers:
146-
test.support.unlink(c_name)
147-
self.addCleanup(test.support.unlink, c_name)
147+
os_helper.unlink(c_name)
148+
self.addCleanup(os_helper.unlink, c_name)
148149
with open(c_name, 'w') as f:
149150
f.write("#!/bin/sh\n/bin/echo " + c_output)
150151
os.chmod(c_name, stat.S_IRWXU)
@@ -221,8 +222,8 @@ def test__remove_unsupported_archs(self):
221222
suffix = (':' + self.env['PATH']) if self.env['PATH'] else ''
222223
self.env['PATH'] = os.path.abspath(self.temp_path_dir) + suffix
223224
c_name = 'clang'
224-
test.support.unlink(c_name)
225-
self.addCleanup(test.support.unlink, c_name)
225+
os_helper.unlink(c_name)
226+
self.addCleanup(os_helper.unlink, c_name)
226227
# exit status 255 means no PPC support in this compiler chain
227228
with open(c_name, 'w') as f:
228229
f.write("#!/bin/sh\nexit 255")

‎Lib/test/test_dbm_ndbm.py‎

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
from test import support
21
from test.support import import_helper
32
from test.support import os_helper
43
import_helper.import_module("dbm.ndbm") #skip if not supported
@@ -16,7 +15,7 @@ def setUp(self):
1615

1716
def tearDown(self):
1817
for suffix in ['', '.pag', '.dir', '.db']:
19-
support.unlink(self.filename + suffix)
18+
os_helper.unlink(self.filename + suffix)
2019

2120
def test_keys(self):
2221
self.d = dbm.ndbm.open(self.filename, 'c')
@@ -108,7 +107,7 @@ def test_write_readonly_file(self):
108107
def test_nonascii_filename(self):
109108
filename = os_helper.TESTFN_NONASCII
110109
for suffix in ['', '.pag', '.dir', '.db']:
111-
self.addCleanup(support.unlink, filename + suffix)
110+
self.addCleanup(os_helper.unlink, filename + suffix)
112111
with dbm.ndbm.open(filename, 'c') as db:
113112
db[b'key'] = b'value'
114113
self.assertTrue(any(os.path.exists(filename + suffix)

‎Lib/test/test_zipfile64.py‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717

1818
from tempfile import TemporaryFile
1919

20+
from test.support import os_helper
2021
from test.support import TESTFN, requires_zlib
2122

2223
TESTFN2 = TESTFN + "2"
@@ -138,8 +139,8 @@ def testMoreThan64kFilesAppend(self):
138139
self.assertEqual(content, "%d" % (i**3 % 57))
139140

140141
def tearDown(self):
141-
support.unlink(TESTFN)
142-
support.unlink(TESTFN2)
142+
os_helper.unlink(TESTFN)
143+
os_helper.unlink(TESTFN2)
143144

144145
if __name__ == "__main__":
145146
unittest.main()

0 commit comments

Comments
 (0)