[Zodb-checkins] SVN: ZODB/trunk/src/BTrees/tests/testBTrees.py Fixed to use dictionary keys consistently.

Jim Fulton jim at zope.com
Fri Aug 28 06:43:07 EDT 2009


Log message for revision 103330:
  Fixed to use dictionary keys consistently.
  
  Fixed to use a separate Random instance.
  

Changed:
  U   ZODB/trunk/src/BTrees/tests/testBTrees.py

-=-
Modified: ZODB/trunk/src/BTrees/tests/testBTrees.py
===================================================================
--- ZODB/trunk/src/BTrees/tests/testBTrees.py	2009-08-28 10:31:42 UTC (rev 103329)
+++ ZODB/trunk/src/BTrees/tests/testBTrees.py	2009-08-28 10:43:06 UTC (rev 103330)
@@ -1618,7 +1618,7 @@
 
         t = OOBTree()
 
-        random.seed('OOBTree')
+        trandom = random.Random('OOBTree')
 
         global LP294788_ids
 
@@ -1626,22 +1626,22 @@
         LP294788_ids = {}
         ids = {}
         for i in xrange(1024):
-            if random.random() > 0.1:
+            if trandom.random() > 0.1:
                 #add
                 id = None
                 while id is None or id in ids:
-                    id = random.randint(0,1000000)
+                    id = trandom.randint(0,1000000)
 
                 ids[id] = 1
                 t[id] = ToBeDeleted(id)
             else:
                 #del
-                id = random.choice(ids.keys())
+                id = trandom.choice(ids.keys())
                 del t[id]
                 del ids[id]
 
         ids = ids.keys()
-        random.shuffle(ids)
+        trandom.shuffle(ids)
         for id in ids:
             del t[id]
         ids = None
@@ -1659,22 +1659,22 @@
         LP294788_ids = {}
         ids = {}
         for i in xrange(1024):
-            if random.random() > 0.1:
+            if trandom.random() > 0.1:
                 #add
                 id = None
                 while id is None or id in ids:
-                    id = random.randint(0,1000000)
+                    id = trandom.randint(0,1000000)
 
                 ids[id] = 1
                 t[id] = (id, ToBeDeleted(id), u'somename')
             else:
                 #del
-                id = random.choice(ids.keys())
+                id = trandom.choice(ids.keys())
                 del t[id]
                 del ids[id]
 
         ids = ids.keys()
-        random.shuffle(ids)
+        trandom.shuffle(ids)
         for id in ids:
             del t[id]
         ids = None
@@ -1694,23 +1694,22 @@
         LP294788_ids = {}
         ids = {}
         for i in xrange(1024):
-            if random.random() > 0.1:
+            if trandom.random() > 0.1:
                 #add
                 id = None
                 while id is None or id in ids:
-                    id = random.randint(0,1000000)
+                    id = ToBeDeleted(trandom.randint(0,1000000))
 
-                obj = ToBeDeleted(id)
-                ids[obj] = 1
-                t[obj] = 1
+                ids[id] = 1
+                t[id] = 1
             else:
                 #del
-                obj = random.choice(ids.keys())
-                del ids[obj]
-                del t[obj]
+                id = trandom.choice(ids.keys())
+                del ids[id]
+                del t[id]
 
         ids = ids.keys()
-        random.shuffle(ids)
+        trandom.shuffle(ids)
         for id in ids:
             del t[id]
         #release all refs
@@ -1729,23 +1728,23 @@
         LP294788_ids = {}
         ids = {}
         for i in xrange(1024):
-            if random.random() > 0.1:
+            if trandom.random() > 0.1:
                 #add
                 id = None
                 while id is None or id in ids:
-                    id = random.randint(0,1000000)
+                    id = trandom.randint(0,1000000)
+                    id = (id, ToBeDeleted(id), u'somename')
 
-                key = (id, ToBeDeleted(id), u'somename')
-                ids[key] = 1
-                t[key] = 1
+                ids[id] = 1
+                t[id] = 1
             else:
                 #del
-                key = random.choice(ids.keys())
-                del ids[key]
-                del t[key]
+                id = trandom.choice(ids.keys())
+                del ids[id]
+                del t[id]
 
         ids = ids.keys()
-        random.shuffle(ids)
+        trandom.shuffle(ids)
         for id in ids:
             del t[id]
         #release all refs



More information about the Zodb-checkins mailing list