-
Notifications
You must be signed in to change notification settings - Fork 23
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
Fail on subtest failure #27
Conversation
Tests with failed subtests should not be counted as passed or skipped.
Avoid confusion with tests having failed subtests accounted as passed. - Store failed subtest count as an Item attribute. - Force additional exception for passed or skipped tests if some failures happened in subtests. Accounting and reporting are not ideal: - Count of failed tests is incremented once more. - Since all subtest exception are reported earlier, it is impossible to make some of them main failure reason.
Before: passed
After: additional failure
|
Im - 1 on this, from my poc subtests contain failures, i believe letting them leak to the test directly or in aggregate should be opt in |
Reports of failures in tests marked as expected failures should be suppressed (unless run with Any other considerations or use cases when leaking of reports and propagation of results in proposed way are desired or vice versa makes results more confusing? |
IIUC, this PR makes the behavior similar to how import unittest
class T(unittest.TestCase):
def test(self):
with self.subTest("test"):
assert 0
if __name__ == "__main__":
unittest.main()
My initial intention (at least) with this plugin would be to mimic the reporting behavior of So I'm on the fence of the behavior we should adopt. |
Btw thanks @maxnikulin for the PR! |
as far as i can tell current behavour is closer to unittest, as unittest only reports the subtest failure and the executed "items" so from my pov we could do better reporting, but its still a stronger deviation to report the surrounding test as failure together with the subtest |
Totally agree that additional failure report should be avoided somehow. I suppose we just disagree on relative importance of issues. I believe that it is really confusing when failed test is reported as successful (collected == passed)
You could not tolerate additional stack trace and increased failure counter despite correct number of passed tests
I do not have strong opinion which deviation is stronger. It seams that failure number could easily overrun collected items count. I am afraid, some changes in pytest core are required for accurate fix but I do not have a clear plan. It may require to allow list of exceptions for test result instead of single one. A workaround that could easily became a source of abuses is to introduce |
@maxnikulin i would actually like better numbers, to me the proposed solution seems unfortunately does that by introducing tracekbacks that i would consider "incorrect" i'd much prefer the correct nubmers by fixing the stats, but yes that needs a core intervention |
I have an idea to add a special report that suppresses output of traceback. One failed subtest will still increment failure counter by 2. See #29 however for approach with reporting of subtests postponed till |
Replace traceback in longrepr with brief message.
@RonnyPfannschmidt, do you think the following is better than traceback report for the whole test? Certainly, exact form of the failure report could be discussed, consider current variant as a proof of concept.
|
Given it is not a consensus how this should be handled, lets close this for now. Thanks again @maxnikulin for the PR! |
Avoid confusion with tests having failed subtests accounted as passed.
tests if some failures happened in subtests.
Accounting and reporting are not ideal:
to make some of them main failure reason.
Alleviate #11 a bit.