I wish pre-commit
to run the tests before committing my code.
The command python -m unittest discover
is working in the command line.
D:\project_dir>python -m unittest discover
...
...
...
----------------------------------------------------------------------
Ran 5 tests in 6.743s
OK
But when trying to commit I am getting
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
Here is my .pre-commit-config.yaml
file.
- repo: local
hooks:
- id: tests
name: run tests
entry: python -m unittest discover
language: python
types: [python]
stages: [commit]
Also for language I try to use system
. I got the same result.
How can I solve this? Please help.
.pre-commit-config.yaml
file. All git understands are scripts in the.git/hooks/
folder. It looks like the program that uses this file is the pre-commit program. – Extrados