Skip to content

Commit 6964cf1

Browse files
authored
Doc: clarify approx behavior regarding int and bools (#13341)
Fixes #13218
1 parent 636d956 commit 6964cf1

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
@@ -692,6 +692,15 @@ def approx(expected, rel=None, abs=None, nan_ok: bool = False) -> ApproxBase:
692692
from the
693693
`re_assert package <https://github.com/asottile/re-assert>`_.
694694
695+
696+
.. note::
697+
698+
Unlike built-in equality, this function considers
699+
booleans unequal to numeric zero or one. For example::
700+
701+
>>> 1 == approx(True)
702+
False
703+
695704
.. warning::
696705
697706
.. versionchanged:: 3.2

0 commit comments

Comments
 (0)