Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

3.4 regression: unittest.expectedFailure no longer works on TestCase subclasses #65311

Closed
wkschwartz mannequin opened this issue Mar 31, 2014 · 16 comments
Closed

3.4 regression: unittest.expectedFailure no longer works on TestCase subclasses #65311

wkschwartz mannequin opened this issue Mar 31, 2014 · 16 comments
Assignees
Labels
stdlib Python modules in the Lib dir tests Tests in the Lib/test dir type-bug An unexpected behavior, bug, or error

Comments

@wkschwartz
Copy link
Mannequin

wkschwartz mannequin commented Mar 31, 2014

BPO 21112
Nosy @pitrou, @larryhastings, @rbtcollins, @ned-deily, @ezio-melotti, @voidspace, @berkerpeksag, @wkschwartz
Files
  • test_expectedFailure.py: Test case for unittest.expecteFailure regression
  • issue21112.diff
  • 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:

    assignee = 'https://github.com/berkerpeksag'
    closed_at = <Date 2015-08-27.22:38:35.450>
    created_at = <Date 2014-03-31.14:20:26.695>
    labels = ['tests', 'type-bug', 'library']
    title = '3.4 regression: unittest.expectedFailure no longer works on TestCase subclasses'
    updated_at = <Date 2015-08-27.22:38:35.449>
    user = 'https://github.com/wkschwartz'

    bugs.python.org fields:

    activity = <Date 2015-08-27.22:38:35.449>
    actor = 'rbcollins'
    assignee = 'berker.peksag'
    closed = True
    closed_date = <Date 2015-08-27.22:38:35.450>
    closer = 'rbcollins'
    components = ['Library (Lib)', 'Tests']
    creation = <Date 2014-03-31.14:20:26.695>
    creator = 'William.Schwartz'
    dependencies = []
    files = ['34680', '34681']
    hgrepos = []
    issue_num = 21112
    keywords = ['patch', '3.4regression']
    message_count = 16.0
    messages = ['215240', '218491', '218492', '218683', '218727', '218731', '226552', '226553', '226562', '229543', '229545', '229589', '238091', '238168', '249266', '249267']
    nosy_count = 9.0
    nosy_names = ['pitrou', 'larry', 'rbcollins', 'ned.deily', 'ezio.melotti', 'michael.foord', 'python-dev', 'berker.peksag', 'William.Schwartz']
    pr_nums = []
    priority = 'normal'
    resolution = 'fixed'
    stage = 'resolved'
    status = 'closed'
    superseder = None
    type = 'behavior'
    url = 'https://bugs.python.org/issue21112'
    versions = ['Python 3.4', 'Python 3.5']

    @wkschwartz
    Copy link
    Mannequin Author

    wkschwartz mannequin commented Mar 31, 2014

    In Python 2.7 and 3.3, decorating a unittest.TestCase subclass with unittest.expectedFailure caused test discover to skip the decorated test case. Python 3.4 apparently ignores the decorator when applied to classes.

    The attached file when run with Python 2.7.6 on Mac OS X produces the following output

    $ python -m unittest discover
    F.

    ======================================================================
    FAIL: test_fails (test.TestControl)
    ----------------------------------------------------------------------

    Traceback (most recent call last):
      File "/Users/schwartz_w/Documents/testtest/test.py", line 9, in test_fails
        self.assertFalse(True)
    AssertionError: True is not false

    Ran 2 tests in 0.000s

    FAILED (failures=1)

    When run with Python 3.4.0 produces the following output.

    ~/Documents/testtest $ python3 -m unittest discover
    F.F.
    ======================================================================
    FAIL: test_fails (test.TestControl)
    ----------------------------------------------------------------------

    Traceback (most recent call last):
      File "/Users/schwartz_w/Documents/testtest/test.py", line 9, in test_fails
        self.assertFalse(True)
    AssertionError: True is not false

    ======================================================================
    FAIL: test_fails (test.TestTreatment)
    ----------------------------------------------------------------------

    Traceback (most recent call last):
      File "/Users/schwartz_w/Documents/testtest/test.py", line 9, in test_fails
        self.assertFalse(True)
    AssertionError: True is not false

    Ran 4 tests in 0.001s

    FAILED (failures=2)

    The expectedFailure decorator when applied to a class should either skip the class or run all of its tests and check that they failed for consistency with how expectedFailure applies to test methods.

    @wkschwartz wkschwartz mannequin added stdlib Python modules in the Lib dir type-bug An unexpected behavior, bug, or error labels Mar 31, 2014
    @ezio-melotti ezio-melotti added the tests Tests in the Lib/test dir label Mar 31, 2014
    @berkerpeksag
    Copy link
    Member

    Is there a chance to get this into 3.4.1?

    @ned-deily
    Copy link
    Member

    Berker, if you think it should go into 3.4.1, you need to set the priority to "release blocker" to bring it to the attention of the release manager.

    @larryhastings
    Copy link
    Contributor

    Berker: do you consider your diff ready to go in, or is it an "early" diff (like a work-in-progress)?

    @berkerpeksag
    Copy link
    Member

    Berker: do you consider your diff ready to go in, or is it an "early"
    diff (like a work-in-progress)?

    I tested my patch with test_expectedFailure.py again. The patch is not really fixes the problem described in msg215240. So, I consider it a WIP patch for now. Sorry for the noise.

    Here is the output on Python 3.3:

    $ python3.3 -m unittest discover -v
    test_fails (test_expectedFailure.TestControl) ... FAIL
    test_passes (test_expectedFailure.TestControl) ... ok

    ======================================================================
    FAIL: test_fails (test_expectedFailure.TestControl)
    ----------------------------------------------------------------------

    Traceback (most recent call last):
      File "/home/berker/projects/cpython-default/playground/test_expectedFailure.py", line 9, in test_fails
        self.assertFalse(True)
    AssertionError: True is not false

    Ran 2 tests in 0.001s

    FAILED (failures=1)

    And here is the output on Python 3.5 (with bpo-21112.diff patch):

    $ ./../python -m unittest discover -v
    test_fails (test_expectedFailure.TestControl) ... FAIL
    test_passes (test_expectedFailure.TestControl) ... ok
    test_fails (test_expectedFailure.TestTreatment) ... expected failure
    test_passes (test_expectedFailure.TestTreatment) ... unexpected success

    ======================================================================
    FAIL: test_fails (test_expectedFailure.TestControl)
    ----------------------------------------------------------------------

    Traceback (most recent call last):
      File "/home/berker/projects/cpython-default/playground/test_expectedFailure.py", line 9, in test_fails
        self.assertFalse(True)
    AssertionError: True is not false

    Ran 4 tests in 0.002s

    FAILED (failures=1, expected failures=1, unexpected successes=1)

    @larryhastings
    Copy link
    Contributor

    Considering that I'm tagging 3.4.1 within an hour or two, and we don't have a patch yet, I'd say that this is too late to go into 3.4.1. But I'm happy to consider it for a future 3.4.x revision.

    @ned-deily
    Copy link
    Member

    Should this be fixed for 3.4.2?

    @larryhastings
    Copy link
    Contributor

    Note: current plan for 3.4.2 is to release at the end of the month. RC1 will be in about a week.

    @voidspace
    Copy link
    Contributor

    The patch looks good to me.

    @wkschwartz
    Copy link
    Mannequin Author

    wkschwartz mannequin commented Oct 16, 2014

    3.4.2 has been released, it seems, without this getting fixed.

    3.4.3 then? Are we still happy with the patch?

    @berkerpeksag
    Copy link
    Member

    3.4.3 then? Are we still happy with the patch?

    Please see msg218727. The patch is not ready yet.

    @pitrou
    Copy link
    Member

    pitrou commented Oct 17, 2014

    Berker, it looks like the 3.3 behaviour was buggy: TestTreatment isn't run at all! Instead, it should be run and consider failures as success.

    So your patch appears more correct than what 3.3 did.

    @wkschwartz
    Copy link
    Mannequin Author

    wkschwartz mannequin commented Mar 14, 2015

    3.4.3 has been released, it seems, without this getting fixed.

    3.4.4 then?

    --
    William Schwartz

    On Mon, Sep 8, 2014 at 3:42 AM, Michael Foord <report@bugs.python.org>
    wrote:

    Michael Foord added the comment:

    The patch looks good to me.

    ----------


    Python tracker <report@bugs.python.org>
    <http://bugs.python.org/issue21112\>


    @rbtcollins
    Copy link
    Member

    Test looks good to me. Do you want to apply it?

    @berkerpeksag berkerpeksag self-assigned this Mar 16, 2015
    @python-dev
    Copy link
    Mannequin

    python-dev mannequin commented Aug 27, 2015

    New changeset a90c6d608b85 by Robert Collins in branch '3.4':
    Issue bpo-21112: Fix regression in unittest.expectedFailure on subclasses.
    https://hg.python.org/cpython/rev/a90c6d608b85

    New changeset ac3f1a6b1de2 by Robert Collins in branch '3.5':
    Issue bpo-21112: Fix regression in unittest.expectedFailure on subclasses.
    https://hg.python.org/cpython/rev/ac3f1a6b1de2

    New changeset bf789ae9bde7 by Robert Collins in branch 'default':
    Issue bpo-21112: Fix regression in unittest.expectedFailure on subclasses.
    https://hg.python.org/cpython/rev/bf789ae9bde7

    @rbtcollins
    Copy link
    Member

    2.7 is sufficiently different that I haven't backported this there - plus the report said it was introduced in 3.4. If someone can show this doesn't work in 2.7 and also supply a patch, we could apply it there.

    @ezio-melotti ezio-melotti transferred this issue from another repository Apr 10, 2022
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
    Labels
    stdlib Python modules in the Lib dir tests Tests in the Lib/test dir type-bug An unexpected behavior, bug, or error
    Projects
    None yet
    Development

    No branches or pull requests

    7 participants