mirror of
https://github.com/pre-commit/pre-commit.git
synced 2026-02-17 08:14:42 +04:00
Add a check and test to the real top level and improve the warning message
This commit is contained in:
parent
fd9d9d276b
commit
217d31ec1c
2 changed files with 32 additions and 9 deletions
|
|
@ -118,7 +118,7 @@ def test_validate_config_old_list_format_ok(tmpdir):
|
|||
assert not validate_config_main((f.strpath,))
|
||||
|
||||
|
||||
def test_validate_warn_on_unknown_keys_at_top_level(tmpdir, caplog):
|
||||
def test_validate_warn_on_unknown_keys_at_repo_level(tmpdir, caplog):
|
||||
f = tmpdir.join('cfg.yaml')
|
||||
f.write(
|
||||
'- repo: https://gitlab.com/pycqa/flake8\n'
|
||||
|
|
@ -133,8 +133,29 @@ def test_validate_warn_on_unknown_keys_at_top_level(tmpdir, caplog):
|
|||
(
|
||||
'pre_commit',
|
||||
logging.WARNING,
|
||||
'Your pre-commit-config contain these extra keys: args. '
|
||||
'while the only valid keys are: hooks, repo, rev.',
|
||||
'Unexpected config key(s): args',
|
||||
),
|
||||
]
|
||||
|
||||
|
||||
def test_validate_warn_on_unknown_keys_at_top_level(tmpdir, caplog):
|
||||
f = tmpdir.join('cfg.yaml')
|
||||
f.write(
|
||||
'repos:\n'
|
||||
'- repo: https://gitlab.com/pycqa/flake8\n'
|
||||
' rev: 3.7.7\n'
|
||||
' hooks:\n'
|
||||
' - id: flake8\n'
|
||||
'foo:\n'
|
||||
' id: 1.0.0\n',
|
||||
)
|
||||
ret_val = validate_config_main((f.strpath,))
|
||||
assert not ret_val
|
||||
assert caplog.record_tuples == [
|
||||
(
|
||||
'pre_commit',
|
||||
logging.WARNING,
|
||||
'Unexpected config key(s): foo',
|
||||
),
|
||||
]
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue