Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

doc: clarify the behavior of approx #13341

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions changelog/13218.doc.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Pointed out in the :func:`pytest.approx` documentation that it considers booleans unequal to numeric zero or one.
9 changes: 9 additions & 0 deletions src/_pytest/python_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -678,6 +678,15 @@ def approx(expected, rel=None, abs=None, nan_ok: bool = False) -> ApproxBase:
from the
`re_assert package <https://github.com/asottile/re-assert>`_.


.. note::

Unlike built-in equality, this function considers
booleans unequal to numeric zero or one. For example::

>>> 1 == approx(True)
False

.. warning::

.. versionchanged:: 3.2
Expand Down