bpo-33718: regrtest: use "xxx then yyy" result if re-run (GH-7521) · python/cpython@c45fc76 (original) (raw)

`@@ -390,6 +390,7 @@ def parse_executed_tests(self, output):

`

390

390

``

391

391

`def check_executed_tests(self, output, tests, skipped=(), failed=(),

`

392

392

`env_changed=(), omitted=(),

`

``

393

`+

rerun=(),

`

393

394

`randomize=False, interrupted=False,

`

394

395

`fail_env_changed=False):

`

395

396

`if isinstance(tests, str):

`

`@@ -402,6 +403,8 @@ def check_executed_tests(self, output, tests, skipped=(), failed=(),

`

402

403

`env_changed = [env_changed]

`

403

404

`if isinstance(omitted, str):

`

404

405

`omitted = [omitted]

`

``

406

`+

if isinstance(rerun, str):

`

``

407

`+

rerun = [rerun]

`

405

408

``

406

409

`executed = self.parse_executed_tests(output)

`

407

410

`if randomize:

`

`@@ -436,6 +439,14 @@ def list_regex(line_format, tests):

`

436

439

`regex = list_regex('%s test%s omitted', omitted)

`

437

440

`self.check_line(output, regex)

`

438

441

``

``

442

`+

if rerun:

`

``

443

`+

regex = list_regex('%s re-run test%s', rerun)

`

``

444

`+

self.check_line(output, regex)

`

``

445

`+

self.check_line(output, "Re-running failed tests in verbose mode")

`

``

446

`+

for name in rerun:

`

``

447

`+

regex = "Re-running test %r in verbose mode" % name

`

``

448

`+

self.check_line(output, regex)

`

``

449

+

439

450

`good = (len(tests) - len(skipped) - len(failed)

`

440

451

`- len(omitted) - len(env_changed))

`

441

452

`if good:

`

`@@ -447,14 +458,19 @@ def list_regex(line_format, tests):

`

447

458

`if interrupted:

`

448

459

`self.check_line(output, 'Test suite interrupted by signal SIGINT.')

`

449

460

``

``

461

`+

result = []

`

450

462

`if failed:

`

451

``

`-

result = 'FAILURE'

`

452

``

`-

elif interrupted:

`

453

``

`-

result = 'INTERRUPTED'

`

``

463

`+

result.append('FAILURE')

`

454

464

`elif fail_env_changed and env_changed:

`

455

``

`-

result = 'ENV CHANGED'

`

456

``

`-

else:

`

457

``

`-

result = 'SUCCESS'

`

``

465

`+

result.append('ENV CHANGED')

`

``

466

`+

if interrupted:

`

``

467

`+

result.append('INTERRUPTED')

`

``

468

`+

if not result:

`

``

469

`+

result.append('SUCCESS')

`

``

470

`+

result = ', '.join(result)

`

``

471

`+

if rerun:

`

``

472

`+

self.check_line(output, 'Tests result: %s' % result)

`

``

473

`+

result = 'FAILURE then %s' % result

`

458

474

`self.check_line(output, 'Tests result: %s' % result)

`

459

475

``

460

476

`def parse_random_seed(self, output):

`

`@@ -948,6 +964,21 @@ def test_env_changed(self):

`

948

964

`self.check_executed_tests(output, [testname], env_changed=testname,

`

949

965

`fail_env_changed=True)

`

950

966

``

``

967

`+

def test_rerun_fail(self):

`

``

968

`+

code = textwrap.dedent("""

`

``

969

`+

import unittest

`

``

970

+

``

971

`+

class Tests(unittest.TestCase):

`

``

972

`+

def test_bug(self):

`

``

973

`+

test always fail

`

``

974

`+

self.fail("bug")

`

``

975

`+

""")

`

``

976

`+

testname = self.create_test(code=code)

`

``

977

+

``

978

`+

output = self.run_tests("-w", testname, exitcode=2)

`

``

979

`+

self.check_executed_tests(output, [testname],

`

``

980

`+

failed=testname, rerun=testname)

`

``

981

+

951

982

``

952

983

`if name == 'main':

`

953

984

`unittest.main()

`