pytest文档工具
pytest-docs的Python项目详细描述
生成测试应用程序本身文档的pytest插件。
功能
创建测试文档。转动此按钮:
'''This is the module doc''' import pytest pytestmark = [ pytest.mark.module_mark, pytest.mark.module_mark_2, pytest.mark.pytest_doc(name="Test Docs"), ] @pytest.mark.class_marker @pytest.mark.pytest_doc(name="Test Class") class TestClass: '''This is the class doc''' @pytest.mark.func_mark_a("foo") def test_func_a(self): '''This is the doc for test_func_a''' assert 1 @pytest.mark.kwarg_mark(goo="bla") def test_func_b(self): '''This is the doc for test_func_b''' assert 1
对此:
# Test Docs This is the module doc **Markers:** - module_mark - module_mark_2 - pytest_doc (name=Test Docs) ## Test Class This is the class doc **Markers:** - pytest_doc (name=Test Class) - class_marker ### test_func_a This is the doc for test_func_a **Markers:** - func_mark_a (foo) ### test_func_b This is the doc for test_func_b **Markers:** - kwarg_mark (goo=bla)
当前支持的格式:
- 降价
- 重新剪切的文本
为什么不是狮身人面像?
(更准确地说,为什么不是斯芬克斯Autodoc?) 狮身人面像是一个很棒的工具,我在其他项目中使用过。要使用其autodoc插件,它需要由python interperter导入文档化的插件。pytest测试收集和调用使用完全独立的机制。 如果您认为可以使用sphinx创建pytest文档,请随时与我联系。
要求
- python 3.4、3.5、3.6或3.7
- Pytest=3.5.0
用法
使用--docs [PATH]创建文档。
使用--doc-type选择类型(当前支持md和rst)
使用@pytest.mark.pytest_doc(name="Test Class")重写元素的名称。它将根据正在使用的位置(模块、类或函数)重写名称。
注意:pytest文档使用pytest收集机制,因此您的文档将根据用于运行测试的常用收集命令生成。
未来计划
- 看看是否有人对此感兴趣
- 文件固定装置
- 记录测试和夹具参数化
- 通过挂钩自定义格式化程序
贡献
我们非常欢迎您的贡献。测试可以用tox运行,请确保 在提交请求之前,覆盖范围至少保持不变。
许可证
“pytest docs”是根据MIT许可证的条款发布的免费开源软件
问题
如果您遇到任何问题,请file an issue连同详细说明。
这个pytest插件是用Cookiecutter和@hackebrot的cookiecutter-pytest-plugin模板生成的。