[issue39966] mock 3.9 bug: Wrapped objects without __bool__ raise exception

Avram report at bugs.python.org
Fri Mar 27 23:55:16 EDT 2020


Avram <python at avram.us> added the comment:

Ah, I see, yes, the documentation is a bit inconsistent. What may make more sense for some magic methods is to call the underlying object and use the return value or raise any exception that occurs.
For example:
__bool__ return value is bool(mock._mock_wraps)
__int__ return value is int(mock._mock_wraps)
__lt__ return value is operator.lt(mock._mock_wraps, other)

This would take care of several of them and provide more consistent behavior with the wrapped object.

----------

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue39966>
_______________________________________


More information about the Python-bugs-list mailing list