summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_regrtest.py
diff options
context:
space:
mode:
authorVictor Stinner <vstinner@redhat.com>2019-04-26 07:56:37 (GMT)
committerGitHub <noreply@github.com>2019-04-26 07:56:37 (GMT)
commit837acc1957d86ca950433f5064fd06d09b57d23b (patch)
tree9451eb77510f5ddb155354a6d8bb5d161c37c79e /Lib/test/test_regrtest.py
parent75120d2205af086140e5e4e2dc620eb19cdf9078 (diff)
downloadcpython-837acc1957d86ca950433f5064fd06d09b57d23b.zip
cpython-837acc1957d86ca950433f5064fd06d09b57d23b.tar.gz
cpython-837acc1957d86ca950433f5064fd06d09b57d23b.tar.bz2
bpo-36719: Fix regrtest re-run (GH-12964)
Properly handle a test which fail but then pass. Add test_rerun_success() unit test.
Diffstat (limited to 'Lib/test/test_regrtest.py')
-rw-r--r--Lib/test/test_regrtest.py23
1 files changed, 22 insertions, 1 deletions
diff --git a/Lib/test/test_regrtest.py b/Lib/test/test_regrtest.py
index 7ff2dde..9155522 100644
--- a/Lib/test/test_regrtest.py
+++ b/Lib/test/test_regrtest.py
@@ -484,7 +484,7 @@ class BaseTestCase(unittest.TestCase):
result.append('SUCCESS')
result = ', '.join(result)
if rerun:
- self.check_line(output, 'Tests result: %s' % result)
+ self.check_line(output, 'Tests result: FAILURE')
result = 'FAILURE then %s' % result
self.check_line(output, 'Tests result: %s' % result)
@@ -989,6 +989,7 @@ class ArgsTestCase(BaseTestCase):
fail_env_changed=True)
def test_rerun_fail(self):
+ # FAILURE then FAILURE
code = textwrap.dedent("""
import unittest
@@ -1003,6 +1004,26 @@ class ArgsTestCase(BaseTestCase):
self.check_executed_tests(output, [testname],
failed=testname, rerun=testname)
+ def test_rerun_success(self):
+ # FAILURE then SUCCESS
+ code = textwrap.dedent("""
+ import builtins
+ import unittest
+
+ class Tests(unittest.TestCase):
+ failed = False
+
+ def test_fail_once(self):
+ if not hasattr(builtins, '_test_failed'):
+ builtins._test_failed = True
+ self.fail("bug")
+ """)
+ testname = self.create_test(code=code)
+
+ output = self.run_tests("-w", testname, exitcode=0)
+ self.check_executed_tests(output, [testname],
+ rerun=testname)
+
def test_no_tests_ran(self):
code = textwrap.dedent("""
import unittest