summaryrefslogtreecommitdiff
path: root/Lib/test/test_bisect.py
diff options
context:
space:
mode:
authorRaymond Hettinger <python@rcn.com>2003-01-16 13:02:25 +0000
committerRaymond Hettinger <python@rcn.com>2003-01-16 13:02:25 +0000
commita9f18dc0f095cf7e8e00e57a135a88b0f6104f73 (patch)
tree4d6e8934980bdb0fa9f3c4bf53e08f31f30d67ba /Lib/test/test_bisect.py
parent4422375c72968173a4a22d1443903d4a0f19f269 (diff)
downloadcpython-git-a9f18dc0f095cf7e8e00e57a135a88b0f6104f73.tar.gz
Test optional slice arguments.
Add backwards compatibility test.
Diffstat (limited to 'Lib/test/test_bisect.py')
-rw-r--r--Lib/test/test_bisect.py18
1 files changed, 14 insertions, 4 deletions
diff --git a/Lib/test/test_bisect.py b/Lib/test/test_bisect.py
index 1a8b0eedfb..d641b538fb 100644
--- a/Lib/test/test_bisect.py
+++ b/Lib/test/test_bisect.py
@@ -1,9 +1,6 @@
import unittest
from test import test_support
-from bisect import bisect_right, bisect_left, insort_left, insort_right
-
-# XXX optional slice arguments need tests.
-
+from bisect import bisect_right, bisect_left, insort_left, insort_right, insort, bisect
class TestBisect(unittest.TestCase):
@@ -110,6 +107,16 @@ class TestBisect(unittest.TestCase):
if ip > 0:
self.failUnless(data[ip-1] <= elem)
+ def test_optionalSlicing(self):
+ for func, list, elt, expected in self.precomputedCases:
+ lo = min(len(list), 1)
+ self.failUnless(func(list, elt, lo=lo) >= lo)
+ hi = min(len(list), 2)
+ self.failUnless(func(list, elt, hi=hi) <= hi)
+
+ def test_backcompatibility(self):
+ self.assertEqual(bisect, bisect_right)
+
#==============================================================================
class TestInsort(unittest.TestCase):
@@ -131,6 +138,9 @@ class TestInsort(unittest.TestCase):
sorted.sort()
self.assertEqual(sorted, insorted)
+ def test_backcompatibility(self):
+ self.assertEqual(insort, insort_right)
+
#==============================================================================
libreftest = """