Pytest-mock

Latest version: v3.14.0

Safety actively analyzes 628918 Python packages for vulnerabilities to keep your Python projects secure.

Scan your dependencies

Page 4 of 11

3.2.0

------------------

* `AsyncMock <https://docs.python.org/3/library/unittest.mock.html#unittest.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.

Page 4 of 11

© 2024 Safety CLI Cybersecurity Inc. All Rights Reserved.