[Zodb-checkins] CVS: Zope/lib/python/BTrees/tests - testBTrees.py:1.14.40.1 testConflict.py:1.2.40.1

Shane Hathaway shane@digicool.com
Thu, 9 Aug 2001 13:34:02 -0400


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

Modified Files:
      Tag: NR-branch
	testBTrees.py testConflict.py 
Log Message:
Sync NR-branch with trunk.  Sorry about so many checkin messages...


=== Zope/lib/python/BTrees/tests/testBTrees.py 1.14 => 1.14.40.1 ===
 # 
 ##############################################################################
-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
 from BTrees.IIBTree import IIBTree, IIBucket, IISet, IITreeSet
 from BTrees.OIBTree import OIBTree, OIBucket, OISet, OITreeSet
-from unittest import TestCase, TestSuite, JUnitTextTestRunner, VerboseTextTestRunner, makeSuite
+from unittest import TestCase, TestSuite, TextTestRunner, makeSuite
 
-TextTestRunner = VerboseTextTestRunner
+from glob import glob
+import os
 
 class Base:
     """ Tests common to all types: sets, buckets, and BTrees """
@@ -119,8 +113,9 @@
         root = None
 
     def _delDB(self):
-        os.system('rm fs_tmp__*')
-                
+        for file in glob('fs_tmp__*'):
+            os.remove(file)
+        
     def testLoadAndStore(self):
         for i in 0, 10, 1000:
             t = self.t.__class__()
@@ -206,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()
@@ -274,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()), [])
@@ -285,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))
             
@@ -394,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)
             
@@ -500,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
@@ -513,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()
@@ -525,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)
@@ -545,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:
@@ -632,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())
@@ -815,7 +810,7 @@
 
 def main():
     alltests=test_suite()
-    runner = TextTestRunner()
+    runner = TextTestRunner(verbosity=2)
     runner.run(alltests)
 
 def debug():


=== Zope/lib/python/BTrees/tests/testConflict.py 1.2 => 1.2.40.1 ===
 # 
 ##############################################################################
-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
 from BTrees.IIBTree import IIBTree, IIBucket, IISet, IITreeSet
 from BTrees.OIBTree import OIBTree, OIBucket, OISet, OITreeSet
-from unittest import TestCase, TestSuite, JUnitTextTestRunner, VerboseTextTestRunner, makeSuite
-
-TextTestRunner = VerboseTextTestRunner
+from unittest import TestCase, TestSuite, TextTestRunner, makeSuite
 
 class Base:
     """ Tests common to all types: sets, buckets, and BTrees """
@@ -131,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()
@@ -282,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()
@@ -507,7 +498,7 @@
 
 def main():
     alltests=test_suite()
-    runner = TextTestRunner()
+    runner = TextTestRunner(verbosity=2)
     runner.run(alltests)
 
 def debug():