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

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

Issue 10639: reindent.py converts newlines to platform default
Patch Set: Created 8 years, 8 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_exceptions.py ('k') | Lib/test/test_faulthandler.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 1
2 """Doctest for method/function calls. 2 """Doctest for method/function calls.
3 3
4 We're going the use these types for extra testing 4 We're going the use these types for extra testing
5 5
6 >>> from collections import UserList 6 >>> from collections import UserList
7 >>> from collections import UserDict 7 >>> from collections import UserDict
8 8
9 We're defining four helper functions 9 We're defining four helper functions
10 10
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
59 Verify clearing of SF bug #733667 59 Verify clearing of SF bug #733667
60 60
61 >>> e(c=4) 61 >>> e(c=4)
62 Traceback (most recent call last): 62 Traceback (most recent call last):
63 ... 63 ...
64 TypeError: e() got an unexpected keyword argument 'c' 64 TypeError: e() got an unexpected keyword argument 'c'
65 65
66 >>> g() 66 >>> g()
67 Traceback (most recent call last): 67 Traceback (most recent call last):
68 ... 68 ...
69 TypeError: g() missing 1 required positional argument: 'x' 69 TypeError: g() takes at least 1 positional argument but 0 were given
70 70
71 >>> g(*()) 71 >>> g(*())
72 Traceback (most recent call last): 72 Traceback (most recent call last):
73 ... 73 ...
74 TypeError: g() missing 1 required positional argument: 'x' 74 TypeError: g() takes at least 1 positional argument but 0 were given
75 75
76 >>> g(*(), **{}) 76 >>> g(*(), **{})
77 Traceback (most recent call last): 77 Traceback (most recent call last):
78 ... 78 ...
79 TypeError: g() missing 1 required positional argument: 'x' 79 TypeError: g() takes at least 1 positional argument but 0 were given
80 80
81 >>> g(1) 81 >>> g(1)
82 1 () {} 82 1 () {}
83 >>> g(1, 2) 83 >>> g(1, 2)
84 1 (2,) {} 84 1 (2,) {}
85 >>> g(1, 2, 3) 85 >>> g(1, 2, 3)
86 1 (2, 3) {} 86 1 (2, 3) {}
87 >>> g(1, 2, 3, *(4, 5)) 87 >>> g(1, 2, 3, *(4, 5))
88 1 (2, 3, 4, 5) {} 88 1 (2, 3, 4, 5) {}
89 89
(...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after
256 ... return str.__eq__(self, other) 256 ... return str.__eq__(self, other)
257 ... def __hash__(self): 257 ... def __hash__(self):
258 ... return str.__hash__(self) 258 ... return str.__hash__(self)
259 259
260 >>> x = {Name("a"):1, Name("b"):2} 260 >>> x = {Name("a"):1, Name("b"):2}
261 >>> def f(a, b): 261 >>> def f(a, b):
262 ... print(a,b) 262 ... print(a,b)
263 >>> f(**x) 263 >>> f(**x)
264 1 2 264 1 2
265 265
266 Too many arguments: 266 Some additional tests about positional argument errors:
267 267
268 >>> def f(): pass 268 >>> def f(a, b):
269 ... pass
270 >>> f(b=1)
271 Traceback (most recent call last):
272 ...
273 TypeError: f() takes 2 positional arguments but 1 was given
274
275 >>> def f(a):
276 ... pass
277 >>> f(6, a=4, *(1, 2, 3))
278 Traceback (most recent call last):
279 ...
280 TypeError: f() got multiple values for argument 'a'
281 >>> def f(a, *, kw):
282 ... pass
283 >>> f(6, 4, kw=4)
284 Traceback (most recent call last):
285 ...
286 TypeError: f() takes 1 positional argument but 2 positional arguments (and 1 keyword-only argument) were given
287
288 >>> def f(a):
289 ... pass
290 >>> f()
291 Traceback (most recent call last):
292 ...
293 TypeError: f() takes 1 positional argument but 0 were given
294
295 >>> def f(a, b):
296 ... pass
269 >>> f(1) 297 >>> f(1)
270 Traceback (most recent call last): 298 Traceback (most recent call last):
271 ... 299 ...
272 TypeError: f() takes 0 positional arguments but 1 was given 300 TypeError: f() takes 2 positional arguments but 1 was given
273 >>> def f(a): pass 301
274 >>> f(1, 2) 302 >>> def f(a, *b):
303 ... pass
304 >>> f()
275 Traceback (most recent call last): 305 Traceback (most recent call last):
276 ... 306 ...
277 TypeError: f() takes 1 positional argument but 2 were given 307 TypeError: f() takes at least 1 positional argument but 0 were given
278 >>> def f(a, b=1): pass 308
279 >>> f(1, 2, 3) 309 >>> def f(a, *, kw=4):
310 ... pass
311 >>> f(kw=4)
280 Traceback (most recent call last): 312 Traceback (most recent call last):
281 ... 313 ...
282 TypeError: f() takes from 1 to 2 positional arguments but 3 were given 314 TypeError: f() takes 1 positional argument but 0 positional arguments (and 1 keyword-only argument) were given
283 >>> def f(*, kw): pass 315
284 >>> f(1, kw=3) 316 >>> def f(a, b=2):
317 ... pass
318 >>> f()
319 Traceback (most recent call last):
320 ...
321 TypeError: f() takes from 1 to 2 positional arguments but 0 were given
322
323 >>> def f(a, *b):
324 ... pass
325 >>> f()
326 Traceback (most recent call last):
327 ...
328 TypeError: f() takes at least 1 positional argument but 0 were given
329
330 >>> def f(*, kw):
331 ... pass
332 >>> f(3, kw=4)
285 Traceback (most recent call last): 333 Traceback (most recent call last):
286 ... 334 ...
287 TypeError: f() takes 0 positional arguments but 1 positional argument (and 1 keyword-only argument) were given 335 TypeError: f() takes 0 positional arguments but 1 positional argument (and 1 keyword-only argument) were given
288 >>> def f(*, kw, b): pass
289 >>> f(1, 2, 3, b=3, kw=3)
290 Traceback (most recent call last):
291 ...
292 TypeError: f() takes 0 positional arguments but 3 positional arguments (and 2 keyword-only arguments) were given
293 >>> def f(a, b=2, *, kw): pass
294 >>> f(2, 3, 4, kw=4)
295 Traceback (most recent call last):
296 ...
297 TypeError: f() takes from 1 to 2 positional arguments but 3 positional argum ents (and 1 keyword-only argument) were given
298 336
299 Too few and missing arguments: 337 >>> def f(a, c=3, *b, kw):
300 338 ... pass
301 >>> def f(a): pass
302 >>> f() 339 >>> f()
303 Traceback (most recent call last): 340 Traceback (most recent call last):
304 ... 341 ...
305 TypeError: f() missing 1 required positional argument: 'a' 342 TypeError: f() takes at least 1 positional argument but 0 were given
306 >>> def f(a, b): pass 343 >>> f(kw=3)
307 >>> f()
308 Traceback (most recent call last): 344 Traceback (most recent call last):
309 ... 345 ...
310 TypeError: f() missing 2 required positional arguments: 'a' and 'b' 346 TypeError: f() takes at least 1 positional argument but 0 positional argumen ts (and 1 keyword-only argument) were given
311 >>> def f(a, b, c): pass 347 >>> f(kw=3, c=4)
312 >>> f()
313 Traceback (most recent call last): 348 Traceback (most recent call last):
314 ... 349 ...
315 TypeError: f() missing 3 required positional arguments: 'a', 'b', and 'c' 350 TypeError: f() takes at least 1 positional argument but 1 positional argumen t (and 1 keyword-only argument) were given
316 >>> def f(a, b, c, d, e): pass
317 >>> f()
318 Traceback (most recent call last):
319 ...
320 TypeError: f() missing 5 required positional arguments: 'a', 'b', 'c', 'd', and 'e'
321 >>> def f(a, b=4, c=5, d=5): pass
322 >>> f(c=12, b=9)
323 Traceback (most recent call last):
324 ...
325 TypeError: f() missing 1 required positional argument: 'a'
326
327 Same with keyword only args:
328
329 >>> def f(*, w): pass
330 >>> f()
331 Traceback (most recent call last):
332 ...
333 TypeError: f() missing 1 required keyword-only argument: 'w'
334 >>> def f(*, a, b, c, d, e): pass
335 >>> f()
336 Traceback (most recent call last):
337 ...
338 TypeError: f() missing 5 required keyword-only arguments: 'a', 'b', 'c', 'd' , and 'e'
339
340 """ 351 """
341 352
342 import sys 353 import sys
343 from test import support 354 from test import support
344 355
345 def test_main(): 356 def test_main():
346 support.run_doctest(sys.modules[__name__], True) 357 support.run_doctest(sys.modules[__name__], True)
347 358
348 if __name__ == '__main__': 359 if __name__ == '__main__':
349 test_main() 360 test_main()
OLDNEW
« no previous file with comments | « Lib/test/test_exceptions.py ('k') | Lib/test/test_faulthandler.py » ('j') | no next file with comments »

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