Skip to content

pre-commit hook fails but pytest runs fine if called directly #7793

Answered by asottile
deadpyxel asked this question in General
Discussion options

You must be logged in to vote

pre-commit passes filenames as positional arguments and will invoke multiple times in parallel

you're likely confused by one of these behaviours and/or not replicating that same behaviour outside pre-commit (the "no tests discovered" is probably pytest not/a/test/file.py another/not/a/test/file.py for example)

you probably want:

    entry: pytest tests
    pass_filenames: false
    always_run: true

See also this stackoverflow post

but also you probably don't want to run pytest as a pre-commit hook

Replies: 3 comments

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Answer selected by nicoddemus
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
3 participants
Converted from issue

This discussion was converted from issue #7793 on September 25, 2020 13:31.