Releases: pytest-dev/pytest-mock
v3.8.1
v3.8.0
- Add
MockerFixture.async_mockmethod. Thanks @PerchunPak for the PR (#296).
3.7.0
- Python 3.10 now officially supported.
- Dropped support for Python 3.6.
3.6.1 (2021-05-06)
3.6.0 (2021-04-24)
- pytest-mock no longer supports Python 3.5.
- Correct type annotations for
mocker.patch.objectto also include the string form.
Thanks @plannigan for the PR (#235). reset_allnow supportsreturn_valueandside_effectkeyword arguments. Thanks @alex-marty for the PR (#214).
3.5.1 (2021-01-10)
- Use
inspect.getattr_staticinstead of resorting toobject.__getattribute__
magic. This should better comply with objects which implement a custom descriptor
protocol. Thanks @yesthesoup for the PR (#224).
3.5.0 (2021-01-04)
- Now all patch functions will emit a warning instead of raising a
ValueErrorwhen used
as a context-manager. Thanks @iforapsy for the PR (#221). - Additionally,
mocker.patch.context_manageris available when the user intends to mock
a context manager (for examplethreading.Lockobject), which will not emit that
warning.
3.4.0 (2020-12-15)
-
Add [mock.seal]{.title-ref} alias to the [mocker]{.title-ref} fixture (#211). Thanks @coiax for the PR.
-
Fixed spying on exceptions not covered by the
Exception
superclass (#215), likeKeyboardInterrupt-- PR #216
by @webknjaz.Before the fix, both
spy_returnandspy_exception
were always assigned toNone
whenever such an exception happened. And after this fix,
spy_exceptionis set to a correct value of an exception
3.3.1 (2020-08-24)
-
Introduce
MockFixtureas an alias toMockerFixture.Before
3.3.0, the fixture class was namedMockFixture, but was renamed toMockerFixtureto better
match themockerfixture. While not officially part of the API, it was later discovered that this broke
the code of some users which already importedpytest_mock.MockFixturefor type annotations, so we
decided to reintroduce the name as an alias.Note however that this is just a stop gap measure, and new code should use
MockerFixturefor type annotations. -
Improved typing for
MockerFixture.patch(#201). Thanks @srittau for the PR.
3.3.0 (2020-08-21)
-
pytest-mocknow includes inline type annotations and exposes them to user programs. Themockerfixture returnspytest_mock.MockerFixture, which can be used to annotate your tests:from pytest_mock import MockerFixture def test_foo(mocker: MockerFixture) -> None: ...
The type annotations were developed against mypy version
0.782, the minimum version supported at the moment. If you run into an error that you believe to be incorrect, please open an issue.Many thanks to @staticdev for providing the initial patch #199.