mirror of
https://github.com/pre-commit/pre-commit.git
synced 2026-01-30 04:48:39 -06:00
test fail language inline
This commit is contained in:
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
|
||||
|
||||
|
||||
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):
|
||||
config = {
|
||||
'repo': 'local',
|
||||
|
||||
Reference in New Issue
Block a user