[Zodb-checkins] CVS: Zope/lib/python/BTrees/tests - testSetOps.py:1.4

Tim Peters tim.one@comcast.net
Mon, 3 Jun 2002 13:45:10 -0400


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

Modified Files:
	testSetOps.py 
Log Message:
nextKeyAsSet():  Simplified the code.  Added a new test to exercise it.


=== Zope/lib/python/BTrees/tests/testSetOps.py 1.3 => 1.4 ===
         self.assertEqual(list(output), range(-N, 3*N))
 
+    def testFunkyKeyIteration(self):
+        # The internal set iteration protocol allows "iterating over" a
+        # a single key as if it were a set.
+        N = 100
+        slow = IISet()
+        for i in range(N):
+            slow = union(slow, IISet([i]))
+        fast = multiunion(range(N))  # acts like N distinct singleton sets
+        self.assertEqual(len(slow), N)
+        self.assertEqual(len(fast), N)
+        self.assertEqual(list(slow.keys()), list(fast.keys()))
+        self.assertEqual(list(fast.keys()), range(N))
+
 def test_suite():
     return makeSuite(TestMultiUnion, 'test')