[Zodb-checkins] CVS: Zope3/lib/python/Persistence/BTrees/tests - testConflict.py:1.1.2.3
Jim Fulton
jim@zope.com
Wed, 27 Feb 2002 18:23:54 -0500
Update of /cvs-repository/Zope3/lib/python/Persistence/BTrees/tests
In directory cvs.zope.org:/tmp/cvs-serv30894
Modified Files:
Tag: Zope-3x-branch
testConflict.py
Log Message:
Fixed the tests to use constant randon data, rather than dynamically
chosen random data. The tests were occasionally failing before because
we'd get unlucky and have data that we tought should be resolvable but
wasn't.
=== Zope3/lib/python/Persistence/BTrees/tests/testConflict.py 1.1.2.2 => 1.1.2.3 ===
##############################################################################
import os
-import random
from Persistence.BTrees.OOBTree import OOBTree, OOBucket, OOSet, OOTreeSet
from Persistence.BTrees.IOBTree import IOBTree, IOBucket, IOSet, IOTreeSet
@@ -51,26 +50,18 @@
del self.t[1]
def _setupConflict(self):
- base=self.t
- d={}
- for i in range(20):
- d[random.randrange(-10000, 10001)]=i*100000
-
- e1={}
- while len(e1) < 5:
- k=random.randrange(-10000, 10001)
- if not d.has_key(k):
- e1[k]=len(e1)
- e1=e1.items()
-
- e2={}
- while len(e2) < 5:
- k=random.randrange(-10000, 10001)
- if not d.has_key(k) and not e2.has_key(k):
- e2[k]=len(e2)
- e2=e2.items()
+
+ l=[ -5124, -7377, 2274, 8801, -9901, 7327, 1565, 17, -679,
+ 3686, -3607, 14, 6419, -5637, 6040, -4556, -8622, 3847, 7191,
+ -4067]
+
+
+ e1=[(-1704, 0), (5420, 1), (-239, 2), (4024, 3), (-6984, 4)]
+ e2=[(7745, 0), (4868, 1), (-2548, 2), (-2711, 3), (-3154, 4)]
- base.update(d)
+
+ base=self.t
+ base.update([(i, i*i) for i in l[:20]])
b1=base.__class__(base)
b2=base.__class__(base)
bm=base.__class__(base)
@@ -201,32 +192,22 @@
class ExtendedSetTests(NormalSetTests):
"Set (as opposed to TreeSet) specific tests."
- def _setupConflict(self):
- base = self.t
- d={}
- for i in range(20):
- d[random.randrange(-10000, 10001)]=i*100000
-
- e1={}
- while len(e1) < 5:
- k=random.randrange(-10000, 10001)
- if not d.has_key(k):
- e1[k]=len(e1)
- e1=e1.keys()
-
- e2={}
- while len(e2) < 5:
- k=random.randrange(-10000, 10001)
- if not d.has_key(k) and not e2.has_key(k):
- e2[k]=len(e2)
- e2=e2.keys()
-
- base.update(d.keys())
- b1 = base.__class__(base)
- b2 = base.__class__(base)
- bm = base.__class__(base)
+ def _setupConflict(self):
+ l=[ -5124, -7377, 2274, 8801, -9901, 7327, 1565, 17, -679,
+ 3686, -3607, 14, 6419, -5637, 6040, -4556, -8622, 3847, 7191,
+ -4067]
+
+ e1=[-1704, 5420, -239, 4024, -6984]
+ e2=[7745, 4868, -2548, -2711, -3154]
+
+
+ base=self.t
+ base.update(l)
+ b1=base.__class__(base)
+ b2=base.__class__(base)
+ bm=base.__class__(base)
- items = base.keys()
+ items=base.keys()
return base, b1, b2, bm, e1, e2, items