Skip to content

Preserve assertion failures for keyword call expectations - #609

Open
oyeong011 wants to merge 1 commit into
pytest-dev:mainfrom
oyeong011:fix/pytest-mock-regression
Open

Preserve assertion failures for keyword call expectations#609
oyeong011 wants to merge 1 commit into
pytest-dev:mainfrom
oyeong011:fix/pytest-mock-regression

Conversation

@oyeong011

Copy link
Copy Markdown

Calling stub.assert_has_calls(calls=[expected]) after an unexpected call raises IndexError instead of AssertionError. The upstream unittest.mock signature accepts the calls keyword. Read expected calls from that keyword when no positional argument was supplied.

The regression fails with IndexError before the change and passes afterward. The full suite passes: 92 tests on macOS/Python 3.12.13 with pytest 9.1.1. Ruff check/format and diff checks pass. Validation used installed wheel metadata for pytest assertion rewriting while PYTHONPATH pointed to the source checkout; no tests were excluded. Other platform/version combinations were not run.

AI assistance: OpenAI Codex assisted with implementation, tests, and this description. The reported checks were executed locally.

Confidence: high
Scope-risk: narrow
Tested: Regression fails before fix and passes after; full suite results recorded externally
Not-tested: Other operating systems and Python versions
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