pytest
pytest copied to clipboard
`pytest_assertrepr_compare` hook should take the same arguments as `pytest_assertion_pass`
What's the problem this feature will solve?
in my plugin (pytest-robotframework), i want to be able to log both passing and failing assertions in the same way, as a keyword in the robot log with the original expression from the assert statement. for example, the following test would produce this output in the robot log:
def test_foo():
left = 1
right = 1
assert left == right
however i can't do that with failing assertions, because pytest_assertrepr_compare does not have an orig argument, so only the actual values can be displayed, not the original left == right expression from the assert statement:
Describe the solution you'd like
either:
- add the
origargument frompytest_assertion_passtopytest_assertrepr_compare. the other arguments would be useful too:item,lineno,expl(explwould be the default explanation or the explanation returned from a previous hook) - create a new
pytest_assertion_failhook that takes the same arguments aspytest_assertion_pass
This would also be useful for safety critical testing where a formal review of the outputs needs to occur.