python2 reduction: Merge remaining compat code into common
[amitay/samba.git] / source4 / dsdb / tests / python / sort.py
index 7b929eaefb66267293473ab63bf7cbd0401e48af..51d797af38d403c388ed26df2411685c413eeacf 100644 (file)
@@ -14,8 +14,8 @@ import re
 sys.path.insert(0, "bin/python")
 import samba
 from samba.tests.subunitrun import SubunitOptions, TestProgram
-from samba.compat import cmp_fn
-from samba.compat import cmp_to_key_fn
+from samba.common import cmp
+from functools import cmp_to_key
 import samba.getopt as options
 
 from samba.auth import system_session
@@ -285,10 +285,10 @@ class BaseSortTests(samba.tests.TestCase):
             return locale.strcoll(a[0], b[0])
 
         def cmp_binary(a, b):
-            return cmp_fn(a[0], b[0])
+            return cmp(a[0], b[0])
 
         def cmp_numeric(a, b):
-            return cmp_fn(int(a[0]), int(b[0]))
+            return cmp(int(a[0]), int(b[0]))
 
         # For testing simplicity, the attributes in here need to be
         # unique for each user. Otherwise there are multiple possible
@@ -303,7 +303,7 @@ class BaseSortTests(samba.tests.TestCase):
         for sort_attr, result_attr in attr_pairs:
             forward = sorted(((norm(x[sort_attr]), norm(x[result_attr]))
                              for x in self.users),
-                             key=cmp_to_key_fn(sort_functions[sort_attr]))
+                             key=cmp_to_key(sort_functions[sort_attr]))
             reverse = list(reversed(forward))
 
             for rev in (0, 1):