cpython: e5165dcae942 (original) (raw)
--- a/Lib/test/test_regrtest.py +++ b/Lib/test/test_regrtest.py @@ -16,7 +16,6 @@ import textwrap import unittest from test import libregrtest from test import support -from test.support import script_helper Py_DEBUG = hasattr(sys, 'getobjects') @@ -366,6 +365,31 @@ class BaseTestCase(unittest.TestCase): self.assertTrue(0 <= randseed <= 10000000, randseed) return randseed
- def run_command(self, args, input=None):
if not input:[](#l1.16)
input = ''[](#l1.17)
try:[](#l1.18)
return subprocess.run(args,[](#l1.19)
check=True, universal_newlines=True,[](#l1.20)
input=input,[](#l1.21)
stdout=subprocess.PIPE,[](#l1.22)
stderr=subprocess.PIPE)[](#l1.23)
except subprocess.CalledProcessError as exc:[](#l1.24)
self.fail("%s\n"[](#l1.25)
"\n"[](#l1.26)
"stdout:\n"[](#l1.27)
"%s\n"[](#l1.28)
"\n"[](#l1.29)
"stderr:\n"[](#l1.30)
"%s"[](#l1.31)
% (str(exc), exc.stdout, exc.stderr))[](#l1.32)
- def run_python(self, args, **kw):
args = [sys.executable, '-X', 'faulthandler', '-I', *args][](#l1.36)
proc = self.run_command(args, **kw)[](#l1.37)
return proc.stdout[](#l1.38)
+ class ProgramsTestCase(BaseTestCase): """ @@ -391,9 +415,8 @@ class ProgramsTestCase(BaseTestCase): self.check_executed_tests(output, self.tests) def run_tests(self, args):
res = script_helper.assert_python_ok(*args)[](#l1.47)
output = os.fsdecode(res.out)[](#l1.48)
self.check_output(output)[](#l1.49)
stdout = self.run_python(args)[](#l1.50)
self.check_output(stdout)[](#l1.51)
def test_script_regrtest(self): # Lib/test/regrtest.py @@ -439,10 +462,7 @@ class ProgramsTestCase(BaseTestCase): self.run_tests([script, *self.tests]) def run_batch(self, *args):
proc = subprocess.run(args,[](#l1.59)
check=True, universal_newlines=True,[](#l1.60)
input='',[](#l1.61)
stdout=subprocess.PIPE, stderr=subprocess.PIPE)[](#l1.62)
proc = self.run_command(args)[](#l1.63) self.check_output(proc.stdout)[](#l1.64)
@unittest.skipUnless(sys.platform == 'win32', 'Windows only') @@ -473,10 +493,8 @@ class ArgsTestCase(BaseTestCase): Test arguments of the Python test suite. """
- def run_tests(self, *args):
args = ['-m', 'test', *args][](#l1.72)
res = script_helper.assert_python_ok(*args)[](#l1.73)
return os.fsdecode(res.out)[](#l1.74)
- def run_tests(self, *args, input=None):
return self.run_python(['-m', 'test', *args], input=input)[](#l1.76)
def test_resources(self): # test -u command line option @@ -561,6 +579,12 @@ class ArgsTestCase(BaseTestCase): '(?: *[0-9]+ *[0-9]{1,2}% *[^ ]+ +([^)]+)+)+') self.check_line(output, regex)