wue*_*eli 1 python git pre-commit-hook pytest pre-commit.com
有没有办法pytest.mark
在预提交挂钩期间排除标记为 的 pytests 运行?特别是,我想排除标记为集成测试的测试。
测试的内容如下所示
pytestmark = [pytest.mark.integration, pytest.mark.reporting_api]
### some tests
Run Code Online (Sandbox Code Playgroud)
配置.pre-commit-conifg.yaml
pytest
是
- repo: local
hooks:
- id: pytest
name: pytest
entry: pytest test/
language: system
pass_filenames: false
types: [python]
stages: [commit, push]
Run Code Online (Sandbox Code Playgroud)
2c:将测试作为其中的一部分运行并不是一个好主意pre-commit
——根据我的经验,它们会太慢,并且您的贡献者可能会感到沮丧并完全关闭框架
也就是说,它应该像添加您想要的参数一样简单,entry
或者args
——我个人更喜欢entry
使用repo: local
钩子(因为没有什么可以“传统地”覆盖args
)
在你的情况下,这看起来像:
- repo: local
hooks:
- id: pytest
name: pytest
entry: pytest test/ -m 'not integration and not reporting_api'
language: system
pass_filenames: false
types: [python]
stages: [commit, push]
Run Code Online (Sandbox Code Playgroud)
免责声明:我创建了预提交,并且我是 pytest 核心开发人员
归档时间: |
|
查看次数: |
1310 次 |
最近记录: |