[Zope-Checkins] CVS: Zope3/lib/python/Persistence/BTrees/tests - testBTrees.py:1.18

Tim Peters tim.one@comcast.net
Fri, 28 Jun 2002 02:40:46 -0400


Update of /cvs-repository/Zope3/lib/python/Persistence/BTrees/tests
In directory cvs.zope.org:/tmp/cvs-serv344/tests

Modified Files:
	testBTrees.py 
Log Message:
update_from_seq():  The test
    if (!n == 2)
can never succeed, because "!" binds more tightly than "==".  A core dump
was the result.  Fixed that, via testing n != 2 instead.

testBadUpdateTupleSize():  New test to provoke the failure modes due to
the above.


=== Zope3/lib/python/Persistence/BTrees/tests/testBTrees.py 1.17 => 1.18 ===
                             self.assertEqual(gooditems, list(got))
 
+    def testBadUpdateTupleSize(self):
+        # This one silently ignored the excess in Zope3.
+        try:
+            self.t.update([(1, 2, 3)])
+        except TypeError:
+            pass
+        else:
+            self.fail("update() with 3-tuple didn't complain")
+
+        # This one dumped core in Zope3.
+        try:
+            self.t.update([(1,)])
+        except TypeError:
+            pass
+        else:
+            self.fail("update() with 1-tuple didn't complain")
+
+        # This one should simply succeed.
+        self.t.update([(1, 2)])
+        self.assertEqual(list(self.t.items()), [(1, 2)])
+
+
 class NormalSetTests(Base):
     """ Test common to all set types """