[issue43478] Disallow Mock spec arguments from being Mocks

Matthew Suozzo report at bugs.python.org
Tue Mar 16 16:44:24 EDT 2021


Matthew Suozzo <msuozzo at google.com> added the comment:

A few more things:

Assertions on Mock-autospec'ed Mocks will silently pass since e.g. assert_called_once_with will now be mocked out. This may justify a more stringent stance on the pattern since it risks hiding real test failures.

One complicating factor with the implementation is that autospec'd objects may have children that are already Mocked out. Failing eagerly, however, would break cases where the child is never used (and consequently risk causing more friction than may be necessary) but failing only upon access of that child makes it trickier for the user to trace back to where the parent was mocked.

----------

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


More information about the Python-bugs-list mailing list