@@ -123,12 +123,12 @@ def test_check_conventional_commit_succeeds(
123123 ),
124124 ),
125125)
126- def test_check_no_conventional_commit (commit_msg , config , tmpdir ):
126+ def test_check_no_conventional_commit (commit_msg , default_config , tmpdir ):
127127 tempfile = tmpdir .join ("temp_commit_file" )
128128 tempfile .write (commit_msg )
129129
130130 with pytest .raises (InvalidCommitMessageError ):
131- commands .Check (config = config , arguments = {"commit_msg_file" : tempfile })()
131+ commands .Check (config = default_config , arguments = {"commit_msg_file" : tempfile })()
132132
133133
134134@pytest .mark .parametrize (
@@ -140,44 +140,50 @@ def test_check_no_conventional_commit(commit_msg, config, tmpdir):
140140 "bump: 0.0.1 -> 1.0.0" ,
141141 ),
142142)
143- def test_check_conventional_commit (commit_msg , config , success_mock : MockType , tmpdir ):
143+ def test_check_conventional_commit (
144+ commit_msg , default_config , success_mock : MockType , tmpdir
145+ ):
144146 tempfile = tmpdir .join ("temp_commit_file" )
145147 tempfile .write (commit_msg )
146- commands .Check (config = config , arguments = {"commit_msg_file" : tempfile })()
148+ commands .Check (config = default_config , arguments = {"commit_msg_file" : tempfile })()
147149 success_mock .assert_called_once ()
148150
149151
150- def test_check_command_when_commit_file_not_found (config ):
152+ def test_check_command_when_commit_file_not_found (default_config ):
151153 with pytest .raises (FileNotFoundError ):
152- commands .Check (config = config , arguments = {"commit_msg_file" : "no_such_file" })()
154+ commands .Check (
155+ config = default_config , arguments = {"commit_msg_file" : "no_such_file" }
156+ )()
153157
154158
155159def test_check_a_range_of_git_commits (
156- config , success_mock : MockType , mocker : MockFixture
160+ default_config , success_mock : MockType , mocker : MockFixture
157161):
158162 mocker .patch (
159163 "commitizen.git.get_commits" , return_value = _build_fake_git_commits (COMMIT_LOG )
160164 )
161165
162- commands .Check (config = config , arguments = {"rev_range" : "HEAD~10..master" })()
166+ commands .Check (config = default_config , arguments = {"rev_range" : "HEAD~10..master" })()
163167 success_mock .assert_called_once ()
164168
165169
166- def test_check_a_range_of_git_commits_and_failed (config , mocker : MockFixture ):
170+ def test_check_a_range_of_git_commits_and_failed (default_config , mocker : MockFixture ):
167171 mocker .patch (
168172 "commitizen.git.get_commits" ,
169173 return_value = _build_fake_git_commits (["This commit does not follow rule" ]),
170174 )
171175
172176 with pytest .raises (InvalidCommitMessageError ) as excinfo :
173- commands .Check (config = config , arguments = {"rev_range" : "HEAD~10..master" })()
177+ commands .Check (
178+ config = default_config , arguments = {"rev_range" : "HEAD~10..master" }
179+ )()
174180 assert "This commit does not follow rule" in str (excinfo .value )
175181
176182
177- def test_check_command_with_invalid_argument (config ):
183+ def test_check_command_with_invalid_argument (default_config ):
178184 with pytest .raises (InvalidCommandArgumentError ) as excinfo :
179185 commands .Check (
180- config = config ,
186+ config = default_config ,
181187 arguments = {"commit_msg_file" : "some_file" , "rev_range" : "HEAD~10..master" },
182188 )
183189 assert (
@@ -187,15 +193,17 @@ def test_check_command_with_invalid_argument(config):
187193
188194
189195@pytest .mark .usefixtures ("tmp_commitizen_project" )
190- def test_check_command_with_empty_range (config : BaseConfig , util : UtilFixture ):
196+ def test_check_command_with_empty_range (default_config : BaseConfig , util : UtilFixture ):
191197 # must initialize git with a commit
192198 util .create_file_and_commit ("feat: initial" )
193199 with pytest .raises (NoCommitsFoundError ) as excinfo :
194- commands .Check (config = config , arguments = {"rev_range" : "master..master" })()
200+ commands .Check (
201+ config = default_config , arguments = {"rev_range" : "master..master" }
202+ )()
195203 assert "No commit found with range: 'master..master'" in str (excinfo )
196204
197205
198- def test_check_a_range_of_failed_git_commits (config , mocker : MockFixture ):
206+ def test_check_a_range_of_failed_git_commits (default_config , mocker : MockFixture ):
199207 ill_formatted_commits_msgs = [
200208 "First commit does not follow rule" ,
201209 "Second commit does not follow rule" ,
@@ -207,59 +215,66 @@ def test_check_a_range_of_failed_git_commits(config, mocker: MockFixture):
207215 )
208216
209217 with pytest .raises (InvalidCommitMessageError ) as excinfo :
210- commands .Check (config = config , arguments = {"rev_range" : "HEAD~10..master" })()
218+ commands .Check (
219+ config = default_config , arguments = {"rev_range" : "HEAD~10..master" }
220+ )()
211221 assert all ([msg in str (excinfo .value ) for msg in ill_formatted_commits_msgs ])
212222
213223
214- def test_check_command_with_valid_message (config , success_mock : MockType ):
224+ def test_check_command_with_valid_message (default_config , success_mock : MockType ):
215225 commands .Check (
216- config = config , arguments = {"message" : "fix(scope): some commit message" }
226+ config = default_config ,
227+ arguments = {"message" : "fix(scope): some commit message" },
217228 )()
218229 success_mock .assert_called_once ()
219230
220231
221232@pytest .mark .parametrize ("message" , ["bad commit" , "" ])
222- def test_check_command_with_invalid_message (config , message ):
233+ def test_check_command_with_invalid_message (default_config , message ):
223234 with pytest .raises (InvalidCommitMessageError ):
224- commands .Check (config = config , arguments = {"message" : message })()
235+ commands .Check (config = default_config , arguments = {"message" : message })()
225236
226237
227- def test_check_command_with_allow_abort_arg (config , success_mock ):
228- commands .Check (config = config , arguments = {"message" : "" , "allow_abort" : True })()
238+ def test_check_command_with_allow_abort_arg (default_config , success_mock ):
239+ commands .Check (
240+ config = default_config , arguments = {"message" : "" , "allow_abort" : True }
241+ )()
229242 success_mock .assert_called_once ()
230243
231244
232- def test_check_command_with_allow_abort_config (config , success_mock ):
233- config .settings ["allow_abort" ] = True
234- commands .Check (config = config , arguments = {"message" : "" })()
245+ def test_check_command_with_allow_abort_config (default_config , success_mock ):
246+ default_config .settings ["allow_abort" ] = True
247+ commands .Check (config = default_config , arguments = {"message" : "" })()
235248 success_mock .assert_called_once ()
236249
237250
238- def test_check_command_override_allow_abort_config (config ):
239- config .settings ["allow_abort" ] = True
251+ def test_check_command_override_allow_abort_config (default_config ):
252+ default_config .settings ["allow_abort" ] = True
240253 with pytest .raises (InvalidCommitMessageError ):
241- commands .Check (config = config , arguments = {"message" : "" , "allow_abort" : False })()
254+ commands .Check (
255+ config = default_config , arguments = {"message" : "" , "allow_abort" : False }
256+ )()
242257
243258
244- def test_check_command_with_allowed_prefixes_arg (config , success_mock ):
259+ def test_check_command_with_allowed_prefixes_arg (default_config , success_mock ):
245260 commands .Check (
246- config = config ,
261+ config = default_config ,
247262 arguments = {"message" : "custom! test" , "allowed_prefixes" : ["custom!" ]},
248263 )()
249264 success_mock .assert_called_once ()
250265
251266
252- def test_check_command_with_allowed_prefixes_config (config , success_mock ):
253- config .settings ["allowed_prefixes" ] = ["custom!" ]
254- commands .Check (config = config , arguments = {"message" : "custom! test" })()
267+ def test_check_command_with_allowed_prefixes_config (default_config , success_mock ):
268+ default_config .settings ["allowed_prefixes" ] = ["custom!" ]
269+ commands .Check (config = default_config , arguments = {"message" : "custom! test" })()
255270 success_mock .assert_called_once ()
256271
257272
258- def test_check_command_override_allowed_prefixes_config (config ):
259- config .settings ["allow_abort" ] = ["fixup!" ]
273+ def test_check_command_override_allowed_prefixes_config (default_config ):
274+ default_config .settings ["allow_abort" ] = ["fixup!" ]
260275 with pytest .raises (InvalidCommitMessageError ):
261276 commands .Check (
262- config = config ,
277+ config = default_config ,
263278 arguments = {"message" : "fixup! test" , "allowed_prefixes" : ["custom!" ]},
264279 )()
265280
@@ -336,58 +351,58 @@ def test_check_conventional_commit_succeed_with_git_diff(
336351 assert "Commit validation: successful!" in out
337352
338353
339- def test_check_command_with_message_length_limit (config , success_mock ):
354+ def test_check_command_with_message_length_limit (default_config , success_mock ):
340355 message = "fix(scope): some commit message"
341356 commands .Check (
342- config = config ,
357+ config = default_config ,
343358 arguments = {"message" : message , "message_length_limit" : len (message ) + 1 },
344359 )()
345360 success_mock .assert_called_once ()
346361
347362
348- def test_check_command_with_message_length_limit_exceeded (config ):
363+ def test_check_command_with_message_length_limit_exceeded (default_config ):
349364 message = "fix(scope): some commit message"
350365 with pytest .raises (CommitMessageLengthExceededError ):
351366 commands .Check (
352- config = config ,
367+ config = default_config ,
353368 arguments = {"message" : message , "message_length_limit" : len (message ) - 1 },
354369 )()
355370
356371
357- def test_check_command_with_amend_prefix_default (config , success_mock ):
358- commands .Check (config = config , arguments = {"message" : "amend! test" })()
372+ def test_check_command_with_amend_prefix_default (default_config , success_mock ):
373+ commands .Check (config = default_config , arguments = {"message" : "amend! test" })()
359374 success_mock .assert_called_once ()
360375
361376
362- def test_check_command_with_config_message_length_limit (config , success_mock ):
377+ def test_check_command_with_config_message_length_limit (default_config , success_mock ):
363378 message = "fix(scope): some commit message"
364- config .settings ["message_length_limit" ] = len (message ) + 1
379+ default_config .settings ["message_length_limit" ] = len (message ) + 1
365380 commands .Check (
366- config = config ,
381+ config = default_config ,
367382 arguments = {"message" : message },
368383 )()
369384 success_mock .assert_called_once ()
370385
371386
372- def test_check_command_with_config_message_length_limit_exceeded (config ):
387+ def test_check_command_with_config_message_length_limit_exceeded (default_config ):
373388 message = "fix(scope): some commit message"
374- config .settings ["message_length_limit" ] = len (message ) - 1
389+ default_config .settings ["message_length_limit" ] = len (message ) - 1
375390 with pytest .raises (CommitMessageLengthExceededError ):
376391 commands .Check (
377- config = config ,
392+ config = default_config ,
378393 arguments = {"message" : message },
379394 )()
380395
381396
382397def test_check_command_cli_overrides_config_message_length_limit (
383- config , success_mock : MockType
398+ default_config , success_mock : MockType
384399):
385400 message = "fix(scope): some commit message"
386- config .settings ["message_length_limit" ] = len (message ) - 1
401+ default_config .settings ["message_length_limit" ] = len (message ) - 1
387402 for message_length_limit in [len (message ) + 1 , 0 ]:
388403 success_mock .reset_mock ()
389404 commands .Check (
390- config = config ,
405+ config = default_config ,
391406 arguments = {
392407 "message" : message ,
393408 "message_length_limit" : message_length_limit ,
0 commit comments