mirror of
https://github.com/python/cpython.git
synced 2025-08-30 21:48:47 +00:00
unittest.mock: a mock created by patch with a spec as the list argument will be callable if __call__ is in the spec
This commit is contained in:
parent
87b3caf873
commit
e58a562d93
2 changed files with 28 additions and 1 deletions
|
@ -1166,7 +1166,14 @@ class _patch(object):
|
|||
if new_callable is not None:
|
||||
Klass = new_callable
|
||||
elif spec is not None or spec_set is not None:
|
||||
if not _callable(spec or spec_set):
|
||||
this_spec = spec
|
||||
if spec_set is not None:
|
||||
this_spec = spec_set
|
||||
if _is_list(this_spec):
|
||||
not_callable = '__call__' not in this_spec
|
||||
else:
|
||||
not_callable = not callable(this_spec)
|
||||
if not_callable:
|
||||
Klass = NonCallableMagicMock
|
||||
|
||||
if spec is not None:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue