-
-
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 errors
Description
Hi,
This looks like a bug in pytest.approx
a = (1+0j, 2+0j)
b = (1, 2.2)
def test_ab():
assert a == pytest.approx(b, abs=0.01)
E AssertionError: assert ((1+0j), (2+0j)) == approx((1 ± 1....2 ± 1.0e-02))
E (pytest_assertion plugin: representation of details failed: /opt/anaconda3/envs/py310/lib/python3.10/site-packages/_pytest/python_api.py:331: TypeError: object of type 'ApproxScalar' has no len().
E Probably an object has a faulty repr.)
Converting the tuples to numpy arrays helps.
(pytest 7.1.2, python 3.10.4)
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 errors