summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_regrtest.py
diff options
context:
space:
mode:
authorHai Shi <shihai1992@gmail.com>2020-06-30 13:46:06 (GMT)
committerGitHub <noreply@github.com>2020-06-30 13:46:06 (GMT)
commit3ddc634cd5469550c0c2dc5a6051a70739995699 (patch)
tree5c4bba3b3ff821397ef129298a49f4b3f34c58a4 /Lib/test/test_regrtest.py
parent3fa4799c3f9d9de7cac30e5db3627e9e125b9ce5 (diff)
downloadcpython-3ddc634cd5469550c0c2dc5a6051a70739995699.zip
cpython-3ddc634cd5469550c0c2dc5a6051a70739995699.tar.gz
cpython-3ddc634cd5469550c0c2dc5a6051a70739995699.tar.bz2
bpo-40275: Use new test.support helper submodules in tests (GH-21219)
Diffstat (limited to 'Lib/test/test_regrtest.py')
-rw-r--r--Lib/test/test_regrtest.py35
1 files changed, 18 insertions, 17 deletions
diff --git a/Lib/test/test_regrtest.py b/Lib/test/test_regrtest.py
index 6745be6..39af0d9 100644
--- a/Lib/test/test_regrtest.py
+++ b/Lib/test/test_regrtest.py
@@ -18,6 +18,7 @@ import textwrap
import unittest
from test import libregrtest
from test import support
+from test.support import os_helper
from test.libregrtest import utils
@@ -161,12 +162,12 @@ class ParseArgsTestCase(unittest.TestCase):
self.assertEqual(ns.ignore_tests, ['pattern'])
self.checkError([opt], 'expected one argument')
- self.addCleanup(support.unlink, support.TESTFN)
- with open(support.TESTFN, "w") as fp:
+ self.addCleanup(os_helper.unlink, os_helper.TESTFN)
+ with open(os_helper.TESTFN, "w") as fp:
print('matchfile1', file=fp)
print('matchfile2', file=fp)
- filename = os.path.abspath(support.TESTFN)
+ filename = os.path.abspath(os_helper.TESTFN)
ns = libregrtest._parse_args(['-m', 'match',
'--ignorefile', filename])
self.assertEqual(ns.ignore_tests,
@@ -183,12 +184,12 @@ class ParseArgsTestCase(unittest.TestCase):
'-m', 'pattern2'])
self.assertEqual(ns.match_tests, ['pattern1', 'pattern2'])
- self.addCleanup(support.unlink, support.TESTFN)
- with open(support.TESTFN, "w") as fp:
+ self.addCleanup(os_helper.unlink, os_helper.TESTFN)
+ with open(os_helper.TESTFN, "w") as fp:
print('matchfile1', file=fp)
print('matchfile2', file=fp)
- filename = os.path.abspath(support.TESTFN)
+ filename = os.path.abspath(os_helper.TESTFN)
ns = libregrtest._parse_args(['-m', 'match',
'--matchfile', filename])
self.assertEqual(ns.match_tests,
@@ -237,7 +238,7 @@ class ParseArgsTestCase(unittest.TestCase):
def test_testdir(self):
ns = libregrtest._parse_args(['--testdir', 'foo'])
- self.assertEqual(ns.testdir, os.path.join(support.SAVEDCWD, 'foo'))
+ self.assertEqual(ns.testdir, os.path.join(os_helper.SAVEDCWD, 'foo'))
self.checkError(['--testdir'], 'expected one argument')
def test_runleaks(self):
@@ -284,7 +285,7 @@ class ParseArgsTestCase(unittest.TestCase):
with self.subTest(opt=opt):
ns = libregrtest._parse_args([opt, 'foo'])
self.assertEqual(ns.coverdir,
- os.path.join(support.SAVEDCWD, 'foo'))
+ os.path.join(os_helper.SAVEDCWD, 'foo'))
self.checkError([opt], 'expected one argument')
def test_nocoverdir(self):
@@ -363,7 +364,7 @@ class BaseTestCase(unittest.TestCase):
self.testdir = os.path.realpath(os.path.dirname(__file__))
self.tmptestdir = tempfile.mkdtemp()
- self.addCleanup(support.rmtree, self.tmptestdir)
+ self.addCleanup(os_helper.rmtree, self.tmptestdir)
def create_test(self, name=None, code=None):
if not name:
@@ -384,7 +385,7 @@ class BaseTestCase(unittest.TestCase):
name = self.TESTNAME_PREFIX + name
path = os.path.join(self.tmptestdir, name + '.py')
- self.addCleanup(support.unlink, path)
+ self.addCleanup(os_helper.unlink, path)
# Use 'x' mode to ensure that we do not override existing tests
try:
with open(path, 'x', encoding='utf-8') as fp:
@@ -770,8 +771,8 @@ class ArgsTestCase(BaseTestCase):
# Write the list of files using a format similar to regrtest output:
# [1/2] test_1
# [2/2] test_2
- filename = support.TESTFN
- self.addCleanup(support.unlink, filename)
+ filename = os_helper.TESTFN
+ self.addCleanup(os_helper.unlink, filename)
# test format '0:00:00 [2/7] test_opcodes -- test_grammar took 0 sec'
with open(filename, "w") as fp:
@@ -886,7 +887,7 @@ class ArgsTestCase(BaseTestCase):
test = self.create_test('huntrleaks', code=code)
filename = 'reflog.txt'
- self.addCleanup(support.unlink, filename)
+ self.addCleanup(os_helper.unlink, filename)
output = self.run_tests('--huntrleaks', '3:3:', test,
exitcode=2,
stderr=subprocess.STDOUT)
@@ -997,8 +998,8 @@ class ArgsTestCase(BaseTestCase):
testname = self.create_test(code=code)
# only run a subset
- filename = support.TESTFN
- self.addCleanup(support.unlink, filename)
+ filename = os_helper.TESTFN
+ self.addCleanup(os_helper.unlink, filename)
subset = [
# only ignore the method name
@@ -1038,8 +1039,8 @@ class ArgsTestCase(BaseTestCase):
self.assertEqual(methods, all_methods)
# only run a subset
- filename = support.TESTFN
- self.addCleanup(support.unlink, filename)
+ filename = os_helper.TESTFN
+ self.addCleanup(os_helper.unlink, filename)
subset = [
# only match the method name