@@ -56,94 +56,100 @@ def test_validate_config_main(args, expected_output):
5656 assert validate_config_main (args ) == expected_output
5757
5858
59- @pytest .mark .parametrize (('config_obj' , 'expected' ), (
60- ([], False ),
61- (
62- [{
63- 'repo' : 'git@github.com:pre-commit/pre-commit-hooks' ,
64- 'sha' : 'cd74dc150c142c3be70b24eaf0b02cae9d235f37' ,
65- 'hooks' : [{'id' : 'pyflakes' , 'files' : '\\ .py$' }],
66- }],
67- True ,
68- ),
69- (
70- [{
71- 'repo' : 'git@github.com:pre-commit/pre-commit-hooks' ,
72- 'sha' : 'cd74dc150c142c3be70b24eaf0b02cae9d235f37' ,
73- 'hooks' : [
74- {
75- 'id' : 'pyflakes' ,
76- 'files' : '\\ .py$' ,
77- 'args' : ['foo' , 'bar' , 'baz' ],
78- },
79- ],
80- }],
81- True ,
82- ),
83- (
84- [{
85- 'repo' : 'git@github.com:pre-commit/pre-commit-hooks' ,
86- 'sha' : 'cd74dc150c142c3be70b24eaf0b02cae9d235f37' ,
87- 'hooks' : [
88- {
89- 'id' : 'pyflakes' ,
90- 'files' : '\\ .py$' ,
91- # Exclude pattern must be a string
92- 'exclude' : 0 ,
93- 'args' : ['foo' , 'bar' , 'baz' ],
94- },
95- ],
96- }],
97- False ,
59+ @pytest .mark .parametrize (
60+ ('config_obj' , 'expected' ), (
61+ ([], False ),
62+ (
63+ [{
64+ 'repo' : 'git@github.com:pre-commit/pre-commit-hooks' ,
65+ 'sha' : 'cd74dc150c142c3be70b24eaf0b02cae9d235f37' ,
66+ 'hooks' : [{'id' : 'pyflakes' , 'files' : '\\ .py$' }],
67+ }],
68+ True ,
69+ ),
70+ (
71+ [{
72+ 'repo' : 'git@github.com:pre-commit/pre-commit-hooks' ,
73+ 'sha' : 'cd74dc150c142c3be70b24eaf0b02cae9d235f37' ,
74+ 'hooks' : [
75+ {
76+ 'id' : 'pyflakes' ,
77+ 'files' : '\\ .py$' ,
78+ 'args' : ['foo' , 'bar' , 'baz' ],
79+ },
80+ ],
81+ }],
82+ True ,
83+ ),
84+ (
85+ [{
86+ 'repo' : 'git@github.com:pre-commit/pre-commit-hooks' ,
87+ 'sha' : 'cd74dc150c142c3be70b24eaf0b02cae9d235f37' ,
88+ 'hooks' : [
89+ {
90+ 'id' : 'pyflakes' ,
91+ 'files' : '\\ .py$' ,
92+ # Exclude pattern must be a string
93+ 'exclude' : 0 ,
94+ 'args' : ['foo' , 'bar' , 'baz' ],
95+ },
96+ ],
97+ }],
98+ False ,
99+ ),
98100 ),
99- ))
101+ )
100102def test_config_valid (config_obj , expected ):
101103 ret = is_valid_according_to_schema (config_obj , CONFIG_SCHEMA )
102104 assert ret is expected
103105
104106
105- @pytest .mark .parametrize ('config_obj' , (
106- [{
107- 'repo' : 'local' ,
108- 'sha' : 'foo' ,
109- 'hooks' : [{
110- 'id' : 'do_not_commit' ,
111- 'name' : 'Block if "DO NOT COMMIT" is found' ,
112- 'entry' : 'DO NOT COMMIT' ,
113- 'language' : 'pcre' ,
114- 'files' : '^(.*)$' ,
107+ @pytest .mark .parametrize (
108+ 'config_obj' , (
109+ [{
110+ 'repo' : 'local' ,
111+ 'sha' : 'foo' ,
112+ 'hooks' : [{
113+ 'id' : 'do_not_commit' ,
114+ 'name' : 'Block if "DO NOT COMMIT" is found' ,
115+ 'entry' : 'DO NOT COMMIT' ,
116+ 'language' : 'pcre' ,
117+ 'files' : '^(.*)$' ,
118+ }],
115119 }],
116- }] ,
117- ))
120+ ) ,
121+ )
118122def test_config_with_local_hooks_definition_fails (config_obj ):
119123 with pytest .raises (schema .ValidationError ):
120124 schema .validate (config_obj , CONFIG_SCHEMA )
121125
122126
123- @pytest .mark .parametrize ('config_obj' , (
124- [{
125- 'repo' : 'local' ,
126- 'hooks' : [{
127- 'id' : 'arg-per-line' ,
128- 'name' : 'Args per line hook' ,
129- 'entry' : 'bin/hook.sh' ,
130- 'language' : 'script' ,
131- 'files' : '' ,
132- 'args' : ['hello' , 'world' ],
127+ @pytest .mark .parametrize (
128+ 'config_obj' , (
129+ [{
130+ 'repo' : 'local' ,
131+ 'hooks' : [{
132+ 'id' : 'arg-per-line' ,
133+ 'name' : 'Args per line hook' ,
134+ 'entry' : 'bin/hook.sh' ,
135+ 'language' : 'script' ,
136+ 'files' : '' ,
137+ 'args' : ['hello' , 'world' ],
138+ }],
133139 }],
134- }],
135- [{
136- 'repo ' : 'local' ,
137- 'hooks ' : [{
138- 'id ' : 'arg- per- line' ,
139- 'name ' : 'Args per line hook' ,
140- 'entry ' : 'bin/hook.sh ' ,
141- 'language ' : 'script ' ,
142- 'files ' : '' ,
143- 'args' : [ 'hello' , 'world' ],
144- }]
145- }] ,
146- ))
140+ [{
141+ 'repo' : 'local' ,
142+ 'hooks ' : [{
143+ 'id ' : 'arg-per-line' ,
144+ 'name ' : 'Args per line hook ' ,
145+ 'entry ' : 'bin/ hook.sh ' ,
146+ 'language ' : 'script ' ,
147+ 'files ' : '' ,
148+ 'args ' : [ 'hello' , 'world' ] ,
149+ }]
150+ }],
151+ ) ,
152+ )
147153def test_config_with_local_hooks_definition_passes (config_obj ):
148154 schema .validate (config_obj , CONFIG_SCHEMA )
149155
0 commit comments