[Python-checkins] bpo-33718: regrtest: use "xxx then yyy" result if re-run (GH-7521)
Miss Islington (bot)
webhook-mailer at python.org
Sat Jun 9 12:35:40 EDT 2018
https://github.com/python/cpython/commit/07aea160ca2dd8814a28afe73e6a72c2b3cbf38a
commit: 07aea160ca2dd8814a28afe73e6a72c2b3cbf38a
branch: 3.6
author: Miss Islington (bot) <31488909+miss-islington at users.noreply.github.com>
committer: GitHub <noreply at github.com>
date: 2018-06-09T09:35:37-07:00
summary:
bpo-33718: regrtest: use "xxx then yyy" result if re-run (GH-7521)
If tests are re-run, use "xxx then yyy" result format (ex: "FAILURE
then SUCCESS") to show that some failing tests have been re-run.
Add also test_regrtest.test_rerun_fail() test.
(cherry picked from commit c45fc7673e23f911639d10d3771ffef7be870c7a)
Co-authored-by: Victor Stinner <vstinner at redhat.com>
files:
M Lib/test/libregrtest/main.py
M Lib/test/test_regrtest.py
diff --git a/Lib/test/libregrtest/main.py b/Lib/test/libregrtest/main.py
index 6a818cdd2cf1..3429b3726abe 100644
--- a/Lib/test/libregrtest/main.py
+++ b/Lib/test/libregrtest/main.py
@@ -79,6 +79,7 @@ def __init__(self):
self.resource_denieds = []
self.environment_changed = []
self.rerun = []
+ self.first_result = None
self.interrupted = False
# used by --slow
@@ -273,6 +274,8 @@ def rerun_failed_tests(self):
self.ns.failfast = False
self.ns.verbose3 = False
+ self.first_result = self.get_tests_result()
+
print()
print("Re-running failed tests in verbose mode")
self.rerun = self.bad[:]
@@ -447,7 +450,10 @@ def get_tests_result(self):
if not result:
result.append("SUCCESS")
- return ', '.join(result)
+ result = ', '.join(result)
+ if self.first_result:
+ result = '%s then %s' % (self.first_result, result)
+ return result
def run_tests(self):
# For a partial run, we do not need to clutter the output.
diff --git a/Lib/test/test_regrtest.py b/Lib/test/test_regrtest.py
index f6d2f3647b94..e2b52283cd11 100644
--- a/Lib/test/test_regrtest.py
+++ b/Lib/test/test_regrtest.py
@@ -389,6 +389,7 @@ def parse_executed_tests(self, output):
def check_executed_tests(self, output, tests, skipped=(), failed=(),
env_changed=(), omitted=(),
+ rerun=(),
randomize=False, interrupted=False,
fail_env_changed=False):
if isinstance(tests, str):
@@ -401,6 +402,8 @@ def check_executed_tests(self, output, tests, skipped=(), failed=(),
env_changed = [env_changed]
if isinstance(omitted, str):
omitted = [omitted]
+ if isinstance(rerun, str):
+ rerun = [rerun]
executed = self.parse_executed_tests(output)
if randomize:
@@ -435,6 +438,14 @@ def list_regex(line_format, tests):
regex = list_regex('%s test%s omitted', omitted)
self.check_line(output, regex)
+ if rerun:
+ regex = list_regex('%s re-run test%s', rerun)
+ self.check_line(output, regex)
+ self.check_line(output, "Re-running failed tests in verbose mode")
+ for name in rerun:
+ regex = "Re-running test %r in verbose mode" % name
+ self.check_line(output, regex)
+
good = (len(tests) - len(skipped) - len(failed)
- len(omitted) - len(env_changed))
if good:
@@ -446,14 +457,19 @@ def list_regex(line_format, tests):
if interrupted:
self.check_line(output, 'Test suite interrupted by signal SIGINT.')
+ result = []
if failed:
- result = 'FAILURE'
- elif interrupted:
- result = 'INTERRUPTED'
+ result.append('FAILURE')
elif fail_env_changed and env_changed:
- result = 'ENV CHANGED'
- else:
- result = 'SUCCESS'
+ result.append('ENV CHANGED')
+ if interrupted:
+ result.append('INTERRUPTED')
+ if not result:
+ result.append('SUCCESS')
+ result = ', '.join(result)
+ if rerun:
+ self.check_line(output, 'Tests result: %s' % result)
+ result = 'FAILURE then %s' % result
self.check_line(output, 'Tests result: %s' % result)
def parse_random_seed(self, output):
@@ -952,6 +968,21 @@ def test_env_changed(self):
self.check_executed_tests(output, [testname], env_changed=testname,
fail_env_changed=True)
+ def test_rerun_fail(self):
+ code = textwrap.dedent("""
+ import unittest
+
+ class Tests(unittest.TestCase):
+ def test_bug(self):
+ # test always fail
+ self.fail("bug")
+ """)
+ testname = self.create_test(code=code)
+
+ output = self.run_tests("-w", testname, exitcode=2)
+ self.check_executed_tests(output, [testname],
+ failed=testname, rerun=testname)
+
if __name__ == '__main__':
unittest.main()
More information about the Python-checkins
mailing list