From 4bf88998c4bd212fa14ea05abfe68bab720fa1c9 Mon Sep 17 00:00:00 2001 From: Joosboy <219508079+Joosboy@users.noreply.github.com> Date: Tue, 14 Jul 2026 23:12:33 +0530 Subject: [PATCH 1/2] docs: mention pytest_assertrepr_compare is called for passing assertions --- src/_pytest/hookspec.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/_pytest/hookspec.py b/src/_pytest/hookspec.py index 6c5dd4b7c4a..4751ade04c0 100644 --- a/src/_pytest/hookspec.py +++ b/src/_pytest/hookspec.py @@ -941,6 +941,9 @@ def pytest_assertrepr_compare( *in* a string will be escaped. Note that all but the first line will be indented slightly, the intention is for the first line to be a summary. + If the :confval:`enable_assertion_pass_hook` configuration option is enabled, + this hook is also called for passing assertions. + :param config: The pytest config object. :param op: The operator, e.g. `"=="`, `"!="`, `"not in"`. :param left: The left operand. From d080ec7cecdb895a00b46fc56485080eeb0b1ec6 Mon Sep 17 00:00:00 2001 From: Joosboy <219508079+Joosboy@users.noreply.github.com> Date: Tue, 14 Jul 2026 23:18:16 +0530 Subject: [PATCH 2/2] changelog: add entry for #12062 --- changelog/12062.improvement.rst | 1 + 1 file changed, 1 insertion(+) create mode 100644 changelog/12062.improvement.rst diff --git a/changelog/12062.improvement.rst b/changelog/12062.improvement.rst new file mode 100644 index 00000000000..15dae027511 --- /dev/null +++ b/changelog/12062.improvement.rst @@ -0,0 +1 @@ +Clarified that :func:`pytest_assertrepr_compare <_pytest.hookspec.pytest_assertrepr_compare>` is also invoked for passing assertions when :confval:`enable_assertion_pass_hook` is enabled.