当前pytest,我们的覆盖插件运行在tests目录中的测试之上。
pytest
tests
运行从我们的主代码提取的doctest的最简单方法是什么? --doctest-modules不起作用(可能是因为它仅从运行doctests tests)。请注意,我们希望在同一过程中包含doctest(而不是简单地单独调用py.test),因为我们希望在代码覆盖率中考虑doctest。
--doctest-modules
py.test
现在实现了:-)。
要使用,请运行py.test --doctest-modules命令,或使用以下命令设置配置pytest.ini:
py.test --doctest-modules
pytest.ini
$ cat pytest.ini # content of pytest.ini [pytest] addopts = --doctest-modules
手册页:PyTest:模块和测试文件的doctest集成。