No need for OrderedDict

This commit is contained in:
Anthony Sottile 2018-09-02 18:45:21 -07:00
parent 9d48766c02
commit 21c2c9df33
2 changed files with 109 additions and 115 deletions

View file

@ -1,5 +1,3 @@
from collections import OrderedDict
from pre_commit.meta_hooks import check_hooks_apply
from testing.fixtures import add_config_to_repo
from testing.fixtures import git_dir
@ -7,17 +5,19 @@ from testing.util import cwd
def test_hook_excludes_everything(capsys, tempdir_factory, mock_store_dir):
config = OrderedDict((
('repo', 'meta'),
(
'hooks', (
OrderedDict((
('id', 'check-useless-excludes'),
('exclude', '.pre-commit-config.yaml'),
)),
),
),
))
config = {
'repos': [
{
'repo': 'meta',
'hooks': [
{
'id': 'check-useless-excludes',
'exclude': '.pre-commit-config.yaml',
},
],
},
],
}
repo = git_dir(tempdir_factory)
add_config_to_repo(repo, config)
@ -30,17 +30,19 @@ def test_hook_excludes_everything(capsys, tempdir_factory, mock_store_dir):
def test_hook_includes_nothing(capsys, tempdir_factory, mock_store_dir):
config = OrderedDict((
('repo', 'meta'),
(
'hooks', (
OrderedDict((
('id', 'check-useless-excludes'),
('files', 'foo'),
)),
),
),
))
config = {
'repos': [
{
'repo': 'meta',
'hooks': [
{
'id': 'check-useless-excludes',
'files': 'foo',
},
],
},
],
}
repo = git_dir(tempdir_factory)
add_config_to_repo(repo, config)
@ -53,17 +55,19 @@ def test_hook_includes_nothing(capsys, tempdir_factory, mock_store_dir):
def test_hook_types_not_matched(capsys, tempdir_factory, mock_store_dir):
config = OrderedDict((
('repo', 'meta'),
(
'hooks', (
OrderedDict((
('id', 'check-useless-excludes'),
('types', ['python']),
)),
),
),
))
config = {
'repos': [
{
'repo': 'meta',
'hooks': [
{
'id': 'check-useless-excludes',
'types': ['python'],
},
],
},
],
}
repo = git_dir(tempdir_factory)
add_config_to_repo(repo, config)
@ -78,17 +82,19 @@ def test_hook_types_not_matched(capsys, tempdir_factory, mock_store_dir):
def test_hook_types_excludes_everything(
capsys, tempdir_factory, mock_store_dir,
):
config = OrderedDict((
('repo', 'meta'),
(
'hooks', (
OrderedDict((
('id', 'check-useless-excludes'),
('exclude_types', ['yaml']),
)),
),
),
))
config = {
'repos': [
{
'repo': 'meta',
'hooks': [
{
'id': 'check-useless-excludes',
'exclude_types': ['yaml'],
},
],
},
],
}
repo = git_dir(tempdir_factory)
add_config_to_repo(repo, config)
@ -101,22 +107,21 @@ def test_hook_types_excludes_everything(
def test_valid_includes(capsys, tempdir_factory, mock_store_dir):
config = OrderedDict((
('repo', 'meta'),
(
'hooks', (
OrderedDict((
('id', 'check-useless-excludes'),
)),
# Should not be reported as an error due to always_run
OrderedDict((
('id', 'check-useless-excludes'),
('files', '^$'),
('always_run', True),
)),
),
),
))
config = {
'repos': [
{
'repo': 'meta',
'hooks': [
# Should not be reported as an error due to always_run
{
'id': 'check-useless-excludes',
'files': '^$',
'always_run': True,
},
],
},
],
}
repo = git_dir(tempdir_factory)
add_config_to_repo(repo, config)