subunit.run: report failure in process return code
authorDouglas Bagnall <douglas.bagnall@catalyst.net.nz>
Thu, 8 Feb 2018 20:51:54 +0000 (09:51 +1300)
committerAndrew Bartlett <abartlet@samba.org>
Fri, 9 Feb 2018 06:59:20 +0000 (07:59 +0100)
The protocol requires that the TestResult object remembers when it has failed, but
in subclassing unittest.TestResult we forgot to ensure this is true.

Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
python/samba/subunit/run.py

index efaeef902c95f163d3aa8be9969a15e3cded21be..bb598b424521716076c4b94a96a8ad3414f210f9 100755 (executable)
@@ -94,6 +94,10 @@ class TestProtocolClient(unittest.TestResult):
     def __init__(self, stream):
         unittest.TestResult.__init__(self)
         self._stream = stream
+        self.failed = False
+
+    def wasSuccessful(self):
+        return not self.failed
 
     def addError(self, test, error=None):
         """Report an error in test test.
@@ -102,6 +106,7 @@ class TestProtocolClient(unittest.TestResult):
             exc_info tuple.
         """
         self._addOutcome("error", test, error=error)
+        self.failed = True
 
     def addExpectedFailure(self, test, error=None):
         """Report an expected failure in test test.
@@ -118,6 +123,7 @@ class TestProtocolClient(unittest.TestResult):
             exc_info tuple.
         """
         self._addOutcome("failure", test, error=error)
+        self.failed = True
 
     def _addOutcome(self, outcome, test, error=None, error_permitted=True):
         """Report a failure in test test.
@@ -161,6 +167,7 @@ class TestProtocolClient(unittest.TestResult):
         """Report an unexpected success in test test.
         """
         self._addOutcome("uxsuccess", test, error_permitted=False)
+        self.failed = True
 
     def startTest(self, test):
         """Mark a test as starting its test run."""