From 2b0e128c8782fb88e574caf690c846fd41759e82 Mon Sep 17 00:00:00 2001 From: Nathan Stocks Date: Sun, 25 Apr 2021 23:00:59 -0600 Subject: [PATCH] Count unexpected successes as failures as unittest does. Resolves #241 --- green/result.py | 4 ++-- green/test/test_result.py | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/green/result.py b/green/result.py index b931322..2b16095 100644 --- a/green/result.py +++ b/green/result.py @@ -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))) @@ -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 diff --git a/green/test/test_result.py b/green/test/test_result.py index 5511c0d..fa4f1be 100644 --- a/green/test/test_result.py +++ b/green/test/test_result.py @@ -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): """