summaryrefslogtreecommitdiffstats
path: root/Lib/unittest/mock.py
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/mock.py
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/mock.py')
-rw-r--r--Lib/unittest/mock.py11
1 files changed, 8 insertions, 3 deletions
diff --git a/Lib/unittest/mock.py b/Lib/unittest/mock.py
index 8378b0f..8f592ab 100644
--- a/Lib/unittest/mock.py
+++ b/Lib/unittest/mock.py
@@ -78,11 +78,15 @@ def _getsignature(func, skipfirst, instance=False):
return
try:
- regargs, varargs, varkwargs, defaults = inspect.getargspec(func)
+ argspec = inspect.getfullargspec(func)
except TypeError:
# C function / method, possibly inherited object().__init__
return
+ # not using annotations
+ regargs, varargs, varkw, defaults, kwonly, kwonlydef, ann = argspec
+
+
# instance methods and classmethods need to lose the self argument
if getattr(func, '__self__', None) is not None:
regargs = regargs[1:]
@@ -90,8 +94,9 @@ def _getsignature(func, skipfirst, instance=False):
# this condition and the above one are never both True - why?
regargs = regargs[1:]
- signature = inspect.formatargspec(regargs, varargs, varkwargs, defaults,
- formatvalue=lambda value: "")
+ signature = inspect.formatargspec(
+ regargs, varargs, varkw, defaults,
+ kwonly, kwonlydef, ann, formatvalue=lambda value: "")
return signature[1:-1], func