unstale

pypi / pytest-mock

pytest-mock

What changed in pytest-mock 3, from its official release notes, upgrade guides and advisories. Sources checked 2026-10-18.

2 breaking1 new APIs and options17 fixes and other

See which of these apply to your code, ranked, in your agent:

npx @unstale/cli init

@unstale/cli 0.1.1 on npm

pytest-mock 320 changes

Breaking changes 2

  • Handling for this RuntimeError was removed because it can no longer occur in supported Python versions.

    3.16.0release notes

  • Support for Python 3.9 was dropped because it is EOL.

    3.16.0release notes

New APIs and options 1

  • Added SpyType for annotating mocker.spy results.

    3.16.0release notes

Fixes and other changes 17

  • Failures no longer show pytest introspection comparing expected and actual calls position by position; the mock's own message listing both is retained.

    3.17.0release notes

  • Failures no longer show pytest introspection comparing expected and actual calls position by position; the mock's own message listing both is retained.

    3.17.0release notes

  • Mock assertion failures are reported only once, without chaining the original mock-module error before them.

    3.17.0release notes

  • Assertion failures no longer show misleading introspection for assertions unrelated to the last call's arguments; autospecced positional and keyword arguments are treated alike, and empty sections are omitted when rewriting is unavailable.

    3.17.0release notes

  • Failure introspection is no longer misleading, and passing calls by keyword no longer raises IndexError instead of AssertionError.

    3.16.1release notes

  • Expected calls supplied as plain tuples no longer cause ValueError or misleading introspection.

    3.16.1release notes

  • resetall no longer skips mocks patched with patch.multiple, whether created by it or passed explicitly.

    3.16.1release notes

  • Resetting a spy's side_effect resumes calling the spied code and clears any side_effect set on the spy.

    3.16.1release notes

  • resetall also resets spies' spy_return and spy_exception, and no longer overwrites those attributes on non-spy mocks.

    3.16.1release notes

  • Stopping a mock no longer sometimes stops the wrong mock, including mocks from create_autospec.

    3.16.1release notes

  • When the same object is used in several patches, stop undoes the most recent patch first.

    3.16.1release notes

  • The value is cleared after a spied synchronous or asynchronous function raises, matching spy_return.

    3.16.1release notes

  • Async mock assertion introspection now uses awaited arguments instead of the latest call's arguments.

    3.16.0release notes

  • return_value=True now applies to non-callable mocks, including those returned by create_autospec.

    3.16.0release notes

  • side_effect=True now applies to non-callable mocks, including those returned by create_autospec.

    3.16.0release notes

  • Fixed duplicate_iterators=True for async functions spied with mocker.spy.

    3.16.0release notes

  • Added support for Python 3.15.

    3.16.0release notes