]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
s4/torture/drs/python: use cmp_fn and key=cmp_to_key_fn for py2/py3
authorNoel Power <noel.power@suse.com>
Fri, 15 Jun 2018 12:04:13 +0000 (13:04 +0100)
committerAndrew Bartlett <abartlet@samba.org>
Thu, 12 Jul 2018 23:12:25 +0000 (01:12 +0200)
Signed-off-by: Noel Power <noel.power@suse.com>
Reviewed-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
source4/torture/drs/python/getnc_exop.py

index 9d1b6ee038d98e3938cb36a4e4a571839934b431..0bb545d78cadcf3a7e296072393e04601be07458 100644 (file)
@@ -43,6 +43,8 @@ from ldb import SCOPE_BASE
 from samba.dcerpc import drsuapi, misc, drsblobs
 from samba.drs_utils import drs_DsBind
 from samba.ndr import ndr_unpack, ndr_pack
+from samba.compat import cmp_to_key_fn
+from samba.compat import cmp_fn
 
 def _linked_attribute_compare(la1, la2):
     """See CompareLinks() in MS-DRSR section 4.1.10.5.17"""
@@ -50,7 +52,7 @@ def _linked_attribute_compare(la1, la2):
     la2, la2_target = la2
 
     # Ascending host object GUID
-    c = cmp(ndr_pack(la1.identifier.guid), ndr_pack(la2.identifier.guid))
+    c = cmp_fn(ndr_pack(la1.identifier.guid), ndr_pack(la2.identifier.guid))
     if c != 0:
         return c
 
@@ -66,7 +68,7 @@ def _linked_attribute_compare(la1, la2):
         return 1 if la1_active else -1
 
     # Ascending target object GUID
-    return cmp(ndr_pack(la1_target), ndr_pack(la2_target))
+    return cmp_fn(ndr_pack(la1_target), ndr_pack(la2_target))
 
 
 class DrsReplicaSyncTestCase(drs_base.DrsBaseTestCase):
@@ -1056,7 +1058,7 @@ class DrsReplicaSyncSortTestCase(drs_base.DrsBaseTestCase):
                                          link.identifier.guid,
                                          target_guid) in expected_links)
 
-        no_inactive.sort(cmp=_linked_attribute_compare)
+        no_inactive.sort(key=cmp_to_key_fn(_linked_attribute_compare))
 
         # assert the two arrays are the same
         self.assertEqual(len(expected_links), ctr.linked_attributes_count)
@@ -1080,7 +1082,7 @@ class DrsReplicaSyncSortTestCase(drs_base.DrsBaseTestCase):
                                          link.identifier.guid,
                                          target_guid) in expected_links)
 
-        has_inactive.sort(cmp=_linked_attribute_compare)
+        has_inactive.sort(key=cmp_to_key_fn(_linked_attribute_compare))
 
         # assert the two arrays are the same
         self.assertEqual(len(expected_links), ctr.linked_attributes_count)
@@ -1128,7 +1130,7 @@ class DrsReplicaSyncSortTestCase(drs_base.DrsBaseTestCase):
                                          link.value.blob).guid
             no_inactive.append((link, target_guid))
 
-        no_inactive.sort(cmp=_linked_attribute_compare)
+        no_inactive.sort(key=cmp_to_key_fn(_linked_attribute_compare))
 
         # assert the two arrays are the same
         self.assertEqual([x[0] for x in no_inactive], ctr.linked_attributes)