diff options
author | Noel Power <noel.power@suse.com> | 2018-10-30 13:25:59 +0000 |
---|---|---|
committer | Andrew Bartlett <abartlet@samba.org> | 2018-11-14 05:07:16 +0100 |
commit | 108109360a5b8ca45b8bf0eef020fe001af61d1d (patch) | |
tree | 01e75a1ea0d5e95850dede628ff4efb45a21941d /python | |
parent | 0ef6e3da4b6dd8e36ced3ad344f9981901aaa2f2 (diff) | |
download | samba-108109360a5b8ca45b8bf0eef020fe001af61d1d.tar.gz |
python/samba/tests: Port samba.tests.blackbox.samba_dnsupdate for PY2/PY3
Make sure either the output of tests and/or the item we are searching match
in type. Output of cmd in python3 is bytes, depending on the was the test is
written it may be easier just to convert all output or just a single string
that is used in the test
Signed-off-by: Noel Power <noel.power@suse.com>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
Diffstat (limited to 'python')
-rw-r--r-- | python/samba/tests/blackbox/samba_dnsupdate.py | 21 |
1 files changed, 11 insertions, 10 deletions
diff --git a/python/samba/tests/blackbox/samba_dnsupdate.py b/python/samba/tests/blackbox/samba_dnsupdate.py index 3e206a44e0c..3e168bc00d9 100644 --- a/python/samba/tests/blackbox/samba_dnsupdate.py +++ b/python/samba/tests/blackbox/samba_dnsupdate.py @@ -18,6 +18,7 @@ import samba.tests from samba.compat import StringIO +from samba.compat import get_string from samba.netcmd.main import cmd_sambatool from samba.credentials import Credentials from samba.auth import system_session @@ -34,7 +35,7 @@ class SambaDnsUpdateTests(samba.tests.BlackboxTestCase): super(SambaDnsUpdateTests, self).setUp() try: out = self.check_output("samba_dnsupdate --verbose") - self.assertTrue("Looking for DNS entry" in out, out) + self.assertTrue(b"Looking for DNS entry" in out, out) except samba.tests.BlackboxProcessError: pass @@ -43,13 +44,13 @@ class SambaDnsUpdateTests(samba.tests.BlackboxTestCase): out = self.check_output("samba_dnsupdate --verbose") except samba.tests.BlackboxProcessError as e: self.fail("Error calling samba_dnsupdate: %s" % e) - self.assertTrue("No DNS updates needed" in out, out) + self.assertTrue(b"No DNS updates needed" in out, out) def test_samba_dnsupate_set_ip(self): try: out = self.check_output("samba_dnsupdate --verbose --current-ip=10.0.0.1") - self.assertTrue(" DNS updates and" in out, out) - self.assertTrue(" DNS deletes needed" in out, out) + self.assertTrue(b" DNS updates and" in out, out) + self.assertTrue(b" DNS deletes needed" in out, out) except samba.tests.BlackboxProcessError: pass @@ -58,16 +59,16 @@ class SambaDnsUpdateTests(samba.tests.BlackboxTestCase): except samba.tests.BlackboxProcessError as e: self.fail("Error calling samba_dnsupdate: %s" % e) - self.assertTrue("No DNS updates needed" in out, out) + self.assertTrue(b"No DNS updates needed" in out, out) try: rpc_out = self.check_output("samba_dnsupdate --verbose --use-samba-tool --rpc-server-ip=%s" % self.server_ip) except samba.tests.BlackboxProcessError as e: self.fail("Error calling samba_dnsupdate: %s" % e) - self.assertTrue(" DNS updates and" in rpc_out, rpc_out) - self.assertTrue(" DNS deletes needed" in rpc_out, rpc_out) + self.assertTrue(b" DNS updates and" in rpc_out, rpc_out) + self.assertTrue(b" DNS deletes needed" in rpc_out, rpc_out) out = self.check_output("samba_dnsupdate --verbose") - self.assertTrue("No DNS updates needed" in out, out + rpc_out) + self.assertTrue(b"No DNS updates needed" in out, out + rpc_out) def test_add_new_uncovered_site(self): name = 'sites' @@ -106,13 +107,13 @@ class SambaDnsUpdateTests(samba.tests.BlackboxTestCase): ldb.FLAG_MOD_ADD, "siteList") dns_c = "samba_dnsupdate --verbose --use-file={0}".format(tmp_uc) - out = self.check_output(dns_c) + out = get_string(self.check_output(dns_c)) self.assertFalse(site_name.lower() in out, out) self.samdb.modify(m) shutil.copyfile(uc_fn, tmp_uc) - out = self.check_output(dns_c) + out = get_string(self.check_output(dns_c)) self.assertFalse("No DNS updates needed" in out, out) self.assertTrue(site_name.lower() in out, out) |