summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_bisect.py
diff options
context:
space:
mode:
authorRaymond Hettinger <python@rcn.com>2008-07-10 14:03:19 (GMT)
committerRaymond Hettinger <python@rcn.com>2008-07-10 14:03:19 (GMT)
commit3cd1e42dca01308a9f5897ba2efc2aab0bebb661 (patch)
tree8950458b1bb3e598da4dc22edbbd610ad5e75bfc /Lib/test/test_bisect.py
parentd2cd86ddd5c3d90911a98a1440563118297e45db (diff)
downloadcpython-3cd1e42dca01308a9f5897ba2efc2aab0bebb661.zip
cpython-3cd1e42dca01308a9f5897ba2efc2aab0bebb661.tar.gz
cpython-3cd1e42dca01308a9f5897ba2efc2aab0bebb661.tar.bz2
Issue 3301: Bisect functions behaved badly when lo was negative.
Diffstat (limited to 'Lib/test/test_bisect.py')
-rw-r--r--Lib/test/test_bisect.py8
1 files changed, 8 insertions, 0 deletions
diff --git a/Lib/test/test_bisect.py b/Lib/test/test_bisect.py
index fb490b7..7776cc8 100644
--- a/Lib/test/test_bisect.py
+++ b/Lib/test/test_bisect.py
@@ -114,6 +114,14 @@ class TestBisect(unittest.TestCase):
self.assertEqual(func(data, elem), expected)
self.assertEqual(func(UserList(data), elem), expected)
+ def test_negative_lo(self):
+ # Issue 3301
+ mod = self.module
+ self.assertRaises(ValueError, mod.bisect_left, [1, 2, 3], 5, -1, 3),
+ self.assertRaises(ValueError, mod.bisect_right, [1, 2, 3], 5, -1, 3),
+ self.assertRaises(ValueError, mod.insort_left, [1, 2, 3], 5, -1, 3),
+ self.assertRaises(ValueError, mod.insort_right, [1, 2, 3], 5, -1, 3),
+
def test_random(self, n=25):
from random import randrange
for i in xrange(n):