-
-
Notifications
You must be signed in to change notification settings - Fork 2.8k
unittest: cleanup unexpected success handling #8231
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
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would be great to get this fixed!
I left a couple of comments/questions.
Also, should add a bugfix changelog entry for this, some users would probably be affected by it.
is that a bugfix or feature ? |
abfa4f3
to
0480b5c
Compare
@bluetech - please have a look. The original behavior is preserved this time. Example: import pytest
import unittest
from twisted.trial import unittest as tw_unittest
class ExpectedFailureTestCase(unittest.TestCase):
@unittest.expectedFailure
def test_expected_failure(self):
self.assertTrue(False)
@unittest.expectedFailure
def test_unexpected_success(self):
self.assertTrue(True)
class ExpectedFailureTwistedTestCase(tw_unittest.TestCase):
todo = "not ready"
def test_expected_failure(self):
self.assertTrue(False)
def test_unexpected_success(self):
self.assertTrue(True)
class TestPytestExpectedFailure:
@pytest.mark.xfail(reason="not ready")
def test_expected_failure(self):
assert False
@pytest.mark.xfail(reason="not ready")
def test_unexpected_success(self):
assert True Running with
Running with
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, thanks! Ended up as a nice clean up at least.
Great work @antonblr! Sorry for joining late, but seems we missed a CHANGELOG entry. Seems like an |
Hi @nicoddemus - what do you think should be outlined in CHANGELOG? The only thing I think might worth to outline is the change to outcome message for unittest twisted todo - it was representation of the |
Ahh I misunderstood then, I thought we had change how Even so a |
Closes #7393
EDIT: we're preserving the original behavior - unexpected success in
@unittest.expectedFailure
should haveFAILED
outcome. See discussion in #7393Learning pytest internals more and decided to give it a shot. Let me know if there is a better, pytest way of implementing that.Behaviour chages:unuttest unexpected success isXPASS
(exit 0) when not strict (was:FAIL
, exit: 1)twisted trial unexpected success isXPASS
(exit 0) when not strict (was:FAIL
, exit: 1)