[Zope-Checkins] CVS: Zope/lib/python/BTrees/tests - testBTrees.py:1.39
Tim Peters
tim.one@comcast.net
Thu, 13 Jun 2002 15:19:42 -0400
Update of /cvs-repository/Zope/lib/python/BTrees/tests
In directory cvs.zope.org:/tmp/cvs-serv18023/tests
Modified Files:
testBTrees.py
Log Message:
Bucket_rangeSearch(): If the min key passed in was larger than the max key
passed in, it was quite possible for this to return *low > *high, and the
caller could crash due to trying to create a list with "negative length".
Changed the routine to consider a range empty if min>max on input, and added
test cases that fail before this patch.
=== Zope/lib/python/BTrees/tests/testBTrees.py 1.38 => 1.39 ===
def testEmptyRangeSearches(self):
- t=self.t
- t.update([(1,1),(5,5),(9,9)])
- self.assertEqual(list(t.keys(-6,-4)),[], list(t.keys(-6,-4)))
- self.assertEqual(list(t.keys(2,4)),[], list(t.keys(2,4)))
- self.assertEqual(list(t.keys(6,8)),[], list(t.keys(6,8)))
- self.assertEqual(list(t.keys(10,12)),[], list(t.keys(10,12)))
+ t = self.t
+ t.update([(1,1), (5,5), (9,9)])
+ self.assertEqual(list(t.keys(-6,-4)), [], list(t.keys(-6,-4)))
+ self.assertEqual(list(t.keys(2,4)), [], list(t.keys(2,4)))
+ self.assertEqual(list(t.keys(6,8)), [], list(t.keys(6,8)))
+ self.assertEqual(list(t.keys(10,12)), [], list(t.keys(10,12)))
+ self.assertEqual(list(t.keys(9, 1)), [], list(t.keys(9, 1)))
def testSlicing(self):
# Test that slicing of .keys()/.values()/.items() works exactly the
@@ -421,12 +422,13 @@
self.assertEqual(list(self.t.keys()) , items)
def testEmptyRangeSearches(self):
- t=self.t
- t.update([1,5,9])
- self.assertEqual(list(t.keys(-6,-4)),[], list(t.keys(-6,-4)))
- self.assertEqual(list(t.keys(2,4)),[], list(t.keys(2,4)))
- self.assertEqual(list(t.keys(6,8)),[], list(t.keys(6,8)))
- self.assertEqual(list(t.keys(10,12)),[], list(t.keys(10,12)))
+ t = self.t
+ t.update([1, 5, 9])
+ self.assertEqual(list(t.keys(-6,-4)), [], list(t.keys(-6,-4)))
+ self.assertEqual(list(t.keys(2,4)), [], list(t.keys(2,4)))
+ self.assertEqual(list(t.keys(6,8)), [], list(t.keys(6,8)))
+ self.assertEqual(list(t.keys(10,12)), [], list(t.keys(10,12)))
+ self.assertEqual(list(t.keys(9,1)), [], list(t.keys(9,1)))
def testSlicing(self):
# Test that slicing of .keys() works exactly the same way as slicing