use*_*562 7 pre-commit-hook pytest python-3.x pre-commit.com
如何获取包含环境变量导出的 bash 脚本?
env.sh
...
export VARIABLE=test
...
Run Code Online (Sandbox Code Playgroud)
test_file.py
...
os.environ['VARIABLE'] # Throws KeyError
...
Run Code Online (Sandbox Code Playgroud)
如何使用预提交运行env.sh来设置以下pytest钩子可以使用的环境?
- repo: local
hooks:
- id: tests
name: run tests
entry: pytest -v
language: system
types: [python]
Run Code Online (Sandbox Code Playgroud)
小智 0
您不应该对 pytest 使用预提交,因为:
来源:https ://github.com/pre-commit/pre-commit-hooks/issues/291
我认为这会解决您的问题:How to passenvironmentvariablestopytest
| 归档时间: |
|
| 查看次数: |
1392 次 |
| 最近记录: |