python / cpython

The Python programming language
https://www.python.org
Other
63.13k stars 30.22k forks source link

unittest.TestCase.subTest causes all subsequent tests to be skipped in failfast mode #67083

Closed 0c7c4ccc-8b0f-427f-9557-16a861df6269 closed 9 years ago

0c7c4ccc-8b0f-427f-9557-16a861df6269 commented 9 years ago
BPO 22894
Nosy @pitrou, @rbtcollins, @ezio-melotti, @voidspace, @ethanfurman
Files
  • utbug.py: A python script demonstrating the bug
  • subtests_failfast.patch
  • Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.

    Show more details

    GitHub fields: ```python assignee = None closed_at = created_at = labels = ['type-bug', 'tests'] title = 'unittest.TestCase.subTest causes all subsequent tests to be skipped in failfast mode' updated_at = user = 'https://bugs.python.org/TreyCucco' ``` bugs.python.org fields: ```python activity = actor = 'pitrou' assignee = 'none' closed = True closed_date = closer = 'pitrou' components = ['Tests'] creation = creator = 'Trey.Cucco' dependencies = [] files = ['37218', '37238'] hgrepos = [] issue_num = 22894 keywords = ['patch'] message_count = 4.0 messages = ['231305', '231449', '231468', '231562'] nosy_count = 7.0 nosy_names = ['pitrou', 'rbcollins', 'ezio.melotti', 'michael.foord', 'ethan.furman', 'python-dev', 'Trey.Cucco'] pr_nums = [] priority = 'normal' resolution = 'fixed' stage = 'resolved' status = 'closed' superseder = None type = 'behavior' url = 'https://bugs.python.org/issue22894' versions = ['Python 3.4', 'Python 3.5'] ```

    0c7c4ccc-8b0f-427f-9557-16a861df6269 commented 9 years ago

    When running a test suite with the -f flag (--failfast), unittest seems to stop running tests once it exits a with self.subTest block.

    In the attached script, run it without -f and test_b will run and fail. Run it with the -f flag and only the test_a test will run. test_b will not run and no errors will be reported.

    I noticed this bug in 3.4.1 on OS X

    pitrou commented 9 years ago

    Here is a patch.

    voidspace commented 9 years ago

    Looks good, thanks for the quick response.

    1762cc99-3127-4a62-9baf-30c3d0f51ef7 commented 9 years ago

    New changeset 993e8f795194 by Antoine Pitrou in branch '3.4': Issue bpo-22894: TestCase.subTest() would cause the test suite to be stopped when in failfast mode, even in the absence of failures. https://hg.python.org/cpython/rev/993e8f795194

    New changeset 04103cece49d by Antoine Pitrou in branch 'default': Issue bpo-22894: TestCase.subTest() would cause the test suite to be stopped when in failfast mode, even in the absence of failures. https://hg.python.org/cpython/rev/04103cece49d