Skip to content

Commit 5f9d68c

Browse files
authored
Clarify precision when using NUMBER option in --doctest-modules (#9914)
Fix #9892
1 parent 4ddf48b commit 5f9d68c

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

doc/en/how-to/doctest.rst

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -126,14 +126,17 @@ pytest also introduces new options:
126126
in expected doctest output.
127127

128128
* ``NUMBER``: when enabled, floating-point numbers only need to match as far as
129-
the precision you have written in the expected doctest output. For example,
130-
the following output would only need to match to 2 decimal places::
129+
the precision you have written in the expected doctest output. The numbers are
130+
compared using :func:`pytest.approx` with relative tolerance equal to the
131+
precision. For example, the following output would only need to match to 2
132+
decimal places when comparing ``3.14`` to
133+
``pytest.approx(math.pi, rel=10**-2)``::
131134

132135
>>> math.pi
133136
3.14
134137

135-
If you wrote ``3.1416`` then the actual output would need to match to 4
136-
decimal places; and so on.
138+
If you wrote ``3.1416`` then the actual output would need to match to
139+
approximately 4 decimal places; and so on.
137140

138141
This avoids false positives caused by limited floating-point precision, like
139142
this::

0 commit comments

Comments
 (0)