Visitar URL original
bpo-42532: Check if NonCallableMock's spec_arg is not None instead of call its __bool__ function by idanw206 · Pull Request #23613 · python/cpython · GitHub
Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Check if NonCallableMock's spec_arg is not None instead of call its _…
…_bool__ function
  • Loading branch information
Idan Weiss
Idan Weiss committed Dec 2, 2020
commit 1bc3518ebc846e182f079fe66619af7e7f99945b
2 changes: 1 addition & 1 deletion Lib/unittest/mock.py
Original file line number Diff line number Diff line change
Expand Up @@ -406,7 +406,7 @@ def __new__(cls, /, *args, **kw):
# Check if spec is an async object or function
bound_args = _MOCK_SIG.bind_partial(cls, *args, **kw).arguments
spec_arg = bound_args.get('spec_set', bound_args.get('spec'))
if spec_arg and _is_async_obj(spec_arg):
if spec_arg is not None and _is_async_obj(spec_arg):
bases = (AsyncMockMixin, cls)
new = type(cls.__name__, bases, {'__doc__': cls.__doc__})
instance = _safe_super(NonCallableMock, cls).__new__(new)
Expand Down