Skip to content

Commit 2a23fda

Browse files
committed
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.
1 parent aaa7e83 commit 2a23fda

File tree

1 file changed

+12
-8
lines changed

1 file changed

+12
-8
lines changed

doc/en/doctest.rst

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ that will be used for those doctest files using the
103103
Using 'doctest' options
104104
-----------------------
105105

106-
The standard ``doctest`` module provides some `options <https://docs.python.org/3/library/doctest.html#option-flags>`__
106+
Python's standard ``doctest`` module provides some `options <https://docs.python.org/3/library/doctest.html#option-flags>`__
107107
to configure the strictness of doctest tests. In pytest, you can enable those flags using the
108108
configuration file.
109109

@@ -115,6 +115,15 @@ lengthy exception stack traces you can just write:
115115
[pytest]
116116
doctest_optionflags= NORMALIZE_WHITESPACE IGNORE_EXCEPTION_DETAIL
117117
118+
Alternatively, options can be enabled by an inline comment in the doc test
119+
itself:
120+
121+
.. code-block:: rst
122+
123+
>>> something_that_raises() # doctest: +IGNORE_EXCEPTION_DETAIL
124+
Traceback (most recent call last):
125+
ValueError: ...
126+
118127
pytest also introduces new options:
119128

120129
* ``ALLOW_UNICODE``: when enabled, the ``u`` prefix is stripped from unicode
@@ -145,14 +154,9 @@ pytest also introduces new options:
145154
``NUMBER`` also supports lists of floating-point numbers -- in fact, it
146155
supports floating-point numbers appearing anywhere in the output.
147156

148-
Alternatively, options can be enabled by an inline comment in the doc test
149-
itself:
150157

151-
.. code-block:: rst
152-
153-
# content of example.rst
154-
>>> get_unicode_greeting() # doctest: +ALLOW_UNICODE
155-
'Hello'
158+
Continue on failure
159+
-------------------
156160

157161
By default, pytest would report only the first failure for a given doctest. If
158162
you want to continue the test even when you have failures, do:

0 commit comments

Comments
 (0)