Changelog
### 3.3.0
```
------------------
* ``pytest-mock`` now includes inline type annotations and exposes them to user programs. The ``mocker`` fixture returns ``pytest_mock.MockerFixture``, which can be used to annotate your tests:
.. code-block:: python
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`_).
.. _staticdev: https://github.com/staticdev
.. _199: https://github.com/pytest-dev/pytest-mock/pull/199
```
### 3.2.0
```
------------------
* `AsyncMock <https://docs.python.org/3/library/unittest.mock.htmlunittest.mock.AsyncMock>`__ is now exposed in ``mocker`` and supports provides assertion introspection similar to ``Mock`` objects.
Added by `tirkarthi`_ in `197`_.
.. _tirkarthi: https://github.com/tirkarthi
.. _197: https://github.com/pytest-dev/pytest-mock/pull/197
```
### 3.1.1
```
------------------
* Fixed performance regression caused by the ``ValueError`` raised
when ``mocker`` is used as context manager (`191`_).
.. _191: https://github.com/pytest-dev/pytest-mock/issues/191
```
### 3.1.0
```
------------------
* New mocker fixtures added that allow using mocking functionality in other scopes:
* ``class_mocker``
* ``module_mocker``
* ``package_mocker``
* ``session_mocker``
Added by `scorphus`_ in `182`_.
.. _scorphus: https://github.com/scorphus
.. _182: https://github.com/pytest-dev/pytest-mock/pull/182
```
### 3.0.0
```
------------------
* Python 2.7 and 3.4 are no longer supported. Users using ``pip 9`` or later will install
a compatible version automatically.
* ``mocker.spy`` now also works with ``async def`` functions (`179`_). Thanks `frankie567`_ for the PR!
.. _179: https://github.com/pytest-dev/pytest-mock/issues/179
.. _frankie567: https://github.com/frankie567
```
### 2.0.0
```
------------------
Breaking Changes
++++++++++++++++
* ``mocker.spy`` attributes for tracking returned values and raised exceptions of its spied functions
are now called ``spy_return`` and ``spy_exception``, instead of reusing the existing
``MagicMock`` attributes ``return_value`` and ``side_effect``.
Version ``1.13`` introduced a serious regression: after a spied function using ``mocker.spy``
raises an exception, further calls to the spy will not call the spied function,
always raising the first exception instead: assigning to ``side_effect`` causes
``unittest.mock`` to behave this way (`175`_).
* The deprecated ``mock`` alias to the ``mocker`` fixture has finally been removed.
.. _175: https://github.com/pytest-dev/pytest-mock/issues/175
```
### 1.13.0
```
-------------------
* The object returned by ``mocker.spy`` now also tracks any side effect
of the spied method/function.
```
### 1.12.1
```
-------------------
* Fix error if ``mocker.patch`` is used in code where the source file
is not available, for example stale ``.pyc`` files (`169`_).
.. _169: https://github.com/pytest-dev/pytest-mock/issues/169issuecomment-555729265
```
### 1.12.0
```
-------------------
* Now all patch functions also raise a ``ValueError`` when used
as a context-manager. Thanks `AlexGascon`_ for the PR (`168`_).
.. _AlexGascon: https://github.com/AlexGascon
.. _168: https://github.com/pytest-dev/pytest-mock/pull/168
```
### 1.11.2
```
-------------------
* The *pytest introspection follows* message is no longer shown
if there is no pytest introspection (`154`_).
Thanks `The-Compiler`_ for the report.
* ``mocker`` now raises a ``ValueError`` when used as a context-manager.
Thanks `binarymason`_ for the PR (`165`_).
.. _154: https://github.com/pytest-dev/pytest-mock/issues/154
.. _165: https://github.com/pytest-dev/pytest-mock/pull/165
.. _binarymason: https://github.com/binarymason
```
### 1.11.1
```
-------------------
* Fix ``mocker.spy`` on Python 2 when used on non-function objects
which implement ``__call__`` (`157`_). Thanks `pbasista`_ for
the report.
.. _157: https://github.com/pytest-dev/pytest-mock/issues/157
.. _pbasista: https://github.com/pbasista
```
### 1.11.0
```
------
* The object returned by ``mocker.spy`` now also tracks the return value
of the spied method/function.
```
### 1.10.4
```
------
* Fix plugin when 'terminal' plugin is disabled
```
### 1.10.3
```
------
* Fix test suite in Python 3.8. Thanks `hroncok`_ for the report and `blueyed`_ for the PR (`140`_).
.. _140: https://github.com/pytest-dev/pytest-mock/pull/140
.. _hroncok: https://github.com/hroncok
```
### 1.10.2
```
------
* Fix bug at the end of the test session when a call to ``patch.stopall`` is done explicitly by
user code. Thanks `craiga`_ for the report (`137`_).
.. _137: https://github.com/pytest-dev/pytest-mock/issues/137
.. _craiga: https://github.com/craiga
```
### 1.10.1
```
------
* Fix broken links and update README. Also the code is now formatted using `black <https://github.com/ambv/black>`__.
```
Links
- PyPI: https://pypi.org/project/pytest-mock
- Changelog: https://pyup.io/changelogs/pytest-mock/
- Repo: https://github.com/pytest-dev/pytest-mock/
This PR updates pytest-mock from 1.10.0 to 3.3.0.
Changelog
### 3.3.0 ``` ------------------ * ``pytest-mock`` now includes inline type annotations and exposes them to user programs. The ``mocker`` fixture returns ``pytest_mock.MockerFixture``, which can be used to annotate your tests: .. code-block:: python 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`_). .. _staticdev: https://github.com/staticdev .. _199: https://github.com/pytest-dev/pytest-mock/pull/199 ``` ### 3.2.0 ``` ------------------ * `AsyncMock <https://docs.python.org/3/library/unittest.mock.htmlunittest.mock.AsyncMock>`__ is now exposed in ``mocker`` and supports provides assertion introspection similar to ``Mock`` objects. Added by `tirkarthi`_ in `197`_. .. _tirkarthi: https://github.com/tirkarthi .. _197: https://github.com/pytest-dev/pytest-mock/pull/197 ``` ### 3.1.1 ``` ------------------ * Fixed performance regression caused by the ``ValueError`` raised when ``mocker`` is used as context manager (`191`_). .. _191: https://github.com/pytest-dev/pytest-mock/issues/191 ``` ### 3.1.0 ``` ------------------ * New mocker fixtures added that allow using mocking functionality in other scopes: * ``class_mocker`` * ``module_mocker`` * ``package_mocker`` * ``session_mocker`` Added by `scorphus`_ in `182`_. .. _scorphus: https://github.com/scorphus .. _182: https://github.com/pytest-dev/pytest-mock/pull/182 ``` ### 3.0.0 ``` ------------------ * Python 2.7 and 3.4 are no longer supported. Users using ``pip 9`` or later will install a compatible version automatically. * ``mocker.spy`` now also works with ``async def`` functions (`179`_). Thanks `frankie567`_ for the PR! .. _179: https://github.com/pytest-dev/pytest-mock/issues/179 .. _frankie567: https://github.com/frankie567 ``` ### 2.0.0 ``` ------------------ Breaking Changes ++++++++++++++++ * ``mocker.spy`` attributes for tracking returned values and raised exceptions of its spied functions are now called ``spy_return`` and ``spy_exception``, instead of reusing the existing ``MagicMock`` attributes ``return_value`` and ``side_effect``. Version ``1.13`` introduced a serious regression: after a spied function using ``mocker.spy`` raises an exception, further calls to the spy will not call the spied function, always raising the first exception instead: assigning to ``side_effect`` causes ``unittest.mock`` to behave this way (`175`_). * The deprecated ``mock`` alias to the ``mocker`` fixture has finally been removed. .. _175: https://github.com/pytest-dev/pytest-mock/issues/175 ``` ### 1.13.0 ``` ------------------- * The object returned by ``mocker.spy`` now also tracks any side effect of the spied method/function. ``` ### 1.12.1 ``` ------------------- * Fix error if ``mocker.patch`` is used in code where the source file is not available, for example stale ``.pyc`` files (`169`_). .. _169: https://github.com/pytest-dev/pytest-mock/issues/169issuecomment-555729265 ``` ### 1.12.0 ``` ------------------- * Now all patch functions also raise a ``ValueError`` when used as a context-manager. Thanks `AlexGascon`_ for the PR (`168`_). .. _AlexGascon: https://github.com/AlexGascon .. _168: https://github.com/pytest-dev/pytest-mock/pull/168 ``` ### 1.11.2 ``` ------------------- * The *pytest introspection follows* message is no longer shown if there is no pytest introspection (`154`_). Thanks `The-Compiler`_ for the report. * ``mocker`` now raises a ``ValueError`` when used as a context-manager. Thanks `binarymason`_ for the PR (`165`_). .. _154: https://github.com/pytest-dev/pytest-mock/issues/154 .. _165: https://github.com/pytest-dev/pytest-mock/pull/165 .. _binarymason: https://github.com/binarymason ``` ### 1.11.1 ``` ------------------- * Fix ``mocker.spy`` on Python 2 when used on non-function objects which implement ``__call__`` (`157`_). Thanks `pbasista`_ for the report. .. _157: https://github.com/pytest-dev/pytest-mock/issues/157 .. _pbasista: https://github.com/pbasista ``` ### 1.11.0 ``` ------ * The object returned by ``mocker.spy`` now also tracks the return value of the spied method/function. ``` ### 1.10.4 ``` ------ * Fix plugin when 'terminal' plugin is disabled ``` ### 1.10.3 ``` ------ * Fix test suite in Python 3.8. Thanks `hroncok`_ for the report and `blueyed`_ for the PR (`140`_). .. _140: https://github.com/pytest-dev/pytest-mock/pull/140 .. _hroncok: https://github.com/hroncok ``` ### 1.10.2 ``` ------ * Fix bug at the end of the test session when a call to ``patch.stopall`` is done explicitly by user code. Thanks `craiga`_ for the report (`137`_). .. _137: https://github.com/pytest-dev/pytest-mock/issues/137 .. _craiga: https://github.com/craiga ``` ### 1.10.1 ``` ------ * Fix broken links and update README. Also the code is now formatted using `black <https://github.com/ambv/black>`__. ```Links
- PyPI: https://pypi.org/project/pytest-mock - Changelog: https://pyup.io/changelogs/pytest-mock/ - Repo: https://github.com/pytest-dev/pytest-mock/