From 2a23fdab9f066e3ebf7f3bcffe6e40c136772a2c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20R=C3=B6thlisberger?= Date: Mon, 8 Jul 2019 17:00:32 +0100 Subject: [PATCH] docs: Tidy up doctest options section * Move the parts about "how to configure it" (pytest.ini vs. inline comment) together. * Move `--doctest-continue-on-failure` into its own sub-heading, as it isn't related to the doctest optionflags. --- doc/en/doctest.rst | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/doc/en/doctest.rst b/doc/en/doctest.rst index 8eca000fd..9839c7ad4 100644 --- a/doc/en/doctest.rst +++ b/doc/en/doctest.rst @@ -103,7 +103,7 @@ that will be used for those doctest files using the Using 'doctest' options ----------------------- -The standard ``doctest`` module provides some `options `__ +Python's standard ``doctest`` module provides some `options `__ to configure the strictness of doctest tests. In pytest, you can enable those flags using the configuration file. @@ -115,6 +115,15 @@ lengthy exception stack traces you can just write: [pytest] doctest_optionflags= NORMALIZE_WHITESPACE IGNORE_EXCEPTION_DETAIL +Alternatively, options can be enabled by an inline comment in the doc test +itself: + +.. code-block:: rst + + >>> something_that_raises() # doctest: +IGNORE_EXCEPTION_DETAIL + Traceback (most recent call last): + ValueError: ... + pytest also introduces new options: * ``ALLOW_UNICODE``: when enabled, the ``u`` prefix is stripped from unicode @@ -145,14 +154,9 @@ pytest also introduces new options: ``NUMBER`` also supports lists of floating-point numbers -- in fact, it supports floating-point numbers appearing anywhere in the output. -Alternatively, options can be enabled by an inline comment in the doc test -itself: -.. code-block:: rst - - # content of example.rst - >>> get_unicode_greeting() # doctest: +ALLOW_UNICODE - 'Hello' +Continue on failure +------------------- By default, pytest would report only the first failure for a given doctest. If you want to continue the test even when you have failures, do: