mirror of
https://github.com/pre-commit/pre-commit.git
synced 2026-02-20 09:34:42 +04:00
Merge pull request #2756 from m-rsha/test-fail
test fail language inline
This commit is contained in:
commit
8f2dfce5d1
2 changed files with 14 additions and 24 deletions
14
tests/languages/fail_test.py
Normal file
14
tests/languages/fail_test.py
Normal file
|
|
@ -0,0 +1,14 @@
|
||||||
|
from __future__ import annotations
|
||||||
|
|
||||||
|
from pre_commit.languages import fail
|
||||||
|
from testing.language_helpers import run_language
|
||||||
|
|
||||||
|
|
||||||
|
def test_fail_hooks(tmp_path):
|
||||||
|
ret = run_language(
|
||||||
|
tmp_path,
|
||||||
|
fail,
|
||||||
|
'watch out for',
|
||||||
|
file_args=('bunnies',),
|
||||||
|
)
|
||||||
|
assert ret == (1, b'watch out for\n\nbunnies\n')
|
||||||
|
|
@ -330,30 +330,6 @@ def test_repository_state_compatibility(tempdir_factory, store, v):
|
||||||
assert _hook_installed(hook) is True
|
assert _hook_installed(hook) is True
|
||||||
|
|
||||||
|
|
||||||
def test_fail_hooks(store):
|
|
||||||
config = {
|
|
||||||
'repo': 'local',
|
|
||||||
'hooks': [{
|
|
||||||
'id': 'fail',
|
|
||||||
'name': 'fail',
|
|
||||||
'language': 'fail',
|
|
||||||
'entry': 'make sure to name changelogs as .rst!',
|
|
||||||
'files': r'changelog/.*(?<!\.rst)$',
|
|
||||||
}],
|
|
||||||
}
|
|
||||||
hook = _get_hook(config, store, 'fail')
|
|
||||||
ret, out = _hook_run(
|
|
||||||
hook, ('changelog/123.bugfix', 'changelog/wat'), color=False,
|
|
||||||
)
|
|
||||||
assert ret == 1
|
|
||||||
assert out == (
|
|
||||||
b'make sure to name changelogs as .rst!\n'
|
|
||||||
b'\n'
|
|
||||||
b'changelog/123.bugfix\n'
|
|
||||||
b'changelog/wat\n'
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
def test_unknown_keys(store, caplog):
|
def test_unknown_keys(store, caplog):
|
||||||
config = {
|
config = {
|
||||||
'repo': 'local',
|
'repo': 'local',
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue