Skip to content

Commit bb4d149

Browse files
Doc: clarify approx behavior regarding int and bools (#13341) (#13352)
Fixes #13218 (cherry picked from commit 6964cf1) Co-authored-by: Natalia Mokeeva <[email protected]>
1 parent 75cf3e7 commit bb4d149

File tree

2 files changed

+10
-0
lines changed

2 files changed

+10
-0
lines changed

changelog/13218.doc.rst

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Pointed out in the :func:`pytest.approx` documentation that it considers booleans unequal to numeric zero or one.

src/_pytest/python_api.py

+9
Original file line numberDiff line numberDiff line change
@@ -697,6 +697,15 @@ def approx(expected, rel=None, abs=None, nan_ok: bool = False) -> ApproxBase:
697697
from the
698698
`re_assert package <https://github.com/asottile/re-assert>`_.
699699
700+
701+
.. note::
702+
703+
Unlike built-in equality, this function considers
704+
booleans unequal to numeric zero or one. For example::
705+
706+
>>> 1 == approx(True)
707+
False
708+
700709
.. warning::
701710
702711
.. versionchanged:: 3.2

0 commit comments

Comments
 (0)