Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(89431)

Delta Between Two Patch Sets: Lib/test/test_bisect.py

Issue 16510: Using appropriate checks in tests
Left Patch Set: Created 5 years, 12 months ago
Right Patch Set: Created 5 years, 6 months ago
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments. Please Sign in to add in-line comments.
Jump to:
Left: Side by side diff | Download
Right: Side by side diff | Download
« no previous file with change/comment | « Lib/test/test_binop.py ('k') | Lib/test/test_buffer.py » ('j') | no next file with change/comment »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
LEFTRIGHT
1 import sys 1 import sys
2 import unittest 2 import unittest
3 from test import support 3 from test import support
4 from collections import UserList 4 from collections import UserList
5 5
6 py_bisect = support.import_fresh_module('bisect', blocked=['_bisect']) 6 py_bisect = support.import_fresh_module('bisect', blocked=['_bisect'])
7 c_bisect = support.import_fresh_module('bisect', fresh=['_bisect']) 7 c_bisect = support.import_fresh_module('bisect', fresh=['_bisect'])
8 8
9 class Range(object): 9 class Range(object):
10 """A trivial range()-like object without any integer width limitations.""" 10 """A trivial range()-like object that has an insert() method."""
11 def __init__(self, start, stop): 11 def __init__(self, start, stop):
12 self.start = start 12 self.start = start
13 self.stop = stop 13 self.stop = stop
14 self.last_insert = None 14 self.last_insert = None
15 15
16 def __len__(self): 16 def __len__(self):
17 return self.stop - self.start 17 return self.stop - self.start
18 18
19 def __getitem__(self, idx): 19 def __getitem__(self, idx):
20 n = self.stop - self.start 20 n = self.stop - self.start
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after
113 ] 113 ]
114 114
115 def test_precomputed(self): 115 def test_precomputed(self):
116 for func, data, elem, expected in self.precomputedCases: 116 for func, data, elem, expected in self.precomputedCases:
117 self.assertEqual(func(data, elem), expected) 117 self.assertEqual(func(data, elem), expected)
118 self.assertEqual(func(UserList(data), elem), expected) 118 self.assertEqual(func(UserList(data), elem), expected)
119 119
120 def test_negative_lo(self): 120 def test_negative_lo(self):
121 # Issue 3301 121 # Issue 3301
122 mod = self.module 122 mod = self.module
123 self.assertRaises(ValueError, mod.bisect_left, [1, 2, 3], 5, -1, 3), 123 self.assertRaises(ValueError, mod.bisect_left, [1, 2, 3], 5, -1, 3)
124 self.assertRaises(ValueError, mod.bisect_right, [1, 2, 3], 5, -1, 3), 124 self.assertRaises(ValueError, mod.bisect_right, [1, 2, 3], 5, -1, 3)
125 self.assertRaises(ValueError, mod.insort_left, [1, 2, 3], 5, -1, 3), 125 self.assertRaises(ValueError, mod.insort_left, [1, 2, 3], 5, -1, 3)
126 self.assertRaises(ValueError, mod.insort_right, [1, 2, 3], 5, -1, 3), 126 self.assertRaises(ValueError, mod.insort_right, [1, 2, 3], 5, -1, 3)
127 127
128 def test_large_range(self): 128 def test_large_range(self):
129 # Issue 13496 129 # Issue 13496
130 mod = self.module 130 mod = self.module
131 n = sys.maxsize 131 n = sys.maxsize
132 data = range(n-1) 132 data = range(n-1)
133 self.assertEqual(mod.bisect_left(data, n-3), n-3) 133 self.assertEqual(mod.bisect_left(data, n-3), n-3)
134 self.assertEqual(mod.bisect_right(data, n-3), n-2) 134 self.assertEqual(mod.bisect_right(data, n-3), n-2)
135 self.assertEqual(mod.bisect_left(data, n-3, n-10, n), n-3) 135 self.assertEqual(mod.bisect_left(data, n-3, n-10, n), n-3)
136 self.assertEqual(mod.bisect_right(data, n-3, n-10, n), n-2) 136 self.assertEqual(mod.bisect_right(data, n-3, n-10, n), n-2)
(...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after
319 class TestDocExamplePython(TestDocExample, unittest.TestCase): 319 class TestDocExamplePython(TestDocExample, unittest.TestCase):
320 module = py_bisect 320 module = py_bisect
321 321
322 class TestDocExampleC(TestDocExample, unittest.TestCase): 322 class TestDocExampleC(TestDocExample, unittest.TestCase):
323 module = c_bisect 323 module = c_bisect
324 324
325 #------------------------------------------------------------------------------ 325 #------------------------------------------------------------------------------
326 326
327 if __name__ == "__main__": 327 if __name__ == "__main__":
328 unittest.main() 328 unittest.main()
LEFTRIGHT

RSS Feeds Recent Issues | This issue
This is Rietveld 894c83f36cb7+