VERSION: Disable GIT_SNAPSHOT for the 4.11.0rc1 release...
[samba.git] / selftest / subunithelper.py
index 3ac2d963a90842a9fabd55bdc560ab11b4577739..651d9b00289dc597295b63944a6616e0ed4cb315 100644 (file)
@@ -26,6 +26,8 @@ from samba import subunit
 from samba.subunit.run import TestProtocolClient
 from samba.subunit import iso8601
 import unittest
+from samba.compat import binary_type
+
 
 VALID_RESULTS = set(['success', 'successful', 'failure', 'fail', 'skip',
                      'knownfail', 'error', 'xfail', 'skip-testsuite',
@@ -33,6 +35,7 @@ VALID_RESULTS = set(['success', 'successful', 'failure', 'fail', 'skip',
                      'testsuite-success', 'testsuite-error',
                      'uxsuccess', 'testsuite-uxsuccess'])
 
+
 class TestsuiteEnabledTestResult(unittest.TestResult):
 
     def start_testsuite(self, name):
@@ -90,7 +93,10 @@ def parse_results(msg_ops, statistics, fh):
                     else:
                         reason += l
 
-                remote_error = subunit.RemoteError(reason.decode("utf-8"))
+                if isinstance(reason, binary_type):
+                    remote_error = subunit.RemoteError(reason.decode("utf-8"))
+                else:
+                    remote_error = subunit.RemoteError(reason)
 
                 if not terminated:
                     statistics['TESTS_ERROR'] += 1
@@ -600,7 +606,7 @@ class PlainFormatter(TestsuiteEnabledTestResult):
         out = ""
         unexpected = False
 
-        if not name in self.test_output:
+        if name not in self.test_output:
             print("no output for name[%s]" % name)
 
         if result in ("success", "xfail"):
@@ -654,7 +660,7 @@ class PlainFormatter(TestsuiteEnabledTestResult):
                     'success': '.'}.get(result, "?(%s)" % result))
             return
 
-        if not self.name in self.test_output:
+        if self.name not in self.test_output:
             self.test_output[self.name] = ""
 
         self.test_output[self.name] += "UNEXPECTED(%s): %s\n" % (result, testname)