예제 #1
0
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,
            'pre-commit-validate-config is deprecated -- '
            'use `pre-commit validate-config` instead.',
        ),
        (
            'pre_commit',
            logging.WARNING,
            'Unexpected key(s) present at root: foo',
        ),
    ]
예제 #2
0
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'
        '    rev: 3.7.7\n'
        '    hooks:\n'
        '    -   id: flake8\n'
        '    args: [--some-args]\n', )
    ret_val = validate_config_main((f.strpath, ))
    assert not ret_val
    assert caplog.record_tuples == [
        (
            'pre_commit',
            logging.WARNING,
            'Unexpected config key(s): args',
        ),
    ]
예제 #3
0
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'
        '    rev: 3.7.7\n'
        '    hooks:\n'
        '    -   id: flake8\n'
        '    args: [--some-args]\n',
    )
    ret_val = validate_config_main((f.strpath,))
    assert not ret_val
    assert caplog.record_tuples == [
        (
            'pre_commit',
            logging.WARNING,
            'Unexpected key(s) present on https://gitlab.com/pycqa/flake8: '
            'args',
        ),
    ]
예제 #4
0
def test_validate_config_main(args, expected_output):
    assert validate_config_main(args) == expected_output
예제 #5
0
def test_validate_config_old_list_format_ok(tmpdir, cap_out):
    f = tmpdir.join('cfg.yaml')
    f.write('-  {repo: meta, hooks: [{id: identity}]}')
    assert not validate_config_main((f.strpath,))
    start = '[WARNING] normalizing pre-commit configuration to a top-level map'
    assert cap_out.get().startswith(start)
예제 #6
0
def test_validate_config_main_ok():
    assert not validate_config_main(('.pre-commit-config.yaml',))
예제 #7
0
def test_validate_config_old_list_format_ok(tmpdir):
    f = tmpdir.join('cfg.yaml')
    f.write('-  {repo: meta, hooks: [{id: identity}]}')
    assert not validate_config_main((f.strpath, ))
예제 #8
0
def test_validate_config_old_list_format_ok(tmpdir):
    f = tmpdir.join('cfg.yaml')
    f.write('-  {repo: meta, hooks: [{id: identity}]}')
    assert not validate_config_main((f.strpath,))
예제 #9
0
def test_validate_config_main_ok():
    assert not validate_config_main(('.pre-commit-config.yaml',))
예제 #10
0
def test_validate_config_main(args, expected_output):
    assert validate_config_main(args) == expected_output