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 @@ ...@@ -82,14 +82,7 @@
# attributions are listed in the accompanying credits file. # attributions are listed in the accompanying credits file.
# #
############################################################################## ##############################################################################
import sys, os, time, whrandom import sys, os, time, random
try:
sys.path.insert(0, '.')
import ZODB
except:
sys.path.insert(0, '../..')
import ZODB
from BTrees.OOBTree import OOBTree, OOBucket, OOSet, OOTreeSet from BTrees.OOBTree import OOBTree, OOBucket, OOSet, OOTreeSet
from BTrees.IOBTree import IOBTree, IOBucket, IOSet, IOTreeSet from BTrees.IOBTree import IOBTree, IOBucket, IOSet, IOTreeSet
...@@ -208,7 +201,7 @@ class MappingBase(Base): ...@@ -208,7 +201,7 @@ class MappingBase(Base):
added = {} added = {}
r = range(1000) r = range(1000)
for x in r: for x in r:
k = whrandom.choice(r) k = random.choice(r)
self.t[k] = x self.t[k] = x
added[k] = x added[k] = x
addl = added.keys() addl = added.keys()
...@@ -276,7 +269,7 @@ class MappingBase(Base): ...@@ -276,7 +269,7 @@ class MappingBase(Base):
def testClear(self): def testClear(self):
r = range(100) r = range(100)
for x in r: for x in r:
rnd = whrandom.choice(r) rnd = random.choice(r)
self.t[rnd] = 0 self.t[rnd] = 0
self.t.clear() self.t.clear()
diff = lsubtract(list(self.t.keys()), []) diff = lsubtract(list(self.t.keys()), [])
...@@ -287,7 +280,7 @@ class MappingBase(Base): ...@@ -287,7 +280,7 @@ class MappingBase(Base):
d={} d={}
l=[] l=[]
for i in range(10000): for i in range(10000):
k=whrandom.randint(-2000, 2000) k=random.randrange(-2000, 2001)
d[k]=i d[k]=i
l.append((k, i)) l.append((k, i))
...@@ -396,7 +389,7 @@ class NormalSetTests(Base): ...@@ -396,7 +389,7 @@ class NormalSetTests(Base):
d={} d={}
l=[] l=[]
for i in range(10000): for i in range(10000):
k=whrandom.randint(-2000, 2000) k=random.randrange(-2000, 2001)
d[k]=i d[k]=i
l.append(k) l.append(k)
...@@ -502,7 +495,7 @@ class BTreeTests(MappingBase): ...@@ -502,7 +495,7 @@ class BTreeTests(MappingBase):
added = {} added = {}
r = range(100) r = range(100)
for x in r: for x in r:
k = whrandom.choice(r) k = random.choice(r)
if not added.has_key(k): if not added.has_key(k):
self.t[k] = x self.t[k] = x
added[k] = 1 added[k] = 1
...@@ -515,7 +508,7 @@ class BTreeTests(MappingBase): ...@@ -515,7 +508,7 @@ class BTreeTests(MappingBase):
added = {} added = {}
r = range(100) r = range(100)
for x in r: for x in r:
k = whrandom.choice(r) k = random.choice(r)
self.t[k] = x self.t[k] = x
added[k] = 1 added[k] = 1
addl = added.keys() addl = added.keys()
...@@ -527,12 +520,12 @@ class BTreeTests(MappingBase): ...@@ -527,12 +520,12 @@ class BTreeTests(MappingBase):
r = range(1000) r = range(1000)
added = [] added = []
for x in r: for x in r:
k = whrandom.choice(r) k = random.choice(r)
self.t[k] = x self.t[k] = x
added.append(k) added.append(k)
deleted = [] deleted = []
for x in r: for x in r:
k = whrandom.choice(r) k = random.choice(r)
if self.t.has_key(k): if self.t.has_key(k):
del self.t[k] del self.t[k]
deleted.append(k) deleted.append(k)
...@@ -547,7 +540,7 @@ class BTreeTests(MappingBase): ...@@ -547,7 +540,7 @@ class BTreeTests(MappingBase):
def testTargetedDeletes(self): def testTargetedDeletes(self):
r = range(1000) r = range(1000)
for x in r: for x in r:
k = whrandom.choice(r) k = random.choice(r)
self.t[k] = x self.t[k] = x
for x in r: for x in r:
try: try:
...@@ -634,7 +627,7 @@ class BTreeTests(MappingBase): ...@@ -634,7 +627,7 @@ class BTreeTests(MappingBase):
r = range(100) r = range(100)
a = {} a = {}
for x in r: for x in r:
rnd = whrandom.choice(r) rnd = random.choice(r)
self.t[rnd] = 0 self.t[rnd] = 0
a[rnd] = 0 a[rnd] = 0
diff = lsubtract(list(self.t.keys(0, 100)), a.keys()) diff = lsubtract(list(self.t.keys(0, 100)), a.keys())
......
...@@ -82,14 +82,7 @@ ...@@ -82,14 +82,7 @@
# attributions are listed in the accompanying credits file. # attributions are listed in the accompanying credits file.
# #
############################################################################## ##############################################################################
import sys, os, time, whrandom import sys, os, time, random
try:
sys.path.insert(0, '.')
import ZODB
except:
sys.path.insert(0, '../..')
import ZODB
from BTrees.OOBTree import OOBTree, OOBucket, OOSet, OOTreeSet from BTrees.OOBTree import OOBTree, OOBucket, OOSet, OOTreeSet
from BTrees.IOBTree import IOBTree, IOBucket, IOSet, IOTreeSet from BTrees.IOBTree import IOBTree, IOBucket, IOSet, IOTreeSet
...@@ -129,18 +122,18 @@ class MappingBase(Base): ...@@ -129,18 +122,18 @@ class MappingBase(Base):
base=self.t base=self.t
d={} d={}
for i in range(20): for i in range(20):
d[whrandom.randint(-10000, 10000)]=i*100000 d[random.randrange(-10000, 10001)]=i*100000
e1={} e1={}
while len(e1) < 5: while len(e1) < 5:
k=whrandom.randint(-10000, 10000) k=random.randrange(-10000, 10001)
if not d.has_key(k): if not d.has_key(k):
e1[k]=len(e1) e1[k]=len(e1)
e1=e1.items() e1=e1.items()
e2={} e2={}
while len(e2) < 5: 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): if not d.has_key(k) and not e2.has_key(k):
e2[k]=len(e2) e2[k]=len(e2)
e2=e2.items() e2=e2.items()
...@@ -280,18 +273,18 @@ class ExtendedSetTests(NormalSetTests): ...@@ -280,18 +273,18 @@ class ExtendedSetTests(NormalSetTests):
base=self.t base=self.t
d={} d={}
for i in range(20): for i in range(20):
d[whrandom.randint(-10000, 10000)]=i*100000 d[random.randrange(-10000, 10001)]=i*100000
e1={} e1={}
while len(e1) < 5: while len(e1) < 5:
k=whrandom.randint(-10000, 10000) k=random.randrange(-10000, 10001)
if not d.has_key(k): if not d.has_key(k):
e1[k]=len(e1) e1[k]=len(e1)
e1=e1.keys() e1=e1.keys()
e2={} e2={}
while len(e2) < 5: 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): if not d.has_key(k) and not e2.has_key(k):
e2[k]=len(e2) e2[k]=len(e2)
e2=e2.keys() 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