Commit 8a8e8d09 authored by Jeremy Hylton's avatar Jeremy Hylton

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.
parent dc490d66
......@@ -82,14 +82,7 @@
# attributions are listed in the accompanying credits file.
#
##############################################################################
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 @@ class MappingBase(Base):
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 @@ class MappingBase(Base):
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 @@ class MappingBase(Base):
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 @@ class NormalSetTests(Base):
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 @@ class BTreeTests(MappingBase):
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 @@ class BTreeTests(MappingBase):
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 @@ class BTreeTests(MappingBase):
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 @@ class BTreeTests(MappingBase):
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 @@ class BTreeTests(MappingBase):
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())
......
......@@ -82,14 +82,7 @@
# attributions are listed in the accompanying credits file.
#
##############################################################################
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 @@ class MappingBase(Base):
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 @@ class ExtendedSetTests(NormalSetTests):
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()
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment