Some minor fixups

This commit is contained in:
Anthony Sottile 2017-10-30 09:12:48 -07:00
parent 9db827ef9d
commit 5a8ca2ffbe
8 changed files with 79 additions and 50 deletions

View file

@ -295,6 +295,24 @@ def test_autoupdate_local_hooks_with_out_of_date_repo(
assert new_config_writen['repos'][0] == local_config
def test_autoupdate_meta_hooks(tmpdir, capsys):
cfg = tmpdir.join(C.CONFIG_FILE)
cfg.write(
'repos:\n'
'- repo: meta\n'
' hooks:\n'
' - id: check-useless-excludes\n',
)
ret = autoupdate(Runner(tmpdir.strpath, C.CONFIG_FILE), tags_only=True)
assert ret == 0
assert cfg.read() == (
'repos:\n'
'- repo: meta\n'
' hooks:\n'
' - id: check-useless-excludes\n'
)
def test_updates_old_format_to_new_format(tmpdir, capsys):
cfg = tmpdir.join(C.CONFIG_FILE)
cfg.write(

View file

@ -25,7 +25,7 @@ def test_hook_excludes_everything(
add_config_to_repo(repo, config)
with cwd(repo):
assert check_files_matches_any.main(argv=[]) == 1
assert check_files_matches_any.main(()) == 1
out, _ = capsys.readouterr()
assert 'check-useless-excludes does not apply to this repository' in out
@ -50,7 +50,7 @@ def test_hook_includes_nothing(
add_config_to_repo(repo, config)
with cwd(repo):
assert check_files_matches_any.main(argv=[]) == 1
assert check_files_matches_any.main(()) == 1
out, _ = capsys.readouterr()
assert 'check-useless-excludes does not apply to this repository' in out
@ -75,7 +75,7 @@ def test_hook_types_not_matched(
add_config_to_repo(repo, config)
with cwd(repo):
assert check_files_matches_any.main(argv=[]) == 1
assert check_files_matches_any.main(()) == 1
out, _ = capsys.readouterr()
assert 'check-useless-excludes does not apply to this repository' in out
@ -100,7 +100,7 @@ def test_hook_types_excludes_everything(
add_config_to_repo(repo, config)
with cwd(repo):
assert check_files_matches_any.main(argv=[]) == 1
assert check_files_matches_any.main(()) == 1
out, _ = capsys.readouterr()
assert 'check-useless-excludes does not apply to this repository' in out
@ -124,7 +124,7 @@ def test_valid_includes(
add_config_to_repo(repo, config)
with cwd(repo):
assert check_files_matches_any.main(argv=[]) == 0
assert check_files_matches_any.main(()) == 0
out, _ = capsys.readouterr()
assert out == ''

View file

@ -29,7 +29,7 @@ def test_useless_exclude_global(capsys, tempdir_factory):
add_config_to_repo(repo, config)
with cwd(repo):
assert check_useless_excludes.main(argv=[]) == 1
assert check_useless_excludes.main(()) == 1
out, _ = capsys.readouterr()
assert "The global exclude pattern 'foo' does not match any files" in out
@ -52,7 +52,7 @@ def test_useless_exclude_for_hook(capsys, tempdir_factory):
add_config_to_repo(repo, config)
with cwd(repo):
assert check_useless_excludes.main(argv=[]) == 1
assert check_useless_excludes.main(()) == 1
out, _ = capsys.readouterr()
expected = (
@ -78,7 +78,7 @@ def test_no_excludes(capsys, tempdir_factory):
add_config_to_repo(repo, config)
with cwd(repo):
assert check_useless_excludes.main(argv=[]) == 0
assert check_useless_excludes.main(()) == 0
out, _ = capsys.readouterr()
assert out == ''
@ -101,7 +101,7 @@ def test_valid_exclude(capsys, tempdir_factory):
add_config_to_repo(repo, config)
with cwd(repo):
assert check_useless_excludes.main(argv=[]) == 0
assert check_useless_excludes.main(()) == 0
out, _ = capsys.readouterr()
assert out == ''