[Zope-Checkins] CVS: Zope3/lib/python/Persistence/BTrees/tests - testSetOps.py:1.5
Tim Peters
tim.one@comcast.net
Sun, 23 Jun 2002 17:15:48 -0400
Update of /cvs-repository/Zope3/lib/python/Persistence/BTrees/tests
In directory cvs.zope.org:/tmp/cvs-serv10350/tests
Modified Files:
testSetOps.py
Log Message:
Added some set operation tests on sets big enough to require more than
one bucket.
=== Zope3/lib/python/Persistence/BTrees/tests/testSetOps.py 1.4 => 1.5 ===
self.assertEqual(list(C), want)
+ def testLargerInputs(self):
+ from random import randint
+ MAXSIZE = 200
+ MAXVAL = 400
+ for i in range(3):
+ n = randint(0, MAXSIZE)
+ Akeys = [randint(1, MAXVAL) for j in range(n)]
+ As = [makeset(Akeys) for makeset in self.builders]
+ Akeys = IISet(Akeys)
+
+ n = randint(0, MAXSIZE)
+ Bkeys = [randint(1, MAXVAL) for j in range(n)]
+ Bs = [makeset(Bkeys) for makeset in self.builders]
+ Bkeys = IISet(Bkeys)
+
+ for op, simulator in ((self.union, self._union),
+ (self.intersection, self._intersection),
+ (self.difference, self._difference)):
+ for A in As:
+ for B in Bs:
+ got = op(A, B)
+ want = simulator(Akeys, Bkeys)
+ self.assertEqual(list(got), want,
+ (A, B, Akeys, Bkeys, list(got), want))
+
# Given a mapping builder (IIBTree, OOBucket, etc), return a function
# that builds an object of that type given only a list of keys.
def makeBuilder(mapbuilder):