pytest-dev / pytest-dev/pytest
`pytest_assertrepr_compare` hook should take the same arguments as `pytest_assertion_pass`
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 14.5k
- Forks
- 3.4k
- Avg merge
- 2d 9h
- Merged PRs (30d)
- 35
Description
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
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by locating the pytest_assertrepr_compare and pytest_assertion_pass hook implementations and their existing call sites or tests. Compare the proposed APIs, then determine which design can expose the original assertion expression for failing assertions; done means an agreed hook behavior is implemented and covered by the relevant hook tests.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- testing-qa
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 25/100