Skip to content

pytest_assertrepr_compare is executed on passing assertions when a pytest_assertion_pass hook is defined #12062

Open
@DetachHead

Description

@DetachHead
  • a detailed description of the bug or problem you are having
    the documentation for pytest_assertrepr_compare states that this hook is only called when an assertion fails. however if a pytest_assertion_pass hook is present, then the pytest_assertrepr_compare hook also gets called when the assertion passes.

    not sure if it's intentional or not, but if it is, this behavior should be mentioned in the docs

  • output of pip list from the virtual environment you are using
    not using pip

  • pytest and operating system versions
    pytest 8.1.0, windows 10 & 11

  • minimal example if possible

    # conftest.py
    def pytest_assertrepr_compare():
      raise Exception # this gets called even though the assertion passed
    
    
    def pytest_assertion_pass():
        pass
    # test_foo.py
    def test_foo():
        assert 0 == 0

Metadata

Metadata

Assignees

No one assigned

    Labels

    type: docsdocumentation improvement, missing or needing clarification

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions