测试 API

版本 1.6 中新增。

sphinx.testing 中提供了用于测试的实用函数和 pytest 装置。如果您是 Sphinx 扩展的开发者,您可以使用 pytest 编写单元测试。

pytest 配置

要使用 sphinx.testing 提供的 pytest 装置,请将 'sphinx.testing.fixtures' 插件添加到您的测试模块或 conftest.py 文件中,如下所示:

pytest_plugins = ('sphinx.testing.fixtures',)

用法

如果您想了解更详细的用法,请参阅 tests/conftest.py 以及 tests/ 目录下的其他 test_*.py 文件。