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

Side by Side Diff: Lib/test/test_slice.py

Issue 16510: Using appropriate checks in tests
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:
View unified diff | Download patch
« no previous file with comments | « Lib/test/test_shutil.py ('k') | Lib/test/test_socket.py » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 # tests for slice objects; in particular the indices method. 1 # tests for slice objects; in particular the indices method.
2 2
3 import unittest 3 import unittest
4 from test import support 4 from test import support
5 from pickle import loads, dumps 5 from pickle import loads, dumps
6 6
7 import itertools 7 import itertools
8 import operator 8 import operator
9 import sys 9 import sys
10 10
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after
128 s = slice(1, 2, 3) 128 s = slice(1, 2, 3)
129 self.assertEqual(s.start, 1) 129 self.assertEqual(s.start, 1)
130 self.assertEqual(s.stop, 2) 130 self.assertEqual(s.stop, 2)
131 self.assertEqual(s.step, 3) 131 self.assertEqual(s.step, 3)
132 132
133 class AnyClass: 133 class AnyClass:
134 pass 134 pass
135 135
136 obj = AnyClass() 136 obj = AnyClass()
137 s = slice(obj) 137 s = slice(obj)
138 self.assertTrue(s.stop is obj) 138 self.assertIs(s.stop, obj)
139 139
140 def check_indices(self, slice, length): 140 def check_indices(self, slice, length):
141 try: 141 try:
142 actual = slice.indices(length) 142 actual = slice.indices(length)
143 except ValueError: 143 except ValueError:
144 actual = "valueerror" 144 actual = "valueerror"
145 try: 145 try:
146 expected = slice_indices(slice, length) 146 expected = slice_indices(slice, length)
147 except ValueError: 147 except ValueError:
148 expected = "valueerror" 148 expected = "valueerror"
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after
238 t = loads(dumps(s, protocol)) 238 t = loads(dumps(s, protocol))
239 self.assertEqual(s, t) 239 self.assertEqual(s, t)
240 self.assertEqual(s.indices(15), t.indices(15)) 240 self.assertEqual(s.indices(15), t.indices(15))
241 self.assertNotEqual(id(s), id(t)) 241 self.assertNotEqual(id(s), id(t))
242 242
243 def test_main(): 243 def test_main():
244 support.run_unittest(SliceTest) 244 support.run_unittest(SliceTest)
245 245
246 if __name__ == "__main__": 246 if __name__ == "__main__":
247 test_main() 247 test_main()
OLDNEW
« no previous file with comments | « Lib/test/test_shutil.py ('k') | Lib/test/test_socket.py » ('j') | no next file with comments »

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