Skip to content

Commit

Permalink
Count unexpected successes as failures as unittest does. Resolves #241
Browse files Browse the repository at this point in the history
  • Loading branch information
CleanCut committed Apr 26, 2021
1 parent 01405d6 commit 2b0e128
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
4 changes: 2 additions & 2 deletions green/result.py
Original file line number Diff line number Diff line change
Expand Up @@ -544,7 +544,7 @@ def stopTestRun(self):
self.stream.writeln(self.colors.failing("No Tests Found"))
else:
grade = self.colors.passing("OK")
if self.errors or self.failures:
if not self.wasSuccessful():
grade = self.colors.failing("FAILED")
self.stream.writeln("{} ({})".format(grade, ", ".join(stats)))

Expand Down Expand Up @@ -791,4 +791,4 @@ def wasSuccessful(self):
):
return False
else:
return len(self.all_errors) == 0
return len(self.all_errors) + len(self.unexpectedSuccesses) == 0
2 changes: 1 addition & 1 deletion green/test/test_result.py
Original file line number Diff line number Diff line change
Expand Up @@ -1056,7 +1056,7 @@ def test_wasSuccessful_unexpectedSuccesses(self):
self.args.verbose = 1
gtr = GreenTestResult(self.args, GreenStream(self.stream))
gtr.unexpectedSuccesses.append("anything")
self.assertEqual(gtr.wasSuccessful(), True)
self.assertEqual(gtr.wasSuccessful(), False)

def test_wasSuccessful_coverageFails(self):
"""
Expand Down

0 comments on commit 2b0e128

Please sign in to comment.