-
-
Notifications
You must be signed in to change notification settings - Fork 141
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add a "defaults" dict to mocker to allow changing defaults that are passed to mock.patch #55
Comments
Hey @remcohaszing, Sorry, this went under the radar. Perhaps it would be better to add this as a [pytest]
mock_autospec_default=true |
Adding an option feels dirty to me: then we end up with a lot of them in the end probably?! What about overriding the |
@blueyed you got a point, we may end up with a lot of options, which doesn't really scale. So I'm assuming @blueyed means something like this: # content of test_foo.py
@pytest.fixture
def mocker(mocker):
mocker.defaults['autospec'] = True The cool thing is that you can adjust the options per-test, per-module, or even the entire test suite: # content of conftest.py
@pytest.fixture(autouse=True)
def mocker(mocker):
mocker.defaults['autospec'] = True I like it. 😁 |
I always use
autospec=True
in when patching objects. I think this helps to uncover bad mock calls.Perhaps it would be nice to be able to set this as a default value. E.g.:
The text was updated successfully, but these errors were encountered: