pytest-dev / pytest-dev/pytest
assertion introspection is missing when pytest produces a diff
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 14.5k
- Forks
- 3.4k
- Avg merge
- 2d 9h
- Merged PRs (30d)
- 35
Description
def get_data(last):
return [1, 2, last]
def test_list_compare():
assert [1, 2, 3] == get_data(2)
def test_int_compare():
assert 1 == get_data(2)
> uv run pytest tests
...
======================== FAILURES ==============================================
____________________________ test_list_compare __________________________________
def test_list_compare():
> assert [1, 2, 3] == get_data(2)
E assert [1, 2, 3] == [1, 2, 2]
E
E At index 2 diff: 3 != 2
E
E Full diff:
E [
E 1,
E 2,
E - 2,
E ? ^
E + 3,
E ? ^
E ]
tests\test_it.py:5: AssertionError
______________________________ test_int_compare _______________________________
def test_int_compare():
> assert 1 == get_data(2)
E assert 1 == [1, 2, 2]
E + where [1, 2, 2] = get_data(2)
tests\test_it.py:8: AssertionError
while this minification doesn't represent an actual use-case, only the issue in question, there are many cases where the diff of the lists is not as useful to me as the breakdown of how it came to be, could there be a verbosity option to display both the diff, and the breakdown?
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
Reproduce the issue with the examples in tests/test_it.py by running uv run pytest tests. Review the existing assertion output and how the list diff and value breakdown are selected. Done means a verbosity option can display both forms without removing the current diff behavior, with tests covering the new output.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- testing-qa
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 42/100