summaryrefslogtreecommitdiffstats
path: root/Lib/unittest/mock.py
diff options
context:
space:
mode:
authorNikita Sobolev <mail@sobolevn.me>2023-01-07 10:49:15 (GMT)
committerGitHub <noreply@github.com>2023-01-07 10:49:15 (GMT)
commit9e7d7266ecdcccc02385fe4ccb094f3444102e26 (patch)
tree99b6f78cf6e7b88ec03a4b437eb8e055a4758fe0 /Lib/unittest/mock.py
parenta109454e828ce2d9bde15dea78405f8ffee653ec (diff)
downloadcpython-9e7d7266ecdcccc02385fe4ccb094f3444102e26.zip
cpython-9e7d7266ecdcccc02385fe4ccb094f3444102e26.tar.gz
cpython-9e7d7266ecdcccc02385fe4ccb094f3444102e26.tar.bz2
gh-96127: Fix `inspect.signature` call on mocks (#96335)
Diffstat (limited to 'Lib/unittest/mock.py')
-rw-r--r--Lib/unittest/mock.py10
1 files changed, 9 insertions, 1 deletions
diff --git a/Lib/unittest/mock.py b/Lib/unittest/mock.py
index b3c0e28..0f93cb5 100644
--- a/Lib/unittest/mock.py
+++ b/Lib/unittest/mock.py
@@ -2217,7 +2217,15 @@ class AsyncMockMixin(Base):
code_mock = NonCallableMock(spec_set=_CODE_ATTRS)
code_mock.__dict__["_spec_class"] = CodeType
code_mock.__dict__["_spec_signature"] = _CODE_SIG
- code_mock.co_flags = inspect.CO_COROUTINE
+ code_mock.co_flags = (
+ inspect.CO_COROUTINE
+ + inspect.CO_VARARGS
+ + inspect.CO_VARKEYWORDS
+ )
+ code_mock.co_argcount = 0
+ code_mock.co_varnames = ('args', 'kwargs')
+ code_mock.co_posonlyargcount = 0
+ code_mock.co_kwonlyargcount = 0
self.__dict__['__code__'] = code_mock
self.__dict__['__name__'] = 'AsyncMock'
self.__dict__['__defaults__'] = tuple()