Skip to content

Captured output in unittest.mock documentation is outdated #109350

@ragulpr

Description

@ragulpr

Refer to

The documentation was not updated after changes that made exceptions more readable like #11804. This matters since documentation would be easier to follow & google with up-to-date examples.

One example is:

>>> mock.foo_bar.assert_called_once_with('baz', spam='eggs')
>>> mock.foo_bar()
>>> mock.foo_bar.assert_called_once_with('baz', spam='eggs')
Traceback (most recent call last):
...
AssertionError: Expected to be called once. Called 2 times.

When output as of @ Python 3.13.0a0:

    AssertionError: Expected 'foo_bar' to be called once. Called 2 times.
    Calls: [call('baz', spam='eggs'), call()].

There are multiple examples of this. The easy fix is to just run the examples and update with the latest exception messages.

I prepared a fix for this, coming up in PR unless you stop me 🌞

Linked PRs

Metadata

Metadata

Assignees

No one assigned

    Labels

    docsDocumentation in the Doc dir

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions