From: Joe Guo Date: Thu, 5 Apr 2018 01:48:36 +0000 (+1200) Subject: selftest: enable py3 for samba.tests.docs X-Git-Tag: ldb-1.4.0~593 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=a9f591369ee9359961237a03eb19672a47cb4e11;p=thirdparty%2Fsamba.git selftest: enable py3 for samba.tests.docs Popen methods will return bytes. Decode output to string before using. Signed-off-by: Joe Guo Reviewed-by: Andrew Bartlett Reviewed-by: Douglas Bagnall --- diff --git a/python/samba/tests/docs.py b/python/samba/tests/docs.py index 3d896d7c7d2..0f029ae02d2 100644 --- a/python/samba/tests/docs.py +++ b/python/samba/tests/docs.py @@ -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 *"): diff --git a/selftest/tests.py b/selftest/tests.py index 548e68b5c1b..c8f2411f4b1 100644 --- a/selftest/tests.py +++ b/selftest/tests.py @@ -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