Bug report
Initial PR and discussion: #111682
So, here's the problem:
Example 1::
>>> 1 + 2
3
Example 2:
.. doctest::
>>> 1 + 2
3
We have two tools: doctest (builtin module) and sphinx (3rd party) that can run these samples as doctests. The problem is that they define "doctest" term differently:
doctest module says that both of these examples are doctests
sphinx says that only example with .. doctest:: directive is a doctest
This is problematic, because not all example are actually executed in CI, right now we have a CI job that uses Sphinx. So, in the result of this we have broken doctest (1st meaning) examples in the docs.
Examples:
What can we do?
Options:
- Add
.. doctest:: directives everywhere, but I think it is too much work and people will forget to do this
- Try to use
doctest_test_doctest_blocks, see docs https://www.sphinx-doc.org/en/master/usage/extensions/doctest.html This is what I plan to do locally and I will send a PR with the results. I fear that quite a lot of doctests might be broken
- Add doctests to
test_* files using something like
def load_tests(loader, tests, pattern):
tests.addTests(doctest.DocFileSuite(
os.path.join(REPO_ROOT, 'Doc/library/LIBNAME.rst'),
module_relative=False,
))
return tests
The last option is also problematic, because right now we can only run doctests in CI, when PR only touches Doc/ folder, I am not sure that it will be easy with this setup.
CC @AlexWaygood @AA-Turner
Linked PRs
Bug report
Initial PR and discussion: #111682
So, here's the problem:
We have two tools:
doctest(builtin module) andsphinx(3rd party) that can run these samples as doctests. The problem is that they define "doctest" term differently:doctestmodule says that both of these examples are doctestssphinxsays that only example with.. doctest::directive is a doctestThis is problematic, because not all example are actually executed in CI, right now we have a CI job that uses Sphinx. So, in the result of this we have broken doctest (1st meaning) examples in the docs.
Examples:
What can we do?
Options:
.. doctest::directives everywhere, but I think it is too much work and people will forget to do thisdoctest_test_doctest_blocks, see docs https://www.sphinx-doc.org/en/master/usage/extensions/doctest.html This is what I plan to do locally and I will send a PR with the results. I fear that quite a lot of doctests might be brokentest_*files using something likeThe last option is also problematic, because right now we can only run doctests in CI, when PR only touches
Doc/folder, I am not sure that it will be easy with this setup.CC @AlexWaygood @AA-Turner
Linked PRs
doctest_test_doctest_blocksoption to Sphinx #111723stdtypes.rstto doctests #136501