【问题标题】:doctest running in sphinx doc在 sphinx doc 中运行的 doctest
【发布时间】:2020-04-23 14:59:28
【问题描述】:

我正在尝试运行我的第一个文档中编写的 doctest。但我不知道如何运行它。我写了以下内容:

.. doctest::

    >>> 43 + 1
    45

然后我做:

$ make html

但文档已成功构建。

我也很感兴趣,如果一个人可以在不构建 html 文档的情况下运行测试?

提前谢谢你。

【问题讨论】:

  • 查看doctest docs了解配置和使用方法。
  • 你试过“make doctest”吗?
  • >你试过“make doctest”吗?它运行所有 doctest(甚至从代码中)。也许只能从一些开始运行?
  • 使用python -m doctest -v example.rst怎么样?见docs.python.org/3/library/…
  • 请更新问题并向我们展示您尝试过的方法和无效的方法。

标签: python-sphinx restructuredtext doctest


【解决方案1】:

所以,这实际上并没有那么难。我应该只运行以下命令:

$ pytest 'path to static rst files' --doctest-glob=*.rst --doctest-module

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-10-03
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多