-
-
Notifications
You must be signed in to change notification settings - Fork 29.9k
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
unexpected successes are not output #67004
Comments
Unexpected successes cause failures, but we don't output details about them at the end of the run. From https://code.google.com/p/unittest-ext/issues/detail?id=22 A complicating factor is that we don't have a backtrace to show - but we may have captured stdout/stderr or in future various test attachments to show. |
I think this has been fixed: % cat mm.py class TestStringMethods(unittest.TestCase):
@unittest.expectedFailure
def test_upper(self):
self.assertEqual(2, 2)
if __name__ == '__main__':
unittest.main() % ./python.exe mm.py OK (expected failures=1) FAILED (unexpected successes=1) |
Or do you mean that there should be more output? |
In verbose mode we do get output like the one in the code.google issue: % cat tmp.py import unittest
class TestStringMethods(unittest.TestCase):
@unittest.expectedFailure
def test_upper(self):
self.assertEqual(2, 2)
def test_lower(self):
return
if __name__ == '__main__':
unittest.main() % ./python.exe -m tmp -v |
I don't think adding more information from the test would be helpful - when a test fails you have (and need) information about what happened. But when a test succeeds the code of the test basically tells you what happened - all the assertions passed. I think we can close this. |
I think the OP means that test details (test description, traceback, captured output) are printed for ERROR and FAIL in TextTestResult.printErrors(). Other possible results besides error and failure are success, skipped, expected failure and unexpected success. Success, skipped and expected failure are expected, they do not cause total failure, but unexpected success is different. Result.wasSuccessful() returns False if there are any errors, failures or unexpected successes. But unlike errors and failures we do not have any details about unexpected successes. It looks like oversight to me. Yes, there are no traceback for unexpected success, but at least we can output the test description and captured output. |
There are no other details for unexpected successes, only test descriptions. |
Yes, this is why I don’t understand the request here. When a test fails you know which assertion was violated or which line raised an exception. When a multi line test succeeds, you don’t know which line was supposed to fail. |
I know that in unittest2 an unexpected success did not cause the test to fail (when we moved from unittest2 to unittest at work we got test failures due to unexpected successes that previously did not show up). I don't know the whole history of how unittest2 came to be, I think it was a clone of an older copy of unittest? Maybe that it the background for this issue? |
Unless you tun tests in verbose mode you do not know which of tests was unexpectedly successful. And even in the verbose mode it is not easy to find that test in long output. Yes, unexpected successes considered successes in earlier versions. See bpo-20165. You can find many interesting when read git logs. |
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:
bugs.python.org fields:
The text was updated successfully, but these errors were encountered: