[issue30548] typo in documentation for create_autospec
Mario Corchero
report at bugs.python.org
Sun Nov 5 14:07:21 EST 2017
Mario Corchero <mariocj89 at gmail.com> added the comment:
I've always understood instance as a way to say "I am passing this class but I want to force the autospec on the instance"
For example, given
```
class X:
def __init__(self):
raise
```
You can do `unittest.mock.create_autospec(X, instance=True)` to set a spec of the instance rather than the class.
Also quite often you do autospec on a class but you want the interface of the instance. This parameter allows you to do so.
Basically, `unittest.mock.create_autospec(X, instance=True)` will produce a non callable mock.
I think the docs are correct, maybe misleading
----------
nosy: +mariocj89
_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue30548>
_______________________________________
More information about the Python-bugs-list
mailing list