mirror of
https://github.com/sphinx-doc/sphinx.git
synced 2025-02-25 18:55:22 -06:00
Merge pull request #2478 from taschini/doctest_default_flags
Doctest default flags
This commit is contained in:
commit
cfa50a4db7
1
CHANGES
1
CHANGES
@ -11,6 +11,7 @@ Features added
|
|||||||
|
|
||||||
* Add ``:caption:`` option for sphinx.ext.inheritance_diagram.
|
* Add ``:caption:`` option for sphinx.ext.inheritance_diagram.
|
||||||
* #894: Add ``lualatexpdf`` and ``xelatexpdf`` as a make target to build PDF using lualatex or xelatex
|
* #894: Add ``lualatexpdf`` and ``xelatexpdf`` as a make target to build PDF using lualatex or xelatex
|
||||||
|
* #2471: Add config variable for default doctest flags.
|
||||||
|
|
||||||
Bugs fixed
|
Bugs fixed
|
||||||
----------
|
----------
|
||||||
|
@ -56,12 +56,9 @@ names.
|
|||||||
.. rst:directive:: .. doctest:: [group]
|
.. rst:directive:: .. doctest:: [group]
|
||||||
|
|
||||||
A doctest-style code block. You can use standard :mod:`doctest` flags for
|
A doctest-style code block. You can use standard :mod:`doctest` flags for
|
||||||
controlling how actual output is compared with what you give as output. By
|
controlling how actual output is compared with what you give as output. The
|
||||||
default, these options are enabled: ``ELLIPSIS`` (allowing you to put
|
default set of flags is specified by the :confval:`doctest_default_flags`
|
||||||
ellipses in the expected output that match anything in the actual output),
|
configuration variable.
|
||||||
``IGNORE_EXCEPTION_DETAIL`` (not comparing tracebacks),
|
|
||||||
``DONT_ACCEPT_TRUE_FOR_1`` (by default, doctest accepts "True" in the output
|
|
||||||
where "1" is given -- this is a relic of pre-Python 2.2 times).
|
|
||||||
|
|
||||||
This directive supports two options:
|
This directive supports two options:
|
||||||
|
|
||||||
@ -176,6 +173,20 @@ The following is an example for the usage of the directives. The test via
|
|||||||
|
|
||||||
There are also these config values for customizing the doctest extension:
|
There are also these config values for customizing the doctest extension:
|
||||||
|
|
||||||
|
.. confval:: doctest_default_flags
|
||||||
|
|
||||||
|
By default, these options are enabled:
|
||||||
|
|
||||||
|
- ``ELLIPSIS``, allowing you to put ellipses in the expected output that
|
||||||
|
match anything in the actual output;
|
||||||
|
- ``IGNORE_EXCEPTION_DETAIL``, causing everything following the leftmost
|
||||||
|
colon and any module information in the exception name to be ignored;
|
||||||
|
- ``DONT_ACCEPT_TRUE_FOR_1``, rejecting "True" in the output where "1" is
|
||||||
|
given -- the default behavior of accepting this substitution is a relic of
|
||||||
|
pre-Python 2.2 times.
|
||||||
|
|
||||||
|
.. versionadded:: 1.5
|
||||||
|
|
||||||
.. confval:: doctest_path
|
.. confval:: doctest_path
|
||||||
|
|
||||||
A list of directories that will be added to :data:`sys.path` when the doctest
|
A list of directories that will be added to :data:`sys.path` when the doctest
|
||||||
|
@ -214,8 +214,7 @@ class DocTestBuilder(Builder):
|
|||||||
|
|
||||||
def init(self):
|
def init(self):
|
||||||
# default options
|
# default options
|
||||||
self.opt = doctest.DONT_ACCEPT_TRUE_FOR_1 | doctest.ELLIPSIS | \
|
self.opt = self.config.doctest_default_flags
|
||||||
doctest.IGNORE_EXCEPTION_DETAIL
|
|
||||||
|
|
||||||
# HACK HACK HACK
|
# HACK HACK HACK
|
||||||
# doctest compiles its snippets with type 'single'. That is nice
|
# doctest compiles its snippets with type 'single'. That is nice
|
||||||
@ -464,4 +463,8 @@ def setup(app):
|
|||||||
app.add_config_value('doctest_test_doctest_blocks', 'default', False)
|
app.add_config_value('doctest_test_doctest_blocks', 'default', False)
|
||||||
app.add_config_value('doctest_global_setup', '', False)
|
app.add_config_value('doctest_global_setup', '', False)
|
||||||
app.add_config_value('doctest_global_cleanup', '', False)
|
app.add_config_value('doctest_global_cleanup', '', False)
|
||||||
|
app.add_config_value(
|
||||||
|
'doctest_default_flags',
|
||||||
|
doctest.DONT_ACCEPT_TRUE_FOR_1 | doctest.ELLIPSIS | doctest.IGNORE_EXCEPTION_DETAIL,
|
||||||
|
False)
|
||||||
return {'version': sphinx.__display_version__, 'parallel_read_safe': True}
|
return {'version': sphinx.__display_version__, 'parallel_read_safe': True}
|
||||||
|
Loading…
Reference in New Issue
Block a user