-
- Notifications
You must be signed in to change notification settings - Fork 2.9k
Closed
Labels
topic: approxrelated to pytest.approx functionrelated to pytest.approx functiontopic: reportingrelated to terminal output and user-facing messages and errorsrelated to terminal output and user-facing messages and errorstype: bugproblem that needs to be addressedproblem that needs to be addressed
Description
Consider this:
import pytest def test_it(): assert pytest.approx({"a": 1, "b": 2}) == {"a": 1, "b": 2, "c": 3}Currently results in this output:
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 comparison failed. Mismatched elements: 0 / 2: E Max absolute difference: -inf E Max relative difference: -inf E Index | Obtained | Expected The "comparison failed" messages doesn't actually show anything wrong (no mismatches), which is confusing.
I think it should give a message like ApproxSequence does when the lengths don't match:
E Impossible to compare mappings with different sizes. E Lengths: 2 and 3 Metadata
Metadata
Assignees
Labels
topic: approxrelated to pytest.approx functionrelated to pytest.approx functiontopic: reportingrelated to terminal output and user-facing messages and errorsrelated to terminal output and user-facing messages and errorstype: bugproblem that needs to be addressedproblem that needs to be addressed