pytest-dev / pytest-dev/pytest

`AssertionError`s with differing items in dict of lists do not display properly when not running in verbose mode

Open
#11,980 3 comments 2 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

topic: reporting type: enhancement
Dominant language
Python
Stars
14.5k
Forks
3.4k
Avg merge
2d 9h
Merged PRs (30d)
35

Description

  • a detailed description of the bug or problem you are having
    when an assert statement fails where the values being compared are dicts of lists with 8 or more items in the list, it does not show what part of the list was different in the output.
  • output of pip list from the virtual environment you are using
    not using pip
  • pytest and operating system versions py
    pytest 8.0, windows 10/11
  • minimal example if possible
def test_something():
    value1 = {"asdf": [1, 1, 1, 1, 1, 1, 1, 1]}
    value2 = {"asdf": [1, 1, 1, 1, 1, 1, 1, 2]}
    assert value1 == value2
AssertionError: assert {'asdf': [1, ...1, 1, 1, ...]} == {'asdf': [1, ...1, 1, 1, ...]}
  
  Differing items:
  {'asdf': [1, 1, 1, 1, 1, 1, ...]} != {'asdf': [1, 1, 1, 1, 1, 1, ...]}
  Use -v to get more diff

the truncated diff does not show what part was different. it should instead display something like:

  Differing items:
  {'asdf': [1, 1, 1, ...1, 1]} != {'asdf': [1, 1, 1, ...1, 2]}

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the provided test_something example under pytest 8.0 on Windows and compare its normal output with the -v output. Trace the assertion comparison and truncation path; done means the non-verbose Differing items section identifies the differing final list value instead of only showing ellipses.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
testing-qa
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.