Skip to content

Update pytest-mock to 3.17.0 - #346

Open
pyup-bot wants to merge 1 commit into
mainfrom
pyup-update-pytest-mock-3.7.0-to-3.17.0
Open

pyup-bot wants to merge 1 commit into
mainfrom
pyup-update-pytest-mock-3.7.0-to-3.17.0

Conversation

@pyup-bot

Copy link
Copy Markdown
Collaborator

This PR updates pytest-mock from 3.7.0 to 3.17.0.

Changelog

3.17.0

------

*2026-10-17*

* `641 <https://github.com/pytest-dev/pytest-mock/pull/641>`_: Failures of mock assertions such as ``assert_called_with`` are again reported only once, instead of two or three times with the original error from the ``mock`` module chained before them.
* `642 <https://github.com/pytest-dev/pytest-mock/pull/642>`_: Mock assertion failures no longer show misleading introspection when they are not about the arguments of the last call: ``assert_called``, ``assert_called_once``, ``assert_not_called``, ``assert_any_call``, their ``await`` counterparts, and ``assert_called_once_with``/``assert_awaited_once_with`` when the mock was not called (awaited) exactly once. The introspection also no longer reports arguments passed by position versus by keyword as different for autospecced mocks, and no longer shows empty ``Args:``/``Kwargs:`` sections when assertion rewriting is not available.
* `643 <https://github.com/pytest-dev/pytest-mock/pull/643>`_: ``assert_has_calls`` and ``assert_has_awaits`` failures no longer show pytest introspection, which compared the expected and actual calls position by position and so reported differences between unrelated calls. The mock's own message, listing the expected and actual calls, is still shown.

3.16.1

------

*2026-10-17*

* `617 <https://github.com/pytest-dev/pytest-mock/pull/617>`_: Fixed ``assert_has_calls`` raising ``ValueError`` instead of ``AssertionError`` (or showing misleading introspection) when the expected calls are plain tuples rather than ``call(...)`` objects, such as ``(args, kwargs)`` entries of another mock's ``call_args_list``, ``(args,)``, ``(kwargs,)``, ``(name, args)`` or ``(name, kwargs)``.
* `621 <https://github.com/pytest-dev/pytest-mock/pull/621>`_: Fixed ``mocker.stop()`` sometimes stopping the wrong mock, for example with mocks from ``mocker.create_autospec``.
* `621 <https://github.com/pytest-dev/pytest-mock/pull/621>`_: ``mocker.stop()`` now undoes the most recent patch first when the same object is used in several patches.
* `623 <https://github.com/pytest-dev/pytest-mock/pull/623>`_: Fixed misleading introspection in ``assert_has_awaits`` failures, and ``assert_has_calls``/``assert_has_awaits`` raising ``IndexError`` instead of ``AssertionError`` when ``calls`` is passed by keyword.
* `624 <https://github.com/pytest-dev/pytest-mock/pull/624>`_: Clear ``spy_return_iter`` after a spied synchronous or asynchronous function raises, matching ``spy_return``.
* `627 <https://github.com/pytest-dev/pytest-mock/pull/627>`_: Document ``async_stub`` await assertions and the distinction between call and await tracking.
* `629 <https://github.com/pytest-dev/pytest-mock/pull/629>`_: Fixed ``mocker.resetall()`` skipping the mocks patched with ``mocker.patch.multiple()``, both the ones it creates and the ones passed explicitly.
* `630 <https://github.com/pytest-dev/pytest-mock/pull/630>`_: ``mocker.resetall()`` now also resets ``spy_return`` and ``spy_exception`` of spies, like it already did for ``spy_return_list`` and ``spy_return_iter``, and no longer overwrites attributes with these names on mocks that are not spies.
* `633 <https://github.com/pytest-dev/pytest-mock/pull/633>`_: Fixed spies on ``classmethod``, ``staticmethod``, builtins and classes returning a ``MagicMock`` instead of calling the spied code after ``mocker.resetall(side_effect=True)``. Resetting a spy's ``side_effect`` now goes back to calling the spied code, also clearing any ``side_effect`` set on the spy.

3.16.0

------

*2026-09-27*

