1- from collections import OrderedDict
2-
31from pre_commit .meta_hooks import check_hooks_apply
42from testing .fixtures import add_config_to_repo
53from testing .fixtures import git_dir
64from testing .util import cwd
75
86
97def test_hook_excludes_everything (capsys , tempdir_factory , mock_store_dir ):
10- config = OrderedDict ((
11- ('repo' , 'meta' ),
12- (
13- 'hooks' , (
14- OrderedDict ((
15- ('id' , 'check-useless-excludes' ),
16- ('exclude' , '.pre-commit-config.yaml' ),
17- )),
18- ),
19- ),
20- ))
8+ config = {
9+ 'repos' : [
10+ {
11+ 'repo' : 'meta' ,
12+ 'hooks' : [
13+ {
14+ 'id' : 'check-useless-excludes' ,
15+ 'exclude' : '.pre-commit-config.yaml' ,
16+ },
17+ ],
18+ },
19+ ],
20+ }
2121
2222 repo = git_dir (tempdir_factory )
2323 add_config_to_repo (repo , config )
@@ -30,17 +30,19 @@ def test_hook_excludes_everything(capsys, tempdir_factory, mock_store_dir):
3030
3131
3232def test_hook_includes_nothing (capsys , tempdir_factory , mock_store_dir ):
33- config = OrderedDict ((
34- ('repo' , 'meta' ),
35- (
36- 'hooks' , (
37- OrderedDict ((
38- ('id' , 'check-useless-excludes' ),
39- ('files' , 'foo' ),
40- )),
41- ),
42- ),
43- ))
33+ config = {
34+ 'repos' : [
35+ {
36+ 'repo' : 'meta' ,
37+ 'hooks' : [
38+ {
39+ 'id' : 'check-useless-excludes' ,
40+ 'files' : 'foo' ,
41+ },
42+ ],
43+ },
44+ ],
45+ }
4446
4547 repo = git_dir (tempdir_factory )
4648 add_config_to_repo (repo , config )
@@ -53,17 +55,19 @@ def test_hook_includes_nothing(capsys, tempdir_factory, mock_store_dir):
5355
5456
5557def test_hook_types_not_matched (capsys , tempdir_factory , mock_store_dir ):
56- config = OrderedDict ((
57- ('repo' , 'meta' ),
58- (
59- 'hooks' , (
60- OrderedDict ((
61- ('id' , 'check-useless-excludes' ),
62- ('types' , ['python' ]),
63- )),
64- ),
65- ),
66- ))
58+ config = {
59+ 'repos' : [
60+ {
61+ 'repo' : 'meta' ,
62+ 'hooks' : [
63+ {
64+ 'id' : 'check-useless-excludes' ,
65+ 'types' : ['python' ],
66+ },
67+ ],
68+ },
69+ ],
70+ }
6771
6872 repo = git_dir (tempdir_factory )
6973 add_config_to_repo (repo , config )
@@ -78,17 +82,19 @@ def test_hook_types_not_matched(capsys, tempdir_factory, mock_store_dir):
7882def test_hook_types_excludes_everything (
7983 capsys , tempdir_factory , mock_store_dir ,
8084):
81- config = OrderedDict ((
82- ('repo' , 'meta' ),
83- (
84- 'hooks' , (
85- OrderedDict ((
86- ('id' , 'check-useless-excludes' ),
87- ('exclude_types' , ['yaml' ]),
88- )),
89- ),
90- ),
91- ))
85+ config = {
86+ 'repos' : [
87+ {
88+ 'repo' : 'meta' ,
89+ 'hooks' : [
90+ {
91+ 'id' : 'check-useless-excludes' ,
92+ 'exclude_types' : ['yaml' ],
93+ },
94+ ],
95+ },
96+ ],
97+ }
9298
9399 repo = git_dir (tempdir_factory )
94100 add_config_to_repo (repo , config )
@@ -101,22 +107,21 @@ def test_hook_types_excludes_everything(
101107
102108
103109def test_valid_includes (capsys , tempdir_factory , mock_store_dir ):
104- config = OrderedDict ((
105- ('repo' , 'meta' ),
106- (
107- 'hooks' , (
108- OrderedDict ((
109- ('id' , 'check-useless-excludes' ),
110- )),
111- # Should not be reported as an error due to always_run
112- OrderedDict ((
113- ('id' , 'check-useless-excludes' ),
114- ('files' , '^$' ),
115- ('always_run' , True ),
116- )),
117- ),
118- ),
119- ))
110+ config = {
111+ 'repos' : [
112+ {
113+ 'repo' : 'meta' ,
114+ 'hooks' : [
115+ # Should not be reported as an error due to always_run
116+ {
117+ 'id' : 'check-useless-excludes' ,
118+ 'files' : '^$' ,
119+ 'always_run' : True ,
120+ },
121+ ],
122+ },
123+ ],
124+ }
120125
121126 repo = git_dir (tempdir_factory )
122127 add_config_to_repo (repo , config )
0 commit comments