summaryrefslogtreecommitdiffstats
path: root/Lib/unittest/test/testmock
diff options
context:
space:
mode:
authorMichael Foord <michael@voidspace.org.uk>2012-04-21 17:22:28 (GMT)
committerMichael Foord <michael@voidspace.org.uk>2012-04-21 17:22:28 (GMT)
commit3af125a4aaef5b34d8abf9d50958077473706954 (patch)
tree590b8e25e8ce8be406f8c8ee60e80829830518b3 /Lib/unittest/test/testmock
parent2cd48738ba0a593a6edf6f4f41b420ead3719e71 (diff)
downloadcpython-3af125a4aaef5b34d8abf9d50958077473706954.zip
cpython-3af125a4aaef5b34d8abf9d50958077473706954.tar.gz
cpython-3af125a4aaef5b34d8abf9d50958077473706954.tar.bz2
Closes issue 14634. unittest.mock.create_autospec now supports keyword only arguments.
Diffstat (limited to 'Lib/unittest/test/testmock')
-rw-r--r--Lib/unittest/test/testmock/testhelpers.py15
1 files changed, 14 insertions, 1 deletions
diff --git a/Lib/unittest/test/testmock/testhelpers.py b/Lib/unittest/test/testmock/testhelpers.py
index 4c43f87..7a7145e 100644
--- a/Lib/unittest/test/testmock/testhelpers.py
+++ b/Lib/unittest/test/testmock/testhelpers.py
@@ -367,7 +367,7 @@ class SpecSignatureTest(unittest.TestCase):
def test_create_autospec_unbound_methods(self):
- # see issue 128
+ # see mock issue 128
# this is expected to fail until the issue is fixed
return
class Foo(object):
@@ -391,6 +391,19 @@ class SpecSignatureTest(unittest.TestCase):
self.assertEqual(m.a, '3')
+ def test_create_autospec_keyword_only_arguments(self):
+ def foo(a, *, b=None):
+ pass
+
+ m = create_autospec(foo)
+ m(1)
+ m.assert_called_with(1)
+ self.assertRaises(TypeError, m, 1, 2)
+
+ m(2, b=3)
+ m.assert_called_with(2, b=3)
+
+
def test_function_as_instance_attribute(self):
obj = SomeClass()
def f(a):