* `604 <https://github.com/pytest-dev/pytest-mock/pull/604>`_: Fixed ``duplicate_iterators=True`` for async functions spied with ``mocker.spy``.
* `611 <https://github.com/pytest-dev/pytest-mock/pull/611>`_: Fixed async mock assertion introspection to use awaited arguments instead of the latest call's arguments.
* `606 <https://github.com/pytest-dev/pytest-mock/pull/606>`_: ``mocker.resetall(return_value=True, side_effect=True)`` now also applies to non-callable mocks, such as those returned by ``mocker.create_autospec(SomeClass, instance=True)``. Previously both arguments were silently ignored for them.
* `547 <https://github.com/pytest-dev/pytest-mock/issues/547>`_: Added ``SpyType`` for annotating ``mocker.spy`` results.
* Dropped support for EOL Python 3.9.
* `147 <https://github.com/pytest-dev/pytest-mock/issues/147>`_: Removed handling of ``RuntimeError: stop called on unstarted patcher``, which can no longer occur in the supported Python versions.
* Added support for Python 3.15.

3.15.1

------

*2025-09-16*

* `529 <https://github.com/pytest-dev/pytest-mock/issues/529>`_: Fixed ``itertools._tee object has no attribute error`` -- now ``duplicate_iterators=True`` must be passed to ``mocker.spy`` to duplicate iterators.

3.15.0

------

*2025-09-04*

* Python 3.8 (EOL) is no longer supported.
* `524 <https://github.com/pytest-dev/pytest-mock/pull/524>`_: Added ``spy_return_iter`` to ``mocker.spy``, which contains a duplicate of the return value of the spied method if it is an ``Iterator``.

3.14.1

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

* `503 <https://github.com/pytest-dev/pytest-mock/pull/503>`_: Python 3.14 is now officially supported.

3.14.0

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

* `415 <https://github.com/pytest-dev/pytest-mock/pull/415>`_: ``MockType`` and ``AsyncMockType`` can be imported from ``pytest_mock`` for type annotation purposes.

* `420 <https://github.com/pytest-dev/pytest-mock/issues/420>`_: Fixed a regression which would cause ``mocker.patch.object`` to not being properly cleared between tests.

3.13.0

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

* `417 <https://github.com/pytest-dev/pytest-mock/pull/417>`_: ``spy`` now has ``spy_return_list``, which is a list containing all the values returned by the spied function.
* ``pytest-mock`` now requires ``pytest>=6.2.5``.
* `410 <https://github.com/pytest-dev/pytest-mock/pull/410>`_: pytest-mock's ``setup.py`` file is removed.
If you relied on this file, e.g. to install pytest using ``setup.py install``,
please see `Why you shouldn't invoke setup.py directly <https://blog.ganssle.io/articles/2021/10/setup-py-deprecated.html#summary>`_ for alternatives.

3.12.0

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

* Added support for Python 3.12.
* Dropped support for EOL Python 3.7.
* ``mocker.resetall()`` now also resets mocks created by ``mocker.create_autospec`` (`390`_).

.. _390: https://github.com/pytest-dev/pytest-mock/pull/390

3.11.1

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

(This release source code is identical to ``3.11.0`` except a small internal fix to deployment/CI)

* Fixed introspection for failed ``assert_has_calls`` (`365`_).

* Updated type annotations for ``mocker.patch`` and ``mocker.spy`` (`364`_).

.. _365: https://github.com/pytest-dev/pytest-mock/pull/365
.. _364: https://github.com/pytest-dev/pytest-mock/pull/364

3.11.0

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

* Fixed introspection for failed ``assert_has_calls`` (`365`_).

* Updated type annotations for ``mocker.patch`` and ``mocker.spy`` (`364`_).

.. _365: https://github.com/pytest-dev/pytest-mock/pull/365
.. _364: https://github.com/pytest-dev/pytest-mock/pull/364

3.10.0

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

* Added new ``mocker.stop(m)`` method to stop specific ``mocker.patch`` or ``mocker.spy`` calls (`319`_).

.. _319: https://github.com/pytest-dev/pytest-mock/pull/319

3.9.0

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

* Expose ``NonCallableMagicMock`` via the ``mocker`` fixture (`318`_).

.. _318: https://github.com/pytest-dev/pytest-mock/pull/318

3.8.2

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

- Fixed ``AsyncMock`` support for Python 3.7+ in ``mocker.async_stub`` (`302`_).

.. _302: https://github.com/pytest-dev/pytest-mock/pull/302

3.8.1

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

* Fixed regression caused by an explicit ``mock`` dependency in the code (`298`_).

.. _298: https://github.com/pytest-dev/pytest-mock/issues/298

3.8.0

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

* Add ``MockerFixture.async_mock`` method. Thanks `PerchunPak`_ for the PR (`296`_).

.. _PerchunPak: https://github.com/PerchunPak
.. _296: https://github.com/pytest-dev/pytest-mock/pull/296
Links

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant