selftest: enable py3 for samba.tests.blackbox.check_output
authorJoe Guo <joeg@catalyst.net.nz>
Fri, 23 Mar 2018 01:10:28 +0000 (14:10 +1300)
committerAndrew Bartlett <abartlet@samba.org>
Thu, 5 Apr 2018 06:59:09 +0000 (08:59 +0200)
convert bytes to str for Python 3

`BlackboxTestCase.check_output` will return bytes since it uses
`subprocess.communicate` underneath.
Convert expected string result to bytes for comparing.

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/blackbox/check_output.py
selftest/tests.py

index d7e41a838b40430fca74d92c0a8432cda2b954dd..8b3643d492d0fe9e8ff10d2f5f36fdb3eeca256a 100644 (file)
@@ -100,6 +100,8 @@ class CheckOutputTests(BlackboxTestCase):
         try:
             with TimeoutHelper(10):
                 actual = self.check_output(cmdline)
-                self.assertEqual(actual, expected)
+                # check_output will return bytes
+                # convert expected to bytes for python 3
+                self.assertEqual(actual, expected.encode('utf-8'))
         except TimeoutHelper.Timeout:
             self.fail(msg='Timeout!')
index d930373d8b1a03de8b57486c91b25c4a848ce6ed..4cb6e23446c35ba4eb4c65330ac2fb04d052f120 100644 (file)
@@ -52,7 +52,7 @@ except ImportError:
 else:
     planpythontestsuite("none", "subunit.tests.test_suite")
 planpythontestsuite("none", "samba.tests.blackbox.ndrdump")
-planpythontestsuite("none", "samba.tests.blackbox.check_output")
+planpythontestsuite("none", "samba.tests.blackbox.check_output", py3_compatible=True)
 planpythontestsuite("none", "api", name="ldb.python", extra_path=['lib/ldb/tests/python'])
 planpythontestsuite("none", "samba.tests.credentials", py3_compatible=True)
 planpythontestsuite("none", "samba.tests.registry", py3_compatible=True)