From a740ef20367bad2d401ab6ac0092d26bd2b62379 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20R=C3=B6thlisberger?= Date: Thu, 11 Jul 2019 10:04:43 +0100 Subject: [PATCH] docs: Document doctest +NUMBER limitation with strings Also added an "xfail" testcase for the same. --- doc/en/doctest.rst | 4 +++- testing/test_doctest.py | 3 +++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/doc/en/doctest.rst b/doc/en/doctest.rst index 9839c7ad4..b17327f62 100644 --- a/doc/en/doctest.rst +++ b/doc/en/doctest.rst @@ -152,7 +152,9 @@ pytest also introduces new options: 0.23300000000000001 ``NUMBER`` also supports lists of floating-point numbers -- in fact, it - supports floating-point numbers appearing anywhere in the output. + matches floating-point numbers appearing anywhere in the output, even inside + a string! This means that it may not be appropriate to enable globally in + ``doctest_optionflags`` in your configuration file. Continue on failure diff --git a/testing/test_doctest.py b/testing/test_doctest.py index 40b6d7ebb..4aac5432d 100644 --- a/testing/test_doctest.py +++ b/testing/test_doctest.py @@ -958,6 +958,9 @@ class TestLiterals: # Only the actual output is rounded up, not the expected output: ("3.0", "2.98"), ("1e3", "999"), + # The current implementation doesn't understand that numbers inside + # strings shouldn't be treated as numbers: + pytest.param("'3.1416'", "'3.14'", marks=pytest.mark.xfail), ], ) def test_number_non_matches(self, testdir, expression, output):