summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_inspect.py
diff options
context:
space:
mode:
authorBenjamin Peterson <benjamin@python.org>2011-03-28 22:32:31 (GMT)
committerBenjamin Peterson <benjamin@python.org>2011-03-28 22:32:31 (GMT)
commit77d466079a53830e5358c5ee5fe1dd4cda40164c (patch)
tree2ea50dfe502ca07dd4ab9226ff89a1f157e446f5 /Lib/test/test_inspect.py
parent41a9ec90030ad29fadba44eb44cc002d1c2cb153 (diff)
downloadcpython-77d466079a53830e5358c5ee5fe1dd4cda40164c.zip
cpython-77d466079a53830e5358c5ee5fe1dd4cda40164c.tar.gz
cpython-77d466079a53830e5358c5ee5fe1dd4cda40164c.tar.bz2
Correct handling of functions with only kwarg args in getcallargs (closes #11256)
A patch from Daniel Urban.
Diffstat (limited to 'Lib/test/test_inspect.py')
-rw-r--r--Lib/test/test_inspect.py14
1 files changed, 14 insertions, 0 deletions
diff --git a/Lib/test/test_inspect.py b/Lib/test/test_inspect.py
index fcdfd94..d93ffec 100644
--- a/Lib/test/test_inspect.py
+++ b/Lib/test/test_inspect.py
@@ -632,6 +632,16 @@ class TestGetcallargsFunctions(unittest.TestCase):
self.assertEqualCallArgs(f, '2, c=4, **{u"b":3}')
self.assertEqualCallArgs(f, 'b=2, **{u"a":3, u"c":4}')
+ def test_varkw_only(self):
+ # issue11256:
+ f = self.makeCallable('**c')
+ self.assertEqualCallArgs(f, '')
+ self.assertEqualCallArgs(f, 'a=1')
+ self.assertEqualCallArgs(f, 'a=1, b=2')
+ self.assertEqualCallArgs(f, 'c=3, **{"a": 1, "b": 2}')
+ self.assertEqualCallArgs(f, '**UserDict(a=1, b=2)')
+ self.assertEqualCallArgs(f, 'c=3, **UserDict(a=1, b=2)')
+
def test_tupleargs(self):
f = self.makeCallable('(b,c), (d,(e,f))=(0,[1,2])')
self.assertEqualCallArgs(f, '(2,3)')
@@ -693,6 +703,10 @@ class TestGetcallargsFunctions(unittest.TestCase):
self.assertEqualException(f, '1')
self.assertEqualException(f, '[1]')
self.assertEqualException(f, '(1,2,3)')
+ # issue11256:
+ f3 = self.makeCallable('**c')
+ self.assertEqualException(f3, '1, 2')
+ self.assertEqualException(f3, '1, 2, a=1, b=2')
class TestGetcallargsMethods(TestGetcallargsFunctions):