pytest-dev / pytest-dev/pytest-mock
Allow use of custom mock implementations
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 2k
- Forks
- 173
- Avg merge
- 1d 10h
- Merged PRs (30d)
- 6
Description
With the growing use of asyncio, we need ways to mock Coroutines.
Currently, mock and unittest.mock do not support creating specs for coroutines (AsyncMock is being added in python 3.8).
As a work around, we're using asynctest.mock, which has the same interface as unittest.mock, however this requires us to completely re-implement the __init__ method of MockFixture, and removes the "hide traceback" functionality (though we don't care too much about this).
This allows us to have both mocker and async_mocker fixtures.
TLDR
To ease this usecase (and potentially others), Can support for defining a mock modules path from the config be added please?
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 reading MockFixture.init and tracing how the plugin currently selects mock and unittest.mock implementations from configuration. Clarify the supported configuration shape and verify that a configured custom module can provide coroutine-aware mocks without removing existing fixture behavior.
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
- 35/100