1 from UserList
import UserList
19 f(1, 2, 3, *UserList([4, 5]))
20 f(1, 2, 3, **{'a':4, 'b':5})
21 f(1, 2, 3, *(4, 5), **{'a':6, 'b':7})
22 f(1, 2, 3, x
=4, y
=5, *(6, 7), **{'a':8, 'b':9})
26 except TypeError, err
:
27 print "TypeError:", err
29 print "should raise TypeError: not enough arguments; expected 1, got 0"
33 except TypeError, err
:
34 print "TypeError:", err
36 print "should raise TypeError: not enough arguments; expected 1, got 0"
40 except TypeError, err
:
41 print "TypeError:", err
43 print "should raise TypeError: not enough arguments; expected 1, got 0"
52 except AttributeError, attr
:
55 print "should raise AttributeError: __len__"
62 except AttributeError, attr
:
65 print "should raise AttributeError: __getitem__"
70 def __getitem__(self
, i
):
77 # make sure the function call doesn't stomp on the dictionary?
78 d
= {'a': 1, 'b': 2, 'c': 3}
84 assert d
== d2
, "function call modified dictionary"
86 # what about willful misconduct?
88 kw
['x'] = locals() # yields a cyclic kw
91 kw
= saboteur(a
=1, **d
)
97 g(1, 2, 3, **{'x':4, 'y':5})
98 except TypeError, err
:
101 print "should raise TypeError: keyword parameter redefined"
104 g(1, 2, 3, a
=4, b
=5, *(6, 7), **{'a':8, 'b':9})
105 except TypeError, err
:
108 print "should raise TypeError: keyword parameter redefined"
112 except TypeError, err
:
115 print "should raise TypeError: keywords must be strings"
119 except TypeError, err
:
122 print "should raise TypeError: unexpected keyword argument: e"
126 except TypeError, err
:
129 print "should raise TypeError: * argument must be a tuple"
133 except TypeError, err
:
136 print "should raise TypeError: ** argument must be a dictionary"
145 a
, b
= f2(1, *(2, 3), **d
)
146 print len(a
), len(b
), b
== d