test fail language inline

This commit is contained in:
marsha
2023-02-10 16:18:43 -06:00
parent 4bd1677cda
commit 4fdfb25a52
2 changed files with 14 additions and 24 deletions

View 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')

View File

@@ -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',