pypi pytest-mock 3.16.1
v3.16.1

latest release: 3.17.0
4 hours ago

2026-10-17

  • #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: Fixed mocker.stop() sometimes stopping the wrong mock, for example with mocks from mocker.create_autospec.
  • #621: mocker.stop() now undoes the most recent patch first when the same object is used in several patches.
  • #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: Clear spy_return_iter after a spied synchronous or asynchronous function raises, matching spy_return.
  • #627: Document async_stub await assertions and the distinction between call and await tracking.
  • #629: Fixed mocker.resetall() skipping the mocks patched with mocker.patch.multiple(), both the ones it creates and the ones passed explicitly.
  • #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: 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.

Don't miss a new pytest-mock release

NewReleases is sending notifications on new releases.