dsdb sort test: avoid exception with fewer elements
authorDouglas Bagnall <douglas.bagnall@catalyst.net.nz>
Mon, 21 Mar 2016 21:25:27 +0000 (10:25 +1300)
committerAndrew Bartlett <abartlet@samba.org>
Tue, 22 Mar 2016 07:00:31 +0000 (08:00 +0100)
The FIENDISH_TESTS list has 33 members, and when the number of
elements being tested is less than that (because you run the script
with, say, --elements=20) some will have a zero count. A recent fix
for Python 2.6 didn't take these possible zeros into account.

Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
Reviewed-by: Garming Sam <garming@catalyst.net.nz>
source4/dsdb/tests/python/sort.py

index 62d8fb80de506c7c798d0a5cb3551d56bf2315fd..480e50a92232d9970441d23aab3e7f9aead0472c 100644 (file)
@@ -199,7 +199,7 @@ class BaseSortTests(samba.tests.TestCase):
                     c[x] = 1
                 fixed = []
                 for x in FIENDISH_TESTS:
-                    fixed += [norm(x)] * c[x]
+                    fixed += [norm(x)] * c.get(x, 0)
 
                 rev = list(reversed(fixed))
                 self.expected_results[k] = (fixed, rev)