@@ -141,15 +141,17 @@ def test_check_conventional_commit_succeeds(mocker: MockFixture, capsys):
141141 ),
142142 ),
143143)
144- def test_check_no_conventional_commit (commit_msg , config , mocker : MockFixture , tmpdir ):
144+ def test_check_no_conventional_commit (
145+ commit_msg , mock_config , mocker : MockFixture , tmpdir
146+ ):
145147 with pytest .raises (InvalidCommitMessageError ):
146148 error_mock = mocker .patch ("commitizen.out.error" )
147149
148150 tempfile = tmpdir .join ("temp_commit_file" )
149151 tempfile .write (commit_msg )
150152
151153 check_cmd = commands .Check (
152- config = config , arguments = {"commit_msg_file" : tempfile }
154+ config = mock_config , arguments = {"commit_msg_file" : tempfile }
153155 )
154156 check_cmd ()
155157 error_mock .assert_called_once ()
@@ -164,56 +166,62 @@ def test_check_no_conventional_commit(commit_msg, config, mocker: MockFixture, t
164166 "bump: 0.0.1 -> 1.0.0" ,
165167 ),
166168)
167- def test_check_conventional_commit (commit_msg , config , mocker : MockFixture , tmpdir ):
169+ def test_check_conventional_commit (
170+ commit_msg , mock_config , mocker : MockFixture , tmpdir
171+ ):
168172 success_mock = mocker .patch ("commitizen.out.success" )
169173
170174 tempfile = tmpdir .join ("temp_commit_file" )
171175 tempfile .write (commit_msg )
172176
173- check_cmd = commands .Check (config = config , arguments = {"commit_msg_file" : tempfile })
177+ check_cmd = commands .Check (
178+ config = mock_config , arguments = {"commit_msg_file" : tempfile }
179+ )
174180
175181 check_cmd ()
176182 success_mock .assert_called_once ()
177183
178184
179- def test_check_command_when_commit_file_not_found (config ):
185+ def test_check_command_when_commit_file_not_found (mock_config ):
180186 with pytest .raises (FileNotFoundError ):
181- commands .Check (config = config , arguments = {"commit_msg_file" : "no_such_file" })()
187+ commands .Check (
188+ config = mock_config , arguments = {"commit_msg_file" : "no_such_file" }
189+ )()
182190
183191
184- def test_check_a_range_of_git_commits (config , mocker : MockFixture ):
192+ def test_check_a_range_of_git_commits (mock_config , mocker : MockFixture ):
185193 success_mock = mocker .patch ("commitizen.out.success" )
186194 mocker .patch (
187195 "commitizen.git.get_commits" , return_value = _build_fake_git_commits (COMMIT_LOG )
188196 )
189197
190198 check_cmd = commands .Check (
191- config = config , arguments = {"rev_range" : "HEAD~10..master" }
199+ config = mock_config , arguments = {"rev_range" : "HEAD~10..master" }
192200 )
193201
194202 check_cmd ()
195203 success_mock .assert_called_once ()
196204
197205
198- def test_check_a_range_of_git_commits_and_failed (config , mocker : MockFixture ):
206+ def test_check_a_range_of_git_commits_and_failed (mock_config , mocker : MockFixture ):
199207 error_mock = mocker .patch ("commitizen.out.error" )
200208 mocker .patch (
201209 "commitizen.git.get_commits" ,
202210 return_value = _build_fake_git_commits (["This commit does not follow rule" ]),
203211 )
204212 check_cmd = commands .Check (
205- config = config , arguments = {"rev_range" : "HEAD~10..master" }
213+ config = mock_config , arguments = {"rev_range" : "HEAD~10..master" }
206214 )
207215
208216 with pytest .raises (InvalidCommitMessageError ):
209217 check_cmd ()
210218 error_mock .assert_called_once ()
211219
212220
213- def test_check_command_with_invalid_argument (config ):
221+ def test_check_command_with_invalid_argument (mock_config ):
214222 with pytest .raises (InvalidCommandArgumentError ) as excinfo :
215223 commands .Check (
216- config = config ,
224+ config = mock_config ,
217225 arguments = {"commit_msg_file" : "some_file" , "rev_range" : "HEAD~10..master" },
218226 )
219227 assert (
@@ -223,18 +231,20 @@ def test_check_command_with_invalid_argument(config):
223231
224232
225233@pytest .mark .usefixtures ("tmp_commitizen_project" )
226- def test_check_command_with_empty_range (config , mocker : MockFixture ):
234+ def test_check_command_with_empty_range (mock_config , mocker : MockFixture ):
227235 # must initialize git with a commit
228236 create_file_and_commit ("feat: initial" )
229237
230- check_cmd = commands .Check (config = config , arguments = {"rev_range" : "master..master" })
238+ check_cmd = commands .Check (
239+ config = mock_config , arguments = {"rev_range" : "master..master" }
240+ )
231241 with pytest .raises (NoCommitsFoundError ) as excinfo :
232242 check_cmd ()
233243
234244 assert "No commit found with range: 'master..master'" in str (excinfo )
235245
236246
237- def test_check_a_range_of_failed_git_commits (config , mocker : MockFixture ):
247+ def test_check_a_range_of_failed_git_commits (mock_config , mocker : MockFixture ):
238248 ill_formated_commits_msgs = [
239249 "First commit does not follow rule" ,
240250 "Second commit does not follow rule" ,
@@ -245,98 +255,102 @@ def test_check_a_range_of_failed_git_commits(config, mocker: MockFixture):
245255 return_value = _build_fake_git_commits (ill_formated_commits_msgs ),
246256 )
247257 check_cmd = commands .Check (
248- config = config , arguments = {"rev_range" : "HEAD~10..master" }
258+ config = mock_config , arguments = {"rev_range" : "HEAD~10..master" }
249259 )
250260
251261 with pytest .raises (InvalidCommitMessageError ) as excinfo :
252262 check_cmd ()
253263 assert all ([msg in str (excinfo .value ) for msg in ill_formated_commits_msgs ])
254264
255265
256- def test_check_command_with_valid_message (config , mocker : MockFixture ):
266+ def test_check_command_with_valid_message (mock_config , mocker : MockFixture ):
257267 success_mock = mocker .patch ("commitizen.out.success" )
258268 check_cmd = commands .Check (
259- config = config , arguments = {"message" : "fix(scope): some commit message" }
269+ config = mock_config , arguments = {"message" : "fix(scope): some commit message" }
260270 )
261271
262272 check_cmd ()
263273 success_mock .assert_called_once ()
264274
265275
266- def test_check_command_with_invalid_message (config , mocker : MockFixture ):
276+ def test_check_command_with_invalid_message (mock_config , mocker : MockFixture ):
267277 error_mock = mocker .patch ("commitizen.out.error" )
268- check_cmd = commands .Check (config = config , arguments = {"message" : "bad commit" })
278+ check_cmd = commands .Check (config = mock_config , arguments = {"message" : "bad commit" })
269279
270280 with pytest .raises (InvalidCommitMessageError ):
271281 check_cmd ()
272282 error_mock .assert_called_once ()
273283
274284
275- def test_check_command_with_empty_message (config , mocker : MockFixture ):
285+ def test_check_command_with_empty_message (mock_config , mocker : MockFixture ):
276286 error_mock = mocker .patch ("commitizen.out.error" )
277- check_cmd = commands .Check (config = config , arguments = {"message" : "" })
287+ check_cmd = commands .Check (config = mock_config , arguments = {"message" : "" })
278288
279289 with pytest .raises (InvalidCommitMessageError ):
280290 check_cmd ()
281291 error_mock .assert_called_once ()
282292
283293
284- def test_check_command_with_allow_abort_arg (config , mocker : MockFixture ):
294+ def test_check_command_with_allow_abort_arg (mock_config , mocker : MockFixture ):
285295 success_mock = mocker .patch ("commitizen.out.success" )
286296 check_cmd = commands .Check (
287- config = config , arguments = {"message" : "" , "allow_abort" : True }
297+ config = mock_config , arguments = {"message" : "" , "allow_abort" : True }
288298 )
289299
290300 check_cmd ()
291301 success_mock .assert_called_once ()
292302
293303
294- def test_check_command_with_allow_abort_config (config , mocker : MockFixture ):
304+ def test_check_command_with_allow_abort_config (mock_config , mocker : MockFixture ):
295305 success_mock = mocker .patch ("commitizen.out.success" )
296- config .settings ["allow_abort" ] = True
297- check_cmd = commands .Check (config = config , arguments = {"message" : "" })
306+ mock_config .settings ["allow_abort" ] = True
307+ check_cmd = commands .Check (config = mock_config , arguments = {"message" : "" })
298308
299309 check_cmd ()
300310 success_mock .assert_called_once ()
301311
302312
303- def test_check_command_override_allow_abort_config (config , mocker : MockFixture ):
313+ def test_check_command_override_allow_abort_config (mock_config , mocker : MockFixture ):
304314 error_mock = mocker .patch ("commitizen.out.error" )
305- config .settings ["allow_abort" ] = True
315+ mock_config .settings ["allow_abort" ] = True
306316 check_cmd = commands .Check (
307- config = config , arguments = {"message" : "" , "allow_abort" : False }
317+ config = mock_config , arguments = {"message" : "" , "allow_abort" : False }
308318 )
309319
310320 with pytest .raises (InvalidCommitMessageError ):
311321 check_cmd ()
312322 error_mock .assert_called_once ()
313323
314324
315- def test_check_command_with_allowed_prefixes_arg (config , mocker : MockFixture ):
325+ def test_check_command_with_allowed_prefixes_arg (mock_config , mocker : MockFixture ):
316326 success_mock = mocker .patch ("commitizen.out.success" )
317327 check_cmd = commands .Check (
318- config = config ,
328+ config = mock_config ,
319329 arguments = {"message" : "custom! test" , "allowed_prefixes" : ["custom!" ]},
320330 )
321331
322332 check_cmd ()
323333 success_mock .assert_called_once ()
324334
325335
326- def test_check_command_with_allowed_prefixes_config (config , mocker : MockFixture ):
336+ def test_check_command_with_allowed_prefixes_config (mock_config , mocker : MockFixture ):
327337 success_mock = mocker .patch ("commitizen.out.success" )
328- config .settings ["allowed_prefixes" ] = ["custom!" ]
329- check_cmd = commands .Check (config = config , arguments = {"message" : "custom! test" })
338+ mock_config .settings ["allowed_prefixes" ] = ["custom!" ]
339+ check_cmd = commands .Check (
340+ config = mock_config , arguments = {"message" : "custom! test" }
341+ )
330342
331343 check_cmd ()
332344 success_mock .assert_called_once ()
333345
334346
335- def test_check_command_override_allowed_prefixes_config (config , mocker : MockFixture ):
347+ def test_check_command_override_allowed_prefixes_config (
348+ mock_config , mocker : MockFixture
349+ ):
336350 error_mock = mocker .patch ("commitizen.out.error" )
337- config .settings ["allow_abort" ] = ["fixup!" ]
351+ mock_config .settings ["allow_abort" ] = ["fixup!" ]
338352 check_cmd = commands .Check (
339- config = config ,
353+ config = mock_config ,
340354 arguments = {"message" : "fixup! test" , "allowed_prefixes" : ["custom!" ]},
341355 )
342356
@@ -429,23 +443,25 @@ def test_check_command_shows_description_when_use_help_option(
429443 file_regression .check (out , extension = ".txt" )
430444
431445
432- def test_check_command_with_message_length_limit (config , mocker : MockFixture ):
446+ def test_check_command_with_message_length_limit (mock_config , mocker : MockFixture ):
433447 success_mock = mocker .patch ("commitizen.out.success" )
434448 message = "fix(scope): some commit message"
435449 check_cmd = commands .Check (
436- config = config ,
450+ config = mock_config ,
437451 arguments = {"message" : message , "message_length_limit" : len (message ) + 1 },
438452 )
439453
440454 check_cmd ()
441455 success_mock .assert_called_once ()
442456
443457
444- def test_check_command_with_message_length_limit_exceeded (config , mocker : MockFixture ):
458+ def test_check_command_with_message_length_limit_exceeded (
459+ mock_config , mocker : MockFixture
460+ ):
445461 error_mock = mocker .patch ("commitizen.out.error" )
446462 message = "fix(scope): some commit message"
447463 check_cmd = commands .Check (
448- config = config ,
464+ config = mock_config ,
449465 arguments = {"message" : message , "message_length_limit" : len (message ) - 1 },
450466 )
451467
@@ -454,9 +470,9 @@ def test_check_command_with_message_length_limit_exceeded(config, mocker: MockFi
454470 error_mock .assert_called_once ()
455471
456472
457- def test_check_command_with_amend_prefix_default (config , mocker : MockFixture ):
473+ def test_check_command_with_amend_prefix_default (mock_config , mocker : MockFixture ):
458474 success_mock = mocker .patch ("commitizen.out.success" )
459- check_cmd = commands .Check (config = config , arguments = {"message" : "amend! test" })
475+ check_cmd = commands .Check (config = mock_config , arguments = {"message" : "amend! test" })
460476
461477 check_cmd ()
462478 success_mock .assert_called_once ()
0 commit comments