1# mode: run 2# tag: kwargs, argument unpacking 3 4# This test validates the error handling in the different specialised 5# code paths of the argument unpacking code. The have-kwargs and 6# no-kwargs branches take different paths, so we always test with and 7# without a keyword dict (even if it's empty). 8 9def test_single_arg(a): 10 """ 11 >>> test_single_arg(1) 12 1 13 >>> test_single_arg(1, **{}) 14 1 15 >>> test_single_arg() # doctest: +ELLIPSIS 16 Traceback (most recent call last): 17 TypeError: ... 18 >>> test_single_arg(1,2) # doctest: +ELLIPSIS 19 Traceback (most recent call last): 20 TypeError: ... 21 >>> test_single_arg(1,2, **{}) # doctest: +ELLIPSIS 22 Traceback (most recent call last): 23 TypeError: ... 24 >>> test_single_arg(**{}) # doctest: +ELLIPSIS 25 Traceback (most recent call last): 26 TypeError: ... 27 >>> test_single_arg(*(), **{}) # doctest: +ELLIPSIS 28 Traceback (most recent call last): 29 TypeError: ... 30 >>> test_single_arg(**{'b':2}) # doctest: +ELLIPSIS 31 Traceback (most recent call last): 32 TypeError: ... 33 >>> test_single_arg(**{'a':1, 'b':2}) # doctest: +ELLIPSIS 34 Traceback (most recent call last): 35 TypeError: ... 36 """ 37 return a 38 39def test_two_args(a,b): 40 """ 41 >>> test_two_args(1,2) 42 (1, 2) 43 >>> test_two_args(1,2, **{}) 44 (1, 2) 45 >>> test_two_args(1,**{'b':2}) 46 (1, 2) 47 >>> test_two_args(**{'a':1, 'b':2}) 48 (1, 2) 49 >>> test_two_args() # doctest: +ELLIPSIS 50 Traceback (most recent call last): 51 TypeError: ... 52 >>> test_two_args(1) # doctest: +ELLIPSIS 53 Traceback (most recent call last): 54 TypeError: ... 55 >>> test_two_args(1, **{}) # doctest: +ELLIPSIS 56 Traceback (most recent call last): 57 TypeError: ... 58 >>> test_two_args(1,2,3) # doctest: +ELLIPSIS 59 Traceback (most recent call last): 60 TypeError: ... 61 >>> test_two_args(1,2,3, **{}) # doctest: +ELLIPSIS 62 Traceback (most recent call last): 63 TypeError: ... 64 >>> test_two_args(**{}) # doctest: +ELLIPSIS 65 Traceback (most recent call last): 66 TypeError: ... 67 >>> test_two_args(*(), **{}) # doctest: +ELLIPSIS 68 Traceback (most recent call last): 69 TypeError: ... 70 >>> test_two_args(**{'a':1}) # doctest: +ELLIPSIS 71 Traceback (most recent call last): 72 TypeError: ... 73 >>> test_two_args(**{'a':1, 'b':2, 'c':3}) # doctest: +ELLIPSIS 74 Traceback (most recent call last): 75 TypeError: ... 76 """ 77 return a,b 78