pytest-dev / pytest-dev/pytest-mock
Add a "defaults" dict to mocker to allow changing defaults that are passed to mock.patch
Open
Nobody has claimed this yet.
enhancement
- Dominant language
- Python
- Stars
- 2k
- Forks
- 173
- Avg merge
- 1d 10h
- Merged PRs (30d)
- 6
Description
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.:
def pytest_configure(mocker_config):
mocker_config.default_autospec = True
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by tracing the mocker configuration entry point and how defaults are passed to mock.patch. Define how a configuration hook such as pytest_configure(mocker_config) would set default_autospec, then verify that subsequent patch calls use it without preventing per-call overrides. Done means the default behavior and override behavior are covered by focused tests.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- testing
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 38/100