PEP8: fix E261: at least two spaces before inline comment
[samba.git] / source4 / dsdb / tests / python / ad_dc_medley_performance.py
index f49563c7f6cbeb6f232e7f72af241141f148e8c8..f2a8fea60b5617701ae4c8248f2768d621e2cc04 100644 (file)
@@ -38,6 +38,7 @@ from samba.auth import system_session
 from ldb import Message, MessageElement, Dn, LdbError
 from ldb import FLAG_MOD_ADD, FLAG_MOD_REPLACE, FLAG_MOD_DELETE
 from ldb import SCOPE_BASE, SCOPE_SUBTREE, SCOPE_ONELEVEL
+from ldb import ERR_NO_SUCH_OBJECT
 
 parser = optparse.OptionParser("ad_dc_performance.py [options] <host>")
 sambaopts = options.SambaOptions(parser)
@@ -200,7 +201,7 @@ class UserTests(samba.tests.TestCase):
     def _test_indexed_search(self):
         expressions = ['(objectclass=group)',
                        '(samaccountname=Administrator)'
-        ]
+                       ]
         for expression in expressions:
             t = time.time()
             for i in range(4000):
@@ -222,15 +223,19 @@ class UserTests(samba.tests.TestCase):
                                     attrs=['cn'])
                 except LdbError as e:
                     (num, msg) = e.args
-                    if num != 32:
+                    if num != ERR_NO_SUCH_OBJECT:
                         raise
 
     def _test_base_search_failing(self):
         pattern = 'missing%d' + self.ou
         for i in range(4000):
-            self.ldb.search(pattern % i,
-                            scope=SCOPE_BASE,
-                            attrs=['cn'])
+            try:
+                self.ldb.search(pattern % i,
+                                scope=SCOPE_BASE,
+                                attrs=['cn'])
+            except LdbError as (num, msg):
+                if num != ERR_NO_SUCH_OBJECT:
+                    raise
 
     def search_expression_list(self, expressions, rounds,
                                attrs=['cn'],
@@ -249,7 +254,7 @@ class UserTests(samba.tests.TestCase):
     def _test_complex_search(self, n=100):
         classes = ['samaccountname', 'objectCategory', 'dn', 'member']
         values = ['*', '*t*', 'g*', 'user']
-        comparators = ['=', '<=', '>='] # '~=' causes error
+        comparators = ['=', '<=', '>=']  # '~=' causes error
         maybe_not = ['!(', '']
         joiners = ['&', '|']