Commit c54e21df authored by Stefan Behnel's avatar Stefan Behnel

extended test case

--HG--
extra : transplant_source : %A9%95%1D%5B%C5W%1C%EDT%C8%5E%D6%12%FBanK%8E%83D
parent 0d598eb9
# mode: run
# tags: kwargs, argument unpacking
# This test validates the error handling in the different specialised
# code paths of the argument unpacking code. The have-kwargs and
# no-kwargs branches take different paths, so we always test with and
# without a keyword dict (even if it's empty).
def test_single_arg(a):
"""
>>> test_single_arg(1)
1
>>> test_single_arg(1, **{})
1
>>> test_single_arg() # doctest: +ELLIPSIS
Traceback (most recent call last):
TypeError: ...
>>> test_single_arg(1,2) # doctest: +ELLIPSIS
Traceback (most recent call last):
TypeError: ...
>>> test_single_arg(1,2, **{}) # doctest: +ELLIPSIS
Traceback (most recent call last):
TypeError: ...
>>> test_single_arg(**{}) # doctest: +ELLIPSIS
Traceback (most recent call last):
TypeError: ...
>>> test_single_arg(*(), **{}) # doctest: +ELLIPSIS
Traceback (most recent call last):
TypeError: ...
>>> test_single_arg(**{'b':2}) # doctest: +ELLIPSIS
Traceback (most recent call last):
TypeError: ...
>>> test_single_arg(**{'a':1, 'b':2}) # doctest: +ELLIPSIS
Traceback (most recent call last):
TypeError: ...
"""
return a
......@@ -23,23 +40,38 @@ def test_two_args(a,b):
"""
>>> test_two_args(1,2)
(1, 2)
>>> test_two_args(1,2, **{})
(1, 2)
>>> test_two_args(1,**{'b':2})
(1, 2)
>>> test_two_args(**{'a':1, 'b':2})
(1, 2)
>>> test_two_args() # doctest: +ELLIPSIS
Traceback (most recent call last):
TypeError: ...
>>> test_two_args(1) # doctest: +ELLIPSIS
Traceback (most recent call last):
TypeError: ...
>>> test_two_args(1, **{}) # doctest: +ELLIPSIS
Traceback (most recent call last):
TypeError: ...
>>> test_two_args(1,2,3) # doctest: +ELLIPSIS
Traceback (most recent call last):
TypeError: ...
>>> test_two_args(**{}) # doctest: +ELLIPSIS
>>> test_two_args(1,2,3, **{}) # doctest: +ELLIPSIS
Traceback (most recent call last):
TypeError: ...
>>> test_two_args(1, **{}) # doctest: +ELLIPSIS
>>> test_two_args(**{}) # doctest: +ELLIPSIS
Traceback (most recent call last):
TypeError: ...
>>> test_two_args(*(), **{}) # doctest: +ELLIPSIS
Traceback (most recent call last):
TypeError: ...
>>> test_two_args(**{'a':1}) # doctest: +ELLIPSIS
Traceback (most recent call last):
TypeError: ...
>>> test_two_args(**{'a':1, 'b':2, 'c':3}) # doctest: +ELLIPSIS
Traceback (most recent call last):
TypeError: ...
"""
return a,b
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment