[issue45215] Add docs for Mock name and parent args and deprecation warning when wrong args are passed

Łukasz Langa report at bugs.python.org
Tue Sep 21 17:39:28 EDT 2021


Łukasz Langa <lukasz at langa.pl> added the comment:

Have you encountered misuse of Mock's `name` and `parent` in the wild? As you're saying, since `str()` and `repr()` will error out anyway, it's unlikely users were doing this in the first place.

I'm a little hesitant to accept the deprecation since there are very many places in the stdlib where we accept an equivalent of, say, `name=`  during some object's `__init__()` and just assign it to a field. If that happens not to be printable and crash `repr()` then too bad... but we won't be adding checks for each such case, right?

----------
nosy: +lukasz.langa

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


More information about the Python-bugs-list mailing list