SVN: ZODB/trunk/src/BTrees/tests/testBTrees.py Fixed to use dictionary keys consistently.

Jim Fulton <[email protected]>
Newsgroups gmane.comp.python.zope.zodb.cvs
Message-ID <20090828104307.396F59417B__42218.4082716287$1251456198$gmane$org@cvs.zope.org>
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
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.