File tree Expand file tree Collapse file tree 1 file changed +7
-4
lines changed Expand file tree Collapse file tree 1 file changed +7
-4
lines changed Original file line number Diff line number Diff line change @@ -126,14 +126,17 @@ pytest also introduces new options:
126
126
in expected doctest output.
127
127
128
128
* ``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) ``::
131
134
132
135
>>> math.pi
133
136
3.14
134
137
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.
137
140
138
141
This avoids false positives caused by limited floating-point precision, like
139
142
this::
You can’t perform that action at this time.
0 commit comments