-
-
Notifications
You must be signed in to change notification settings - Fork 2.7k
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
Unittest unexpected success should be translated to XPASS #7393
Comments
While reviewing @antonblr's PR #8231, and trying to understand the (existing) code a bit more, I looked at the history around this. Originally the skipping plugin didn't handle # we need to translate into how py.test encodes xpass
rep.keywords['xfail'] = "reason: " + item._unexpectedsuccess
rep.outcome = "failed" i.e. basically a straight FAILED. Then there was PR #1795 (issue #1546), which changed the non-unittest code paths, but explicitly kept the unittest code path as failing if item._unexpectedsuccess:
rep.longrepr = "Unexpected success: {0}".format(item._unexpectedsuccess)
else:
rep.longrepr = "Unexpected success"
rep.outcome = "failed" The reason being that this how unittest's And now that I think about it again, I agree - for the unittest plugin, compatibility with unittest is more important than compatibility with pytest. So my issue was misguided here. Really sorry @antonblr that it only comes up now, after you already prepared the PR :( Nonetheless, I still think we can improve the situation on the current master -- instead of being a simple failure, it should be an |
I stepped back to rethink the case and I agree - unittest/twister tests should behave the same under both runners. If people using Also, having |
pytest version: 5.4.x & current master, Python version: 3.8
xfail background
pytest's unittest plugin tries to translate unittest concepts to pytest concept. One concept in pytest is xfail/XFAIL/XPASS (see docs).
Example:
running:
also, if running with strict xfail, this becomes
unittest background
unittest also has expected-failure/unexpected-success support:
running:
pytest unittest plugin
Given the correspondence described above, when running the unittest under pytest I would expect
test_expected_failure
to be translated to an XFAIL -- this happens, andtest_unexpected_success
to be translated to an XPASS -- this doesn't happen:To preserve the unittest behavior of unexpected-success being considered a failure, pytest should probably translate to xfail
strict=True
.Implementation notes
The current behavior is implemented in the skipping and unittest plugins using a
unexpectedsuccess_key
hack. Ideally this hack would be removed in favor of using straight xfail, this would also be a good code cleanup. Not sure how hard that would be to achieve.The text was updated successfully, but these errors were encountered: