python
data_error
ai_generated
true
AssertionError: assert {'a': 1, 'b': 2, ...} == {'a': 1, 'b': 3, ...} Omitting 15 identical items, use -vv to show Differing items: {'b': 2} != {'b': 3}
ID: python/pytest-assertion-dict-diff-truncated
80%Fix Rate
82%Confidence
0Evidence
2024-10-19First Seen
Version Compatibility
| Version | Status | Introduced | Deprecated | Notes |
|---|---|---|---|---|
| 7.x | active | — | — | — |
| 8.x | active | — | — | — |
Root Cause
pytest truncates large dict/list diffs by default; the actual divergence is hidden among omitted items, making the failure hard to diagnose in CI logs.
generic中文
pytest 默认截断大型字典/列表差异;实际分歧隐藏在省略项中,使 CI 日志中的失败难以诊断。
Workarounds
-
90% success
Raise verbosity: pytest -vv tests/test_config.py::test_merge # or set in config # [tool.pytest.ini_options] # addopts = "-vv"
-
85% success
Or compute a minimal diff explicitly: from deepdiff import DeepDiff diff = DeepDiff(expected, actual, ignore_order=True) assert not diff, diff
Dead Ends
Common approaches that don't work:
-
65% fail
Output is captured and interleaved unpredictably; hard to diff visually in CI.
-
50% fail
Works but noisy and slow; you lose pytest's structured diff.