Skip to content
Browse files

extended test case

--HG--
extra : transplant_source : %A9%95%1D%5B%C5W%1C%EDT%C8%5E%D6%12%FBanK%8E%83D
  • Loading branch information...
1 parent 0d598eb commit c54e21df64fa5df4ee872b28cec948465d4fefbf Stefan Behnel committed Sep 17, 2011
Showing with 42 additions and 10 deletions.
  1. +42 −10 tests/run/argerrors.py
View
52 tests/run/argerrors.py
@@ -1,19 +1,36 @@
# 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() # doctest: +ELLIPSIS
+ >>> test_single_arg(1, **{})
+ 1
+ >>> test_single_arg() # doctest: +ELLIPSIS
Traceback (most recent call last):
TypeError: ...
- >>> test_single_arg(1,2) # doctest: +ELLIPSIS
+ >>> test_single_arg(1,2) # doctest: +ELLIPSIS
Traceback (most recent call last):
TypeError: ...
- >>> test_single_arg(**{}) # doctest: +ELLIPSIS
+ >>> test_single_arg(1,2, **{}) # doctest: +ELLIPSIS
Traceback (most recent call last):
TypeError: ...
- >>> test_single_arg(*(), **{}) # doctest: +ELLIPSIS
+ >>> 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: ...
"""
@@ -23,22 +40,37 @@ def test_two_args(a,b):
"""
>>> test_two_args(1,2)
(1, 2)
- >>> test_two_args() # doctest: +ELLIPSIS
+ >>> 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(1) # doctest: +ELLIPSIS
+ >>> test_two_args(1,2,3, **{}) # doctest: +ELLIPSIS
Traceback (most recent call last):
TypeError: ...
- >>> test_two_args(1,2,3) # doctest: +ELLIPSIS
+ >>> test_two_args(**{}) # doctest: +ELLIPSIS
Traceback (most recent call last):
TypeError: ...
- >>> test_two_args(**{}) # doctest: +ELLIPSIS
+ >>> test_two_args(*(), **{}) # doctest: +ELLIPSIS
Traceback (most recent call last):
TypeError: ...
- >>> test_two_args(1, **{}) # doctest: +ELLIPSIS
+ >>> test_two_args(**{'a':1}) # doctest: +ELLIPSIS
Traceback (most recent call last):
TypeError: ...
- >>> test_two_args(*(), **{}) # doctest: +ELLIPSIS
+ >>> test_two_args(**{'a':1, 'b':2, 'c':3}) # doctest: +ELLIPSIS
Traceback (most recent call last):
TypeError: ...
"""

0 comments on commit c54e21d

Please sign in to comment.
Something went wrong with that request. Please try again.