我希望pre-commit
在提交代码之前运行测试。
该命令python -m unittest discover
在命令行中运行。
D:\project_dir>python -m unittest discover
...
...
...
----------------------------------------------------------------------
Ran 5 tests in 6.743s
OK
但是当我试图提交时,我得到了
D:\project_dir>git commit -m "fix tests with hook"
run tests................................................................Failed
hookid: tests
usage: python.exe -m unittest discover [-h] [-v] [-q] [--locals] [-f] [-c]
[-b] [-k TESTNAMEPATTERNS] [-s START]
[-p PATTERN] [-t TOP]
python.exe -m unittest discover: error: unrecognized arguments: bigpipe_response/processors_manager.py
usage: python.exe -m unittest discover [-h] [-v] [-q] [--locals] [-f] [-c]
[-b] [-k TESTNAMEPATTERNS] [-s START]
[-p PATTERN] [-t TOP]
python.exe -m unittest discover: error: unrecognized arguments: tests/test_processors.py
这是我的.pre-commit-config.yaml
文件。
- repo: local
hooks:
- id: tests
name: run tests
entry: python -m unittest discover
language: python
types: [python]
stages: [commit]
另外对于我尝试使用的语言system
。我得到了同样的结果。
我该如何解决这个问题?请帮忙。