pytest icon indicating copy to clipboard operation
pytest copied to clipboard

`pytest_assertrepr_compare` is executed on passing assertions when a `pytest_assertion_pass` hook is defined

Open DetachHead opened this issue 1 year ago • 0 comments

  • [X] 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

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

  • [X] 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
    

DetachHead avatar Mar 04 '24 07:03 DetachHead