Skip to content

Conversation

bluetech
Copy link
Member

Fix #13722

@psf-chronographer psf-chronographer bot added the bot:chronographer:provided (automation) changelog entry is part of PR label Sep 12, 2025
if len(self.expected) != len(other_side):
return [
"Impossible to compare mappings with different sizes.",
f"Lengths: {len(self.expected)} and {len(other_side)}",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If the bigger length is small (<10) and (or? Calling str might be costly) the Str representation of both is small (fit in max truncation) we might want to show the two mappings directly ?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The full message does include a snippet:

    def test_it():
>       assert pytest.approx({"a": 1, "b": 2}) == {"a": 1, "b": 2, "c": 3}
E       AssertionError: assert approx({'a': ... 2 ± 2.0e-06}) == {'a': 1, 'b': 2, 'c': 3}
E         
E         Impossible to compare mappings with different sizes.
E         Lengths: 2 and 3

x.py:4: AssertionError

@bluetech bluetech merged commit 9913ced into pytest-dev:main Sep 16, 2025
36 checks passed
@bluetech bluetech deleted the approx-mapping-len branch September 16, 2025 12:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bot:chronographer:provided (automation) changelog entry is part of PR
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Confusing explanation for pytest.approx(subset) == superset on mappings
3 participants