[Python-checkins] cpython: Issue #25220: Add test for --wait in test_regrtest

victor.stinner python-checkins at python.org
Tue Sep 29 14:19:11 CEST 2015


https://hg.python.org/cpython/rev/e5165dcae942
changeset: 98384:e5165dcae942
user: Victor Stinner <victor.stinner at gmail.com>
date: Tue Sep 29 14:17:09 2015 +0200
summary:
 Issue #25220: Add test for --wait in test_regrtest
Replace script_helper.assert_python_ok() with subprocess.run().
files:
 Lib/test/test_regrtest.py | 48 ++++++++++++++++++++------
 1 files changed, 36 insertions(+), 12 deletions(-)
diff --git a/Lib/test/test_regrtest.py b/Lib/test/test_regrtest.py
--- a/Lib/test/test_regrtest.py
+++ b/Lib/test/test_regrtest.py
@@ -16,7 +16,6 @@
 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 @@
 self.assertTrue(0 <= randseed <= 10000000, randseed)
 return randseed
 
+ def run_command(self, args, input=None):
+ if not input:
+ input = ''
+ try:
+ return subprocess.run(args,
+ check=True, universal_newlines=True,
+ input=input,
+ stdout=subprocess.PIPE,
+ stderr=subprocess.PIPE)
+ except subprocess.CalledProcessError as exc:
+ self.fail("%s\n"
+ "\n"
+ "stdout:\n"
+ "%s\n"
+ "\n"
+ "stderr:\n"
+ "%s"
+ % (str(exc), exc.stdout, exc.stderr))
+
+
+ def run_python(self, args, **kw):
+ args = [sys.executable, '-X', 'faulthandler', '-I', *args]
+ proc = self.run_command(args, **kw)
+ return proc.stdout
+
 
 class ProgramsTestCase(BaseTestCase):
 """
@@ -391,9 +415,8 @@
 self.check_executed_tests(output, self.tests)
 
 def run_tests(self, args):
- res = script_helper.assert_python_ok(*args)
- output = os.fsdecode(res.out)
- self.check_output(output)
+ stdout = self.run_python(args)
+ self.check_output(stdout)
 
 def test_script_regrtest(self):
 # Lib/test/regrtest.py
@@ -439,10 +462,7 @@
 self.run_tests([script, *self.tests])
 
 def run_batch(self, *args):
- proc = subprocess.run(args,
- check=True, universal_newlines=True,
- input='',
- stdout=subprocess.PIPE, stderr=subprocess.PIPE)
+ proc = self.run_command(args)
 self.check_output(proc.stdout)
 
 @unittest.skipUnless(sys.platform == 'win32', 'Windows only')
@@ -473,10 +493,8 @@
 Test arguments of the Python test suite.
 """
 
- def run_tests(self, *args):
- args = ['-m', 'test', *args]
- res = script_helper.assert_python_ok(*args)
- return os.fsdecode(res.out)
+ def run_tests(self, *args, input=None):
+ return self.run_python(['-m', 'test', *args], input=input)
 
 def test_resources(self):
 # test -u command line option
@@ -561,6 +579,12 @@
 '(?: *[0-9]+ *[0-9]{1,2}% *[^ ]+ +\([^)]+\)+)+')
 self.check_line(output, regex)
 
+ def test_wait(self):
+ # test --wait
+ test = self.create_test()
+ output = self.run_tests("--wait", test, input='key')
+ self.check_line(output, 'Press any key to continue')
+
 
 if __name__ == '__main__':
 unittest.main()
-- 
Repository URL: https://hg.python.org/cpython


More information about the Python-checkins mailing list

AltStyle によって変換されたページ (->オリジナル) /