[Zope-Checkins] CVS: Zope/lib/python/BTrees/tests - testBTrees.py:1.18 testConflict.py:1.5

Jeremy Hylton jeremy@zope.com
Tue, 7 Aug 2001 15:30:59 -0400


Update of /cvs-repository/Zope/lib/python/BTrees/tests
In directory cvs.zope.org:/tmp/cvs-serv3035

Modified Files:
	testBTrees.py testConflict.py 
Log Message:
Fixes for includion in StandaloneZODB test suite.

The testrunner reports all tests passed after these changes.
Remove unnecessary path munging and attempts to import ZODB.
Update uses of whrandom to use random.


=== Zope/lib/python/BTrees/tests/testBTrees.py 1.17 => 1.18 ===
 # 
 ##############################################################################
-import sys, os, time, whrandom
-
-try:
-    sys.path.insert(0, '.')
-    import ZODB
-except:
-    sys.path.insert(0, '../..')
-    import ZODB
+import sys, os, time, random
 
 from BTrees.OOBTree import OOBTree, OOBucket, OOSet, OOTreeSet
 from BTrees.IOBTree import IOBTree, IOBucket, IOSet, IOTreeSet
@@ -208,7 +201,7 @@
         added = {}
         r = range(1000)
         for x in r:
-            k = whrandom.choice(r)
+            k = random.choice(r)
             self.t[k] = x
             added[k] = x
         addl = added.keys()
@@ -276,7 +269,7 @@
     def testClear(self):
         r = range(100)
         for x in r:
-            rnd = whrandom.choice(r)
+            rnd = random.choice(r)
             self.t[rnd] = 0
         self.t.clear()
         diff = lsubtract(list(self.t.keys()), [])
@@ -287,7 +280,7 @@
         d={}
         l=[]
         for i in range(10000):
-            k=whrandom.randint(-2000, 2000)
+            k=random.randrange(-2000, 2001)
             d[k]=i
             l.append((k, i))
             
@@ -396,7 +389,7 @@
         d={}
         l=[]
         for i in range(10000):
-            k=whrandom.randint(-2000, 2000)
+            k=random.randrange(-2000, 2001)
             d[k]=i
             l.append(k)
             
@@ -502,7 +495,7 @@
         added = {}
         r = range(100)
         for x in r:
-            k = whrandom.choice(r)
+            k = random.choice(r)
             if not added.has_key(k):
                 self.t[k] = x
                 added[k] = 1
@@ -515,7 +508,7 @@
         added = {}
         r = range(100)
         for x in r:
-            k = whrandom.choice(r)
+            k = random.choice(r)
             self.t[k] = x
             added[k] = 1
         addl = added.keys()
@@ -527,12 +520,12 @@
         r = range(1000)
         added = []
         for x in r:
-            k = whrandom.choice(r)
+            k = random.choice(r)
             self.t[k] = x
             added.append(k)
         deleted = []
         for x in r:
-            k = whrandom.choice(r)
+            k = random.choice(r)
             if self.t.has_key(k):
                 del self.t[k]
                 deleted.append(k)
@@ -547,7 +540,7 @@
     def testTargetedDeletes(self):
         r = range(1000)
         for x in r:
-            k = whrandom.choice(r)
+            k = random.choice(r)
             self.t[k] = x
         for x in r:
             try:
@@ -634,7 +627,7 @@
         r = range(100)
         a = {}
         for x in r:
-            rnd = whrandom.choice(r)
+            rnd = random.choice(r)
             self.t[rnd] = 0
             a[rnd] = 0
         diff = lsubtract(list(self.t.keys(0, 100)), a.keys())


=== Zope/lib/python/BTrees/tests/testConflict.py 1.4 => 1.5 ===
 # 
 ##############################################################################
-import sys, os, time, whrandom
-
-try:
-    sys.path.insert(0, '.')
-    import ZODB
-except:
-    sys.path.insert(0, '../..')
-    import ZODB
+import sys, os, time, random
 
 from BTrees.OOBTree import OOBTree, OOBucket, OOSet, OOTreeSet
 from BTrees.IOBTree import IOBTree, IOBucket, IOSet, IOTreeSet
@@ -129,18 +122,18 @@
         base=self.t
         d={}
         for i in range(20):
-            d[whrandom.randint(-10000, 10000)]=i*100000
+            d[random.randrange(-10000, 10001)]=i*100000
 
         e1={}
         while len(e1) < 5:
-            k=whrandom.randint(-10000, 10000)
+            k=random.randrange(-10000, 10001)
             if not d.has_key(k):
                 e1[k]=len(e1)
         e1=e1.items()
 
         e2={}
         while len(e2) < 5:
-            k=whrandom.randint(-10000, 10000)
+            k=random.randrange(-10000, 10001)
             if not d.has_key(k) and not e2.has_key(k):
                 e2[k]=len(e2)
         e2=e2.items()
@@ -280,18 +273,18 @@
         base=self.t
         d={}
         for i in range(20):
-            d[whrandom.randint(-10000, 10000)]=i*100000
+            d[random.randrange(-10000, 10001)]=i*100000
 
         e1={}
         while len(e1) < 5:
-            k=whrandom.randint(-10000, 10000)
+            k=random.randrange(-10000, 10001)
             if not d.has_key(k):
                 e1[k]=len(e1)
         e1=e1.keys()
 
         e2={}
         while len(e2) < 5:
-            k=whrandom.randint(-10000, 10000)
+            k=random.randrange(-10000, 10001)
             if not d.has_key(k) and not e2.has_key(k):
                 e2[k]=len(e2)
         e2=e2.keys()