[Zodb-checkins] CVS: Zope/lib/python/BTrees/tests - testBTrees.py:1.27.6.1

Toby Dickenson tdickenson@geminidataloggers.com
Mon, 11 Mar 2002 04:47:12 -0500


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

Modified Files:
      Tag: toby-cmp-error-branch
	testBTrees.py 
Log Message:
Collector #231: BTrees ignoring errors from comparison function

=== Zope/lib/python/BTrees/tests/testBTrees.py 1.27 => 1.27.6.1 ===
         self.t = OIBucket()
 
+# cmp error propagation tests
+
+class DoesntLikeBeingCompared:
+    def __cmp__(self,other):
+        raise ValueError('incomparable')
+
+class TestCmpError(TestCase):
+    def testFoo(self):
+        t = OOBTree()
+        t['hello world'] = None
+        try:
+            t[DoesntLikeBeingCompared()] = None
+        except ValueError,e:
+            assert str(e)=='incomparable'
+        else:
+            raise ValueError('incomarable objects should not be allowed into the tree')
+
 def test_suite():
     TIOBTree = makeSuite(TestIOBTrees, 'test')
     TOOBTree = makeSuite(TestOOBTrees, 'test')
@@ -747,11 +764,13 @@
     TOOBucket = makeSuite(TestOOBuckets, 'test')
     TOIBucket = makeSuite(TestOIBuckets, 'test')
     TIIBucket = makeSuite(TestIIBuckets, 'test')
-    
+
     alltests = TestSuite((TIOSet, TOOSet, TOISet, TIISet,
                           TIOTreeSet, TOOTreeSet, TOITreeSet, TIITreeSet,
                           TIOBucket, TOOBucket, TOIBucket, TIIBucket,
-                          TOOBTree, TIOBTree, TOIBTree, TIIBTree))
+                          TOOBTree, TIOBTree, TOIBTree, TIIBTree,
+                          makeSuite(TestCmpError),
+                         ))
 
     return alltests