Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(2)

Unified Diff: Lib/unittest/result.py

Issue 20165: unittest TestResult wasSuccessful returns True when there are unexpected successes
Patch Set: Created 6 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Please Sign in to add in-line comments.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | Lib/unittest/test/test_skipping.py » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
--- a/Lib/unittest/result.py Tue Jan 07 23:29:19 2014 -0700
+++ b/Lib/unittest/result.py Wed Jan 08 01:26:22 2014 -0800
@@ -156,11 +156,16 @@
self.unexpectedSuccesses.append(test)
def wasSuccessful(self):
- "Tells whether or not this result was a success"
- return len(self.failures) == len(self.errors) == 0
+ """Tells whether or not this result was a success."""
+ # The hasattr check is for test_result's OldResult test. That
+ # way this method works on objects that lack the attribute.
+ # (where would such result intances come from? old stored pickles?)
+ return ((len(self.failures) == len(self.errors) == 0) and
+ (not hasattr(self, 'unexpectedSuccesses') or
+ len(self.unexpectedSuccesses) == 0))
def stop(self):
- "Indicates that the tests should be aborted"
+ """Indicates that the tests should be aborted."""
self.shouldStop = True
def _exc_info_to_string(self, err, test):
« no previous file with comments | « no previous file | Lib/unittest/test/test_skipping.py » ('j') | no next file with comments »

RSS Feeds Recent Issues | This issue
This is Rietveld 894c83f36cb7+