小编典典

如何使pytest运行doctests以及普通测试目录?

python

当前pytest,我们的覆盖插件运行在tests目录中的测试之上。

运行从我们的主代码提取的doctest的最简单方法是什么? --doctest-modules不起作用(可能是因为它仅从运行doctests
tests)。请注意,我们希望在同一过程中包含doctest(而不是简单地单独调用py.test),因为我们希望在代码覆盖率中考虑doctest。


阅读 189

收藏
2021-01-20

共1个答案

小编典典

现在实现了:-)。

要使用,请运行py.test --doctest-modules命令,或使用以下命令设置配置pytest.ini

$ cat pytest.ini
# content of pytest.ini
[pytest]
addopts = --doctest-modules

手册页:PyTest:模块和测试文件的doctest集成。

2021-01-20