diff --git a/changelog/12114.bugfix.rst b/changelog/12114.bugfix.rst deleted file mode 100644 index 798496925..000000000 --- a/changelog/12114.bugfix.rst +++ /dev/null @@ -1 +0,0 @@ -Fixed attribute error in pytest.approx for types implicitly convertible to numpy arrays by converting other_side to a numpy array so that np_array_shape != other_side.shape can be properly checked. diff --git a/src/_pytest/python_api.py b/src/_pytest/python_api.py index 7d89fdd80..fab2203ea 100644 --- a/src/_pytest/python_api.py +++ b/src/_pytest/python_api.py @@ -163,7 +163,7 @@ class ApproxNumpy(ApproxBase): self._approx_scalar, self.expected.tolist() ) - # convert other_side to numpy array to ensure shape attribute is available + # Convert other_side to numpy array to ensure shape attribute is available. other_side_as_array = _as_numpy_array(other_side) assert other_side_as_array is not None diff --git a/testing/python/approx.py b/testing/python/approx.py index 968e88285..cf8cc8d03 100644 --- a/testing/python/approx.py +++ b/testing/python/approx.py @@ -763,7 +763,8 @@ class TestApprox: assert a12 != approx(a21) assert a21 != approx(a12) - def test_numpy_array_implicit_conversion(self): + def test_numpy_array_implicit_conversion(self) -> None: + """#12114.""" np = pytest.importorskip("numpy") class ImplicitArray: