python: samba.tests.dcerpc.misc: Port and enable tests
authorLumir Balhar <lbalhar@redhat.com>
Wed, 18 Jan 2017 10:38:55 +0000 (11:38 +0100)
committerAndrew Bartlett <abartlet@samba.org>
Fri, 10 Mar 2017 06:31:11 +0000 (07:31 +0100)
Port tests of samba.dcerpc.misc module to Python 3 compatible form
and enable their execution with Python 3.

Signed-off-by: Lumir Balhar <lbalhar@redhat.com>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
Reviewed-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
python/samba/tests/dcerpc/misc.py
selftest/tests.py

index 11e14aadfa729191d3e0a8d3d11ad7f4e4b0a3c2..7cdb0048148e91ea36b6eb11fa34c8b13ace04e5 100644 (file)
@@ -19,6 +19,7 @@
 
 from samba.dcerpc import misc
 import samba.tests
+from samba.compat import PY3
 
 text1 = "76f53846-a7c2-476a-ae2c-20e2b80d7b34"
 text2 = "344edffa-330a-4b39-b96e-2c34da52e8b1"
@@ -36,13 +37,19 @@ class GUIDTests(samba.tests.TestCase):
     def test_compare_different(self):
         guid1 = misc.GUID(text1)
         guid2 = misc.GUID(text2)
-        self.assertTrue(cmp(guid1, guid2) > 0)
+        self.assertFalse(guid1 == guid2)
+        if not PY3:
+            # cmp() exists only in Python 2
+            self.assertTrue(cmp(guid1, guid2) > 0)
 
     def test_compare_same(self):
         guid1 = misc.GUID(text1)
         guid2 = misc.GUID(text1)
-        self.assertEquals(0, cmp(guid1, guid2))
+        self.assertTrue(guid1 == guid2)
         self.assertEquals(guid1, guid2)
+        if not PY3:
+            # cmp() exists only in Python 2
+            self.assertEquals(0, cmp(guid1, guid2))
 
 
 class PolicyHandleTests(samba.tests.TestCase):
index 77a17a0279ecd4325292240c44ae758294436ff5..150948325b37f743aeeb3f3122cc152091902bf9 100644 (file)
@@ -57,7 +57,7 @@ planpythontestsuite("none", "samba.tests.registry")
 planpythontestsuite("none", "samba.tests.auth")
 planpythontestsuite("none", "samba.tests.get_opt")
 planpythontestsuite("none", "samba.tests.security")
-planpythontestsuite("none", "samba.tests.dcerpc.misc")
+planpythontestsuite("none", "samba.tests.dcerpc.misc", py3_compatible=True)
 planpythontestsuite("none", "samba.tests.dcerpc.integer")
 planpythontestsuite("none", "samba.tests.param", py3_compatible=True)
 planpythontestsuite("none", "samba.tests.upgrade")