-
-
Notifications
You must be signed in to change notification settings - Fork 2.9k
Closed
Labels
topic: approxrelated to pytest.approx functionrelated to pytest.approx function
Description
Hi folks,
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:
def test_approx_str():
assert [1.0, 2.0, "abc"] == approx([1.0, 2.0, "aaa"])
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
let me know if you need more info about this
Package Version
--------- -------
iniconfig 2.0.0
packaging 24.2
pluggy 1.5.0
pytest 8.3.3
- a detailed description of the bug or problem you are having
- output of
pip list
from the virtual environment you are using - pytest and operating system versions
- minimal example if possible
Metadata
Metadata
Assignees
Labels
topic: approxrelated to pytest.approx functionrelated to pytest.approx function