Skip to content

Commit 2ceeea8

Browse files
authored
Merge pull request #3476 from deantvv/test-update-2
Update test for support/os_helper.py (second attempt)
2 parents 4f2d70f + 4161858 commit 2ceeea8

File tree

98 files changed

+2953
-2060
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

98 files changed

+2953
-2060
lines changed

Lib/test/libregrtest/cmdline.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
import os
33
import sys
44
from test import support
5+
from test.support import os_helper
56

67

78
USAGE = """\
@@ -280,7 +281,7 @@ def _create_parser():
280281
def relative_filename(string):
281282
# CWD is replaced with a temporary dir before calling main(), so we
282283
# join it with the saved CWD so it ends up where the user expects.
283-
return os.path.join(support.SAVEDCWD, string)
284+
return os.path.join(os_helper.SAVEDCWD, string)
284285

285286

286287
def huntrleaks(string):

Lib/test/libregrtest/main.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
from test.libregrtest.setup import setup_tests
2121
from test.libregrtest.utils import removepy, count, format_duration, printlist
2222
from test import support
23+
from test.support import os_helper
2324

2425

2526
# When tests are run from the Python build directory, it is best practice
@@ -199,7 +200,7 @@ def find_tests(self, tests):
199200
# regex to match 'test_builtin' in line:
200201
# '0:00:00 [ 4/400] test_builtin -- test_dict took 1 sec'
201202
regex = re.compile(r'\btest_[a-zA-Z0-9_]+\b')
202-
with open(os.path.join(support.SAVEDCWD, self.ns.fromfile)) as fp:
203+
with open(os.path.join(os_helper.SAVEDCWD, self.ns.fromfile)) as fp:
203204
for line in fp:
204205
line = line.split('#', 1)[0]
205206
line = line.strip()
@@ -542,7 +543,7 @@ def save_xml_result(self):
542543
for k, v in totals.items():
543544
root.set(k, str(v))
544545

545-
xmlpath = os.path.join(support.SAVEDCWD, self.ns.xmlpath)
546+
xmlpath = os.path.join(os_helper.SAVEDCWD, self.ns.xmlpath)
546547
with open(xmlpath, 'wb') as f:
547548
for s in ET.tostringlist(root):
548549
f.write(s)
@@ -568,8 +569,8 @@ def main(self, tests=None, **kwargs):
568569
# Run the tests in a context manager that temporarily changes the CWD to a
569570
# temporary and writable directory. If it's not possible to create or
570571
# change the CWD, the original CWD will be used. The original CWD is
571-
# available from support.SAVEDCWD.
572-
with support.temp_cwd(test_cwd, quiet=True):
572+
# available from os_helper.SAVEDCWD.
573+
with os_helper.temp_cwd(test_cwd, quiet=True):
573574
self._main(tests, kwargs)
574575

575576
def getloadavg(self):

Lib/test/libregrtest/refleak.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ def get_pooled_int(value):
6161
return int_pool.setdefault(value, value)
6262

6363
nwarmup, ntracked, fname = ns.huntrleaks
64-
fname = os.path.join(support.SAVEDCWD, fname)
64+
fname = os.path.join(os_helper.SAVEDCWD, fname)
6565
repcount = nwarmup + ntracked
6666

6767
# Pre-allocate to ensure that the loop doesn't allocate anything new

Lib/test/libregrtest/runtest.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
import unittest
1212

1313
from test import support
14+
from test.support import os_helper
1415
from test.libregrtest.refleak import dash_R, clear_caches
1516
from test.libregrtest.save_env import saved_test_environment
1617
from test.libregrtest.utils import print_warning
@@ -298,7 +299,7 @@ def cleanup_test_droppings(test_name, verbose):
298299
# since if a test leaves a file open, it cannot be deleted by name (while
299300
# there's nothing we can do about that here either, we can display the
300301
# name of the offending test, which is a real help).
301-
for name in (support.TESTFN,
302+
for name in (os_helper.TESTFN,
302303
"db_home",
303304
):
304305
if not os.path.exists(name):

Lib/test/libregrtest/runtest_mp.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ def run_test_in_subprocess(testname, ns):
4646
stderr=subprocess.PIPE,
4747
universal_newlines=True,
4848
close_fds=(os.name != 'nt'),
49-
cwd=support.SAVEDCWD)
49+
cwd=os_helper.SAVEDCWD)
5050

5151

5252
def run_tests_worker(worker_args):

Lib/test/libregrtest/save_env.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
import threading
1010
import warnings
1111
from test import support
12+
from test.support import os_helper
1213
from test.libregrtest.utils import print_warning
1314
try:
1415
import _multiprocessing, multiprocessing.process
@@ -228,12 +229,12 @@ def get_files(self):
228229
return sorted(fn + ('/' if os.path.isdir(fn) else '')
229230
for fn in os.listdir())
230231
def restore_files(self, saved_value):
231-
fn = support.TESTFN
232+
fn = os_helper.TESTFN
232233
if fn not in saved_value and (fn + '/') not in saved_value:
233234
if os.path.isfile(fn):
234-
support.unlink(fn)
235+
os_helper.unlink(fn)
235236
elif os.path.isdir(fn):
236-
support.rmtree(fn)
237+
os_helper.rmtree(fn)
237238

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

Lib/test/libregrtest/win_utils.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ def start(self):
5555

5656
# Spawn off the load monitor
5757
command = ['typeperf', COUNTER_NAME, '-si', str(SAMPLING_INTERVAL)]
58-
self.p = subprocess.Popen(command, stdout=command_stdout, cwd=support.SAVEDCWD)
58+
self.p = subprocess.Popen(command, stdout=command_stdout, cwd=os_helper.SAVEDCWD)
5959

6060
# Close our copy of the write end of the pipe
6161
os.close(command_stdout)

Lib/test/list_tests.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
from functools import cmp_to_key
99

1010
from test import support, seq_tests
11+
from test.support import os_helper
1112

1213

1314
class CommonTest(seq_tests.CommonTest):
@@ -73,12 +74,12 @@ def test_print(self):
7374
d.append(d)
7475
d.append(400)
7576
try:
76-
with open(support.TESTFN, "w") as fo:
77+
with open(os_helper.TESTFN, "w") as fo:
7778
fo.write(str(d))
78-
with open(support.TESTFN, "r") as fo:
79+
with open(os_helper.TESTFN, "r") as fo:
7980
self.assertEqual(fo.read(), repr(d))
8081
finally:
81-
os.remove(support.TESTFN)
82+
os.remove(os_helper.TESTFN)
8283

8384
def test_set_subscript(self):
8485
a = self.type2test(range(20))

0 commit comments

Comments
 (0)