selftest: enable py3 for samba.tests.docs
authorJoe Guo <joeg@catalyst.net.nz>
Thu, 5 Apr 2018 01:48:36 +0000 (13:48 +1200)
committerDouglas Bagnall <dbagnall@samba.org>
Fri, 13 Apr 2018 05:27:13 +0000 (07:27 +0200)
Popen methods will return bytes.
Decode output to string before using.

Signed-off-by: Joe Guo <joeg@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
Reviewed-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
python/samba/tests/docs.py
selftest/tests.py

index 3d896d7c7d2bf87097ab3097e6aea1297a7c708d..0f029ae02d2d0301961f37f155e28490ad4f2a21 100644 (file)
@@ -197,10 +197,11 @@ class SmbDotConfTests(TestCase):
             p = subprocess.Popen(program + ["-s", self.smbconf,
                     "--section-name", section, "--parameter-name", param],
                     stdout=subprocess.PIPE, stderr=subprocess.PIPE, cwd=self.topdir).communicate()
-            if p[0].upper().strip() != default.upper():
-                if not (p[0].upper().strip() == "" and default == '""'):
+            result = p[0].decode().upper().strip()
+            if result != default.upper():
+                if not (result == "" and default == '""'):
                     doc_triple = "%s\n      Expected: %s" % (param, default)
-                    failset.add("%s\n      Got: %s" % (doc_triple, p[0].upper().strip()))
+                    failset.add("%s\n      Got: %s" % (doc_triple, result))
 
         if len(failset) > 0:
             self.fail(self._format_message(failset,
@@ -227,10 +228,11 @@ class SmbDotConfTests(TestCase):
                     "--section-name", section, "--parameter-name", param,
                     "--option", "%s = %s" % (param, default)],
                     stdout=subprocess.PIPE, stderr=subprocess.PIPE, cwd=self.topdir).communicate()
-            if p[0].upper().strip() != default.upper():
-                if not (p[0].upper().strip() == "" and default == '""'):
+            result = p[0].decode().upper().strip()
+            if result != default.upper():
+                if not (result == "" and default == '""'):
                     doc_triple = "%s\n      Expected: %s" % (param, default)
-                    failset.add("%s\n      Got: %s" % (doc_triple, p[0].upper().strip()))
+                    failset.add("%s\n      Got: %s" % (doc_triple, result))
 
         if len(failset) > 0:
             self.fail(self._format_message(failset,
@@ -285,10 +287,11 @@ class SmbDotConfTests(TestCase):
                     "--section-name", section, "--parameter-name", param,
                     "--option", "%s = %s" % (param, value_to_use)],
                     stdout=subprocess.PIPE, stderr=subprocess.PIPE, cwd=self.topdir).communicate()
-            if p[0].upper().strip() != value_to_use.upper():
+            result = p[0].decode().upper().strip()
+            if result != value_to_use.upper():
                 # currently no way to distinguish command lists
                 if param_type == 'list':
-                    if ", ".join(p[0].upper().strip().split()) == value_to_use.upper():
+                    if ", ".join(result.split()) == value_to_use.upper():
                         continue
 
                 # currently no way to identify octal
@@ -320,7 +323,7 @@ class SmbDotConfTests(TestCase):
 
             # testparm doesn't display a value if they are equivalent
             if (value_to_use.lower() != opposite_value.lower()):
-                for line in p[0].splitlines():
+                for line in p[0].decode().splitlines():
                     if not line.strip().startswith(param):
                         continue
 
@@ -352,7 +355,7 @@ class SmbDotConfTests(TestCase):
                 stdout=subprocess.PIPE, stderr=subprocess.PIPE, cwd=self.topdir).communicate()
         output = ""
 
-        for line in p[0].splitlines():
+        for line in p[0].decode().splitlines():
             if line.strip().startswith('#'):
                 continue
             if line.strip().startswith("idmap config *"):
index 548e68b5c1b80a0bc0e909f4b3c7206a3a001947..c8f2411f4b1bb72cb53c9d53a9fc8d7991832250 100644 (file)
@@ -43,7 +43,7 @@ pam_wrapper_so_path=config_hash["LIBPAM_WRAPPER_SO_PATH"]
 
 planpythontestsuite("none", "samba.tests.source", py3_compatible=True)
 if have_man_pages_support:
-    planpythontestsuite("none", "samba.tests.docs")
+    planpythontestsuite("none", "samba.tests.docs", py3_compatible=True)
 
 try:
     import testscenarios