只运行受更改影响的测试的pytest插件
pytest-cagoule的Python项目详细描述
pytest cagoule是一个pytest插件,用于查找哪些测试与 你刚改的代码。
用法
使用--cagoule-capture
收集覆盖率信息py.test --cagoule-capture
然后,要运行接触特定文件的测试子集,请使用 cagoule-select=<filename>[:line number],例如
py.test --cagoule-select=path/to/file.py
如果使用git,cagoule可以找到有更改的文件和行 在当前工作目录中:
py.test --diff
或者对于git可以解析的任何其他diff规范,使用--diff=<spec>,例如
py.test --diff=head~1..head
您可能希望配置CI服务器以处理捕获。
安装
使用pip:
安装pytest cagoulepip install pytest-cagoule
注意事项
只捕获在个别测试运行期间执行的行。经常这样 排除在测试之前在import时间执行的模块级代码 开始。而且,测试当然是根据代码注册的 已捕获数据,因此如果使用--diff,则不包括新的测试。
灵感
想法来自nose-knows
许可证
麻省理工学院。有关详细信息,请参见LICENSE。