Skip to content

Fix async assertion argument introspection - #611

Open
jakezwang wants to merge 1 commit into
pytest-dev:mainfrom
jakezwang:fix/async-assertion-introspection
Open

jakezwang wants to merge 1 commit into
pytest-dev:mainfrom
jakezwang:fix/async-assertion-introspection

Conversation

@jakezwang

Copy link
Copy Markdown

Async assertion introspection reads call_args, so a later call that was not awaited replaces the arguments shown for a failed await assertion. It can also add a misleading argument diff when the mock was never awaited.

Use await_args for await assertions and retain call_args for synchronous assertions. Add regressions for positional and keyword arguments, never-awaited mocks, and synchronous assertions on AsyncMock.

Validation: tox on Python 3.10–3.15, pytest 6 on Python 3.10, assertion rewriting disabled on Python 3.12, standalone mock regressions, pre-commit, docs, and package checks passed.

This branch has not been deployed

No deployments
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