Skip to content

Commit a740ef2

Browse files
committed
docs: Document doctest +NUMBER limitation with strings
Also added an "xfail" testcase for the same.
1 parent 4c590e0 commit a740ef2

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

doc/en/doctest.rst

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,9 @@ pytest also introduces new options:
152152
0.23300000000000001
153153

154154
``NUMBER`` also supports lists of floating-point numbers -- in fact, it
155-
supports floating-point numbers appearing anywhere in the output.
155+
matches floating-point numbers appearing anywhere in the output, even inside
156+
a string! This means that it may not be appropriate to enable globally in
157+
``doctest_optionflags`` in your configuration file.
156158

157159

158160
Continue on failure

testing/test_doctest.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -958,6 +958,9 @@ def test_number_precision(self, testdir, config_mode):
958958
# Only the actual output is rounded up, not the expected output:
959959
("3.0", "2.98"),
960960
("1e3", "999"),
961+
# The current implementation doesn't understand that numbers inside
962+
# strings shouldn't be treated as numbers:
963+
pytest.param("'3.1416'", "'3.14'", marks=pytest.mark.xfail),
961964
],
962965
)
963966
def test_number_non_matches(self, testdir, expression, output):

0 commit comments

Comments
 (0)