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.
This commit is contained in:
parent
aaa7e837cc
commit
2a23fdab9f
|
@ -103,7 +103,7 @@ that will be used for those doctest files using the
|
||||||
Using 'doctest' options
|
Using 'doctest' options
|
||||||
-----------------------
|
-----------------------
|
||||||
|
|
||||||
The standard ``doctest`` module provides some `options <https://docs.python.org/3/library/doctest.html#option-flags>`__
|
Python's standard ``doctest`` module provides some `options <https://docs.python.org/3/library/doctest.html#option-flags>`__
|
||||||
to configure the strictness of doctest tests. In pytest, you can enable those flags using the
|
to configure the strictness of doctest tests. In pytest, you can enable those flags using the
|
||||||
configuration file.
|
configuration file.
|
||||||
|
|
||||||
|
@ -115,6 +115,15 @@ lengthy exception stack traces you can just write:
|
||||||
[pytest]
|
[pytest]
|
||||||
doctest_optionflags= NORMALIZE_WHITESPACE IGNORE_EXCEPTION_DETAIL
|
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:
|
pytest also introduces new options:
|
||||||
|
|
||||||
* ``ALLOW_UNICODE``: when enabled, the ``u`` prefix is stripped from unicode
|
* ``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
|
``NUMBER`` also supports lists of floating-point numbers -- in fact, it
|
||||||
supports floating-point numbers appearing anywhere in the output.
|
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
|
Continue on failure
|
||||||
|
-------------------
|
||||||
# content of example.rst
|
|
||||||
>>> get_unicode_greeting() # doctest: +ALLOW_UNICODE
|
|
||||||
'Hello'
|
|
||||||
|
|
||||||
By default, pytest would report only the first failure for a given doctest. If
|
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:
|
you want to continue the test even when you have failures, do:
|
||||||
|
|
Loading…
Reference in New Issue