mirror of https://github.com/python/cpython
Test optional slice arguments.
Add backwards compatibility test.
This commit is contained in:
parent
4422375c72
commit
a9f18dc0f0
|
@ -1,9 +1,6 @@
|
||||||
import unittest
|
import unittest
|
||||||
from test import test_support
|
from test import test_support
|
||||||
from bisect import bisect_right, bisect_left, insort_left, insort_right
|
from bisect import bisect_right, bisect_left, insort_left, insort_right, insort, bisect
|
||||||
|
|
||||||
# XXX optional slice arguments need tests.
|
|
||||||
|
|
||||||
|
|
||||||
class TestBisect(unittest.TestCase):
|
class TestBisect(unittest.TestCase):
|
||||||
|
|
||||||
|
@ -110,6 +107,16 @@ class TestBisect(unittest.TestCase):
|
||||||
if ip > 0:
|
if ip > 0:
|
||||||
self.failUnless(data[ip-1] <= elem)
|
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):
|
class TestInsort(unittest.TestCase):
|
||||||
|
@ -131,6 +138,9 @@ class TestInsort(unittest.TestCase):
|
||||||
sorted.sort()
|
sorted.sort()
|
||||||
self.assertEqual(sorted, insorted)
|
self.assertEqual(sorted, insorted)
|
||||||
|
|
||||||
|
def test_backcompatibility(self):
|
||||||
|
self.assertEqual(insort, insort_right)
|
||||||
|
|
||||||
#==============================================================================
|
#==============================================================================
|
||||||
|
|
||||||
libreftest = """
|
libreftest = """
|
||||||
|
|
Loading…
Reference in New Issue