You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
pytest.approx Raises misleading error for Sequences/Collections containing different strings #13010
I was using pytest.approx and I found a scenario when using approx in a collection or sequence that can have multiples types, the problem arise when doing:
I was expecting pytest to bypass the approx for str type, but I am seeing the following error:
def test_approx_str():
> assert [1.0, 2.0, "abc"] == approx([1.0, 2.0, "aaa"])
E AssertionError: assert [1.0, 2.0, 'abc'] == approx([1.0 ±...2.0e-06, aaa])
E
E (pytest_assertion plugin: representation of details failed: /tmp/test_a/.venv/lib/python3.12/site-packages/_pytest/python_api.py:343: TypeError: unsupported operand type(s) for -: 'str' and 'str'.
E Probably an object has a faulty __repr__.)
test_foo.py:5: AssertionError
Activity
graingert commentedon Nov 30, 2024
Related: #12839
approx: do not raise error in mixed sequence/collections
chore(deps): update dependency pytest to v9 (#305)