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

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

Issue 25958: Implicit ABCs have no means of "anti-registration"
Left Patch Set: Created 4 years, 1 month ago
Right Patch Set: Created 3 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_contains.py ('k') | Lib/test/test_iter.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 unittest 1 import unittest
2 import operator 2 import operator
3 import sys 3 import sys
4 import pickle 4 import pickle
5 5
6 from test import support 6 from test import support
7 7
8 class G: 8 class G:
9 'Sequence using __getitem__' 9 'Sequence using __getitem__'
10 def __init__(self, seqn): 10 def __init__(self, seqn):
(...skipping 205 matching lines...) Expand 10 before | Expand all | Expand 10 after
216 reversed(f) 216 reversed(f)
217 except TypeError: 217 except TypeError:
218 pass 218 pass
219 else: 219 else:
220 self.fail("non-callable __reversed__ didn't raise!") 220 self.fail("non-callable __reversed__ didn't raise!")
221 self.assertEqual(rc, sys.getrefcount(r)) 221 self.assertEqual(rc, sys.getrefcount(r))
222 222
223 def test_objmethods(self): 223 def test_objmethods(self):
224 # Objects must have __len__() and __getitem__() implemented. 224 # Objects must have __len__() and __getitem__() implemented.
225 class NoLen(object): 225 class NoLen(object):
226 def __getitem__(self): return 1 226 def __getitem__(self, i): return 1
227 nl = NoLen() 227 nl = NoLen()
228 self.assertRaises(TypeError, reversed, nl) 228 self.assertRaises(TypeError, reversed, nl)
229 229
230 class NoGetItem(object): 230 class NoGetItem(object):
231 def __len__(self): return 2 231 def __len__(self): return 2
232 ngi = NoGetItem() 232 ngi = NoGetItem()
233 self.assertRaises(TypeError, reversed, ngi) 233 self.assertRaises(TypeError, reversed, ngi)
234 234
235 class Blocked(object): 235 class Blocked(object):
236 def __getitem__(self): return 1 236 def __getitem__(self, i): return 1
237 def __len__(self): return 2 237 def __len__(self): return 2
238 __reversed__ = None 238 __reversed__ = None
239 b = Blocked() 239 b = Blocked()
240 self.assertRaises(TypeError, reversed, b) 240 self.assertRaises(TypeError, reversed, b)
241 241
242 def test_pickle(self): 242 def test_pickle(self):
243 for data in 'abc', range(5), tuple(enumerate('abc')), range(1,17,5): 243 for data in 'abc', range(5), tuple(enumerate('abc')), range(1,17,5):
244 self.check_pickle(reversed(data), list(data)[::-1]) 244 self.check_pickle(reversed(data), list(data)[::-1])
245 245
246 246
(...skipping 13 matching lines...) Expand all
260 260
261 class TestLongStart(EnumerateStartTestCase): 261 class TestLongStart(EnumerateStartTestCase):
262 262
263 enum = lambda self, i: enumerate(i, start=sys.maxsize+1) 263 enum = lambda self, i: enumerate(i, start=sys.maxsize+1)
264 seq, res = 'abc', [(sys.maxsize+1,'a'), (sys.maxsize+2,'b'), 264 seq, res = 'abc', [(sys.maxsize+1,'a'), (sys.maxsize+2,'b'),
265 (sys.maxsize+3,'c')] 265 (sys.maxsize+3,'c')]
266 266
267 267
268 if __name__ == "__main__": 268 if __name__ == "__main__":
269 unittest.main() 269 unittest.main()
LEFTRIGHT

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