Ejemplo n.º 1
0
def test_validate_config_skip_missing_config(capsys):
    with pytest.raises(SystemExit) as excinfo:
        hook_impl._validate_config(123, 'DNE.yaml', True)
    ret, = excinfo.value.args
    assert ret == 123
    expected = '`DNE.yaml` config file not found. Skipping `pre-commit`.\n'
    assert capsys.readouterr().out == expected
Ejemplo n.º 2
0
def test_validate_config_skip_via_env_variable(capsys):
    with pytest.raises(SystemExit) as excinfo:
        with envcontext((('PRE_COMMIT_ALLOW_NO_CONFIG', '1'), )):
            hook_impl._validate_config(0, 'DNE.yaml', False)
    ret, = excinfo.value.args
    assert ret == 0
    expected = '`DNE.yaml` config file not found. Skipping `pre-commit`.\n'
    assert capsys.readouterr().out == expected
Ejemplo n.º 3
0
def test_validate_config_missing(capsys):
    with pytest.raises(SystemExit) as excinfo:
        hook_impl._validate_config(123, 'DNE.yaml', False)
    ret, = excinfo.value.args
    assert ret == 1
    assert capsys.readouterr().out == (
        'No DNE.yaml file was found\n'
        '- To temporarily silence this, run '
        '`PRE_COMMIT_ALLOW_NO_CONFIG=1 git ...`\n'
        '- To permanently silence this, install pre-commit with the '
        '--allow-missing-config option\n'
        '- To uninstall pre-commit run `pre-commit uninstall`\n')
Ejemplo n.º 4
0
def test_validate_config_file_exists(tmpdir):
    cfg = tmpdir.join(C.CONFIG_FILE).ensure()
    hook_impl._validate_config(0, cfg, True)