pytest
pytest copied to clipboard
`pytest.approx()` incorrectly flags nested sequences as unequal
Consider this:
>>> a = [(1.20000000000001,)]
>>> b = [(1.2,)]
>>> a == pytest.approx(b)
False
On the other hand:
>>> a[0] == pytest.approx(b[0])
True
So I am assuming it is thrown off by the nested sequences.
I am using pytest 8.0.0.
Looks like pytest intentionally doesn't support nested data structures for lists:
https://github.com/pytest-dev/pytest/blob/73edefdd649b3fe23e29d884ef5982876db7e18b/src/_pytest/python_api.py#L372-L375
But it's only checking for the same type, so hybrid iterables pass the check and then don't work correctly as ApproxSequenceLike
treats it's values as scalar:
https://github.com/pytest-dev/pytest/blob/73edefdd649b3fe23e29d884ef5982876db7e18b/src/_pytest/python_api.py#L367-L368