-
Notifications
You must be signed in to change notification settings - Fork 22
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
Confusion: Missing subtest message in 4 failed subtest but 1 test passed #99
Comments
Hi @buhtz, The current output tries to mimic how the standard |
@nicoddemus The current output - regarding Problem 1 - does not mimic the behavior of the builtin unittest subtests. Consider the following example: import unittest
class Test(unittest.TestCase):
def test(self):
for i in [0, 2]:
with self.subTest(i=i):
self.assertEqual(0, i%2)
if __name__ == '__main__':
unittest.main() Running this with
or, with
Hence, the standard unittest subtests usage reports 1 passed test. Let's compare this to
So far, so good. But now, what if one of the subtests fails? Let's change the above code example from
Specifically, at the top of the output there is no However, running this with
While pytest reports 1 failure, similar to unittest, it also reports 1 passed test. This behavior is different from unittest's where no passed test is reported. That behavior of pytest (adding a passed test) is even present when all subtests fail. Let's change
2 failures are reported correctly, but again, 1 passed is wrong. This behavior is different from the builtin unittest subtest behavior and should thus be considered a bug. Also, it's very counterintuitive. Instead, the success of a test with respect to its subtests should be computed as |
I have two problems here and not sure if I misunderstand the purpose of pytest-subtests or if there really is a bug.
I have a unittest like this
You see
assertTrue()
is called five times.The
pytest
outputProblem 1 : passed but not passed
The message
4 failed, 1 passed
might technically be correct but it is wrong from the users perspective. There is one test defined by thedef test_...()
method. It doesn't matter how oftenself.assert...()
is called in there. One fail means the whole test fails. Saying1 passed
is a bug.Problem 2 : sub test message missing
I do use subtest (
self.subTest(str(fp))
) to better see which part of the test failed. But the output just tells me four timesAssertionError: False is not true
without more details about which subtest is involved. I would expect something likeAssertionError: False is not true (/Beverly/Foo.pickle)
as an output.The text was updated successfully, but these errors were encountered: