mirror of
https://github.com/pre-commit/pre-commit-hooks.git
synced 2026-04-06 03:56:54 +00:00
Add print-message pre-commit hook
This commit is contained in:
parent
2f1e5e2abf
commit
88ff7b12f2
4 changed files with 64 additions and 0 deletions
27
tests/print_message_test.py
Normal file
27
tests/print_message_test.py
Normal file
|
|
@ -0,0 +1,27 @@
|
|||
from __future__ import absolute_import
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from pre_commit_hooks.print_message import default_message
|
||||
from pre_commit_hooks.print_message import main
|
||||
|
||||
|
||||
def test_passes_by_default():
|
||||
assert main() == 0
|
||||
|
||||
|
||||
def test_fails_with_fail_flag():
|
||||
assert main(['-f']) > 0
|
||||
assert main(['--f']) > 0
|
||||
|
||||
|
||||
def test_default_message(capsys):
|
||||
main()
|
||||
stdout, _ = capsys.readouterr()
|
||||
assert stdout.strip() == default_message
|
||||
|
||||
|
||||
def test_message_argument(capsys):
|
||||
message = 'a message'
|
||||
main(['-m', message])
|
||||
stdout, _ = capsys.readouterr()
|
||||
assert stdout.strip() == message
|
||||
Loading…
Add table
Add a link
Reference in a new issue