mirror of
https://github.com/pre-commit/pre-commit.git
synced 2026-02-19 09:04:41 +04:00
git mv tests/meta_hooks/{,check_}useless_excludes_test.py
This commit is contained in:
parent
cd116977cc
commit
9d48766c02
1 changed files with 0 additions and 0 deletions
|
|
@ -1,107 +0,0 @@
|
|||
from collections import OrderedDict
|
||||
|
||||
from pre_commit.meta_hooks import check_useless_excludes
|
||||
from testing.fixtures import add_config_to_repo
|
||||
from testing.fixtures import git_dir
|
||||
from testing.util import cwd
|
||||
|
||||
|
||||
def test_useless_exclude_global(capsys, tempdir_factory):
|
||||
config = OrderedDict((
|
||||
('exclude', 'foo'),
|
||||
(
|
||||
'repos', [
|
||||
OrderedDict((
|
||||
('repo', 'meta'),
|
||||
(
|
||||
'hooks', (
|
||||
OrderedDict((
|
||||
('id', 'check-useless-excludes'),
|
||||
)),
|
||||
),
|
||||
),
|
||||
)),
|
||||
],
|
||||
),
|
||||
))
|
||||
|
||||
repo = git_dir(tempdir_factory)
|
||||
add_config_to_repo(repo, config)
|
||||
|
||||
with cwd(repo):
|
||||
assert check_useless_excludes.main(()) == 1
|
||||
|
||||
out, _ = capsys.readouterr()
|
||||
assert "The global exclude pattern 'foo' does not match any files" in out
|
||||
|
||||
|
||||
def test_useless_exclude_for_hook(capsys, tempdir_factory):
|
||||
config = OrderedDict((
|
||||
('repo', 'meta'),
|
||||
(
|
||||
'hooks', (
|
||||
OrderedDict((
|
||||
('id', 'check-useless-excludes'),
|
||||
('exclude', 'foo'),
|
||||
)),
|
||||
),
|
||||
),
|
||||
))
|
||||
|
||||
repo = git_dir(tempdir_factory)
|
||||
add_config_to_repo(repo, config)
|
||||
|
||||
with cwd(repo):
|
||||
assert check_useless_excludes.main(()) == 1
|
||||
|
||||
out, _ = capsys.readouterr()
|
||||
expected = (
|
||||
"The exclude pattern 'foo' for check-useless-excludes "
|
||||
"does not match any files"
|
||||
)
|
||||
assert expected in out
|
||||
|
||||
|
||||
def test_no_excludes(capsys, tempdir_factory):
|
||||
config = OrderedDict((
|
||||
('repo', 'meta'),
|
||||
(
|
||||
'hooks', (
|
||||
OrderedDict((
|
||||
('id', 'check-useless-excludes'),
|
||||
)),
|
||||
),
|
||||
),
|
||||
))
|
||||
|
||||
repo = git_dir(tempdir_factory)
|
||||
add_config_to_repo(repo, config)
|
||||
|
||||
with cwd(repo):
|
||||
assert check_useless_excludes.main(()) == 0
|
||||
|
||||
out, _ = capsys.readouterr()
|
||||
assert out == ''
|
||||
|
||||
|
||||
def test_valid_exclude(capsys, tempdir_factory):
|
||||
config = OrderedDict((
|
||||
('repo', 'meta'),
|
||||
(
|
||||
'hooks', (
|
||||
OrderedDict((
|
||||
('id', 'check-useless-excludes'),
|
||||
('exclude', '.pre-commit-config.yaml'),
|
||||
)),
|
||||
),
|
||||
),
|
||||
))
|
||||
|
||||
repo = git_dir(tempdir_factory)
|
||||
add_config_to_repo(repo, config)
|
||||
|
||||
with cwd(repo):
|
||||
assert check_useless_excludes.main(()) == 0
|
||||
|
||||
out, _ = capsys.readouterr()
|
||||
assert out == ''
|
||||
Loading…
Add table
Add a link
Reference in a new issue