44from unittest .mock import MagicMock
55
66import pytest
7+ from pytest_mock import MockFixture
78
89import commitizen .commands .bump as bump
910from commitizen import cli , cmd , git
3738 ),
3839)
3940@pytest .mark .usefixtures ("tmp_commitizen_project" )
40- def test_bump_patch_increment (commit_msg , mocker ):
41+ def test_bump_patch_increment (commit_msg , mocker : MockFixture ):
4142 create_file_and_commit (commit_msg )
4243 testargs = ["cz" , "bump" , "--yes" ]
4344 mocker .patch .object (sys , "argv" , testargs )
@@ -48,7 +49,7 @@ def test_bump_patch_increment(commit_msg, mocker):
4849
4950@pytest .mark .parametrize ("commit_msg" , ("feat: new file" , "feat(user): new file" ))
5051@pytest .mark .usefixtures ("tmp_commitizen_project" )
51- def test_bump_minor_increment (commit_msg , mocker ):
52+ def test_bump_minor_increment (commit_msg , mocker : MockFixture ):
5253 create_file_and_commit (commit_msg )
5354 testargs = ["cz" , "bump" , "--yes" ]
5455 mocker .patch .object (sys , "argv" , testargs )
@@ -60,7 +61,7 @@ def test_bump_minor_increment(commit_msg, mocker):
6061
6162@pytest .mark .parametrize ("commit_msg" , ("feat: new file" , "feat(user): new file" ))
6263@pytest .mark .usefixtures ("tmp_commitizen_project" )
63- def test_bump_minor_increment_annotated (commit_msg , mocker ):
64+ def test_bump_minor_increment_annotated (commit_msg , mocker : MockFixture ):
6465 create_file_and_commit (commit_msg )
6566 testargs = ["cz" , "bump" , "--yes" , "--annotated-tag" ]
6667 mocker .patch .object (sys , "argv" , testargs )
@@ -75,7 +76,7 @@ def test_bump_minor_increment_annotated(commit_msg, mocker):
7576
7677@pytest .mark .parametrize ("commit_msg" , ("feat: new file" , "feat(user): new file" ))
7778@pytest .mark .usefixtures ("tmp_commitizen_project_with_gpg" )
78- def test_bump_minor_increment_signed (commit_msg , mocker ):
79+ def test_bump_minor_increment_signed (commit_msg , mocker : MockFixture ):
7980 create_file_and_commit (commit_msg )
8081 testargs = ["cz" , "bump" , "--yes" , "--gpg-sign" ]
8182 mocker .patch .object (sys , "argv" , testargs )
@@ -90,7 +91,7 @@ def test_bump_minor_increment_signed(commit_msg, mocker):
9091
9192@pytest .mark .parametrize ("commit_msg" , ("feat: new file" , "feat(user): new file" ))
9293def test_bump_minor_increment_annotated_config_file (
93- commit_msg , mocker , tmp_commitizen_project
94+ commit_msg , mocker : MockFixture , tmp_commitizen_project
9495):
9596 tmp_commitizen_cfg_file = tmp_commitizen_project .join ("pyproject.toml" )
9697 tmp_commitizen_cfg_file .write (
@@ -110,7 +111,7 @@ def test_bump_minor_increment_annotated_config_file(
110111
111112@pytest .mark .parametrize ("commit_msg" , ("feat: new file" , "feat(user): new file" ))
112113def test_bump_minor_increment_signed_config_file (
113- commit_msg , mocker , tmp_commitizen_project_with_gpg
114+ commit_msg , mocker : MockFixture , tmp_commitizen_project_with_gpg
114115):
115116 tmp_commitizen_cfg_file = tmp_commitizen_project_with_gpg .join ("pyproject.toml" )
116117 tmp_commitizen_cfg_file .write (f"{ tmp_commitizen_cfg_file .read ()} \n " f"gpg_sign = 1" )
@@ -140,7 +141,7 @@ def test_bump_minor_increment_signed_config_file(
140141 "BREAKING-CHANGE: age is no longer supported" ,
141142 ),
142143)
143- def test_bump_major_increment (commit_msg , mocker ):
144+ def test_bump_major_increment (commit_msg , mocker : MockFixture ):
144145 create_file_and_commit (commit_msg )
145146
146147 testargs = ["cz" , "bump" , "--yes" ]
@@ -186,7 +187,9 @@ def test_bump_major_increment_major_version_zero(commit_msg, mocker):
186187 ("BREAKING CHANGE: age is no longer supported" , "minor" , "0.2.0" ),
187188 ],
188189)
189- def test_bump_command_increment_option (commit_msg , increment , expected_tag , mocker ):
190+ def test_bump_command_increment_option (
191+ commit_msg , increment , expected_tag , mocker : MockFixture
192+ ):
190193 create_file_and_commit (commit_msg )
191194
192195 testargs = ["cz" , "bump" , "--increment" , increment , "--yes" ]
@@ -198,7 +201,7 @@ def test_bump_command_increment_option(commit_msg, increment, expected_tag, mock
198201
199202
200203@pytest .mark .usefixtures ("tmp_commitizen_project" )
201- def test_bump_command_prelease (mocker ):
204+ def test_bump_command_prelease (mocker : MockFixture ):
202205 # PRERELEASE
203206 create_file_and_commit ("feat: location" )
204207
@@ -219,7 +222,7 @@ def test_bump_command_prelease(mocker):
219222
220223
221224@pytest .mark .usefixtures ("tmp_commitizen_project" )
222- def test_bump_on_git_with_hooks_no_verify_disabled (mocker ):
225+ def test_bump_on_git_with_hooks_no_verify_disabled (mocker : MockFixture ):
223226 """Bump commit without --no-verify"""
224227 cmd .run ("mkdir .git/hooks" )
225228 with open (".git/hooks/pre-commit" , "w" ) as f :
@@ -239,7 +242,7 @@ def test_bump_on_git_with_hooks_no_verify_disabled(mocker):
239242
240243
241244@pytest .mark .usefixtures ("tmp_commitizen_project" )
242- def test_bump_tag_exists_raises_exception (mocker ):
245+ def test_bump_tag_exists_raises_exception (mocker : MockFixture ):
243246 cmd .run ("mkdir .git/hooks" )
244247 with open (".git/hooks/post-commit" , "w" ) as f :
245248 f .write ("#!/usr/bin/env bash\n " "exit 9" )
@@ -258,7 +261,7 @@ def test_bump_tag_exists_raises_exception(mocker):
258261
259262
260263@pytest .mark .usefixtures ("tmp_commitizen_project" )
261- def test_bump_on_git_with_hooks_no_verify_enabled (mocker ):
264+ def test_bump_on_git_with_hooks_no_verify_enabled (mocker : MockFixture ):
262265 cmd .run ("mkdir .git/hooks" )
263266 with open (".git/hooks/pre-commit" , "w" ) as f :
264267 f .write ("#!/usr/bin/env bash\n " 'echo "0.1.0"' )
@@ -275,7 +278,7 @@ def test_bump_on_git_with_hooks_no_verify_enabled(mocker):
275278 assert tag_exists is True
276279
277280
278- def test_bump_when_bumpping_is_not_support (mocker , tmp_commitizen_project ):
281+ def test_bump_when_bumpping_is_not_support (mocker : MockFixture , tmp_commitizen_project ):
279282 create_file_and_commit (
280283 "feat: new user interface\n \n BREAKING CHANGE: age is no longer supported"
281284 )
@@ -290,7 +293,7 @@ def test_bump_when_bumpping_is_not_support(mocker, tmp_commitizen_project):
290293
291294
292295@pytest .mark .usefixtures ("tmp_git_project" )
293- def test_bump_when_version_is_not_specify (mocker ):
296+ def test_bump_when_version_is_not_specify (mocker : MockFixture ):
294297 mocker .patch .object (sys , "argv" , ["cz" , "bump" ])
295298
296299 with pytest .raises (NoVersionSpecifiedError ) as excinfo :
@@ -300,7 +303,7 @@ def test_bump_when_version_is_not_specify(mocker):
300303
301304
302305@pytest .mark .usefixtures ("tmp_commitizen_project" )
303- def test_bump_when_no_new_commit (mocker ):
306+ def test_bump_when_no_new_commit (mocker : MockFixture ):
304307 """bump without any commits since the last bump."""
305308 # We need this first commit otherwise the revision is invalid.
306309 create_file_and_commit ("feat: initial" )
@@ -322,7 +325,7 @@ def test_bump_when_no_new_commit(mocker):
322325
323326
324327def test_bump_when_version_inconsistent_in_version_files (
325- tmp_commitizen_project , mocker
328+ tmp_commitizen_project , mocker : MockFixture
326329):
327330 tmp_version_file = tmp_commitizen_project .join ("__version__.py" )
328331 tmp_version_file .write ("100.999.10000" )
@@ -374,7 +377,7 @@ def test_bump_major_version_zero_when_major_is_not_zero(mocker, tmp_commitizen_p
374377 assert expected_error_message in str (excinfo .value )
375378
376379
377- def test_bump_files_only (mocker , tmp_commitizen_project ):
380+ def test_bump_files_only (mocker : MockFixture , tmp_commitizen_project ):
378381 tmp_version_file = tmp_commitizen_project .join ("__version__.py" )
379382 tmp_version_file .write ("0.1.0" )
380383 tmp_commitizen_cfg_file = tmp_commitizen_project .join ("pyproject.toml" )
@@ -407,7 +410,7 @@ def test_bump_files_only(mocker, tmp_commitizen_project):
407410 assert "0.3.0" in f .read ()
408411
409412
410- def test_bump_local_version (mocker , tmp_commitizen_project ):
413+ def test_bump_local_version (mocker : MockFixture , tmp_commitizen_project ):
411414 tmp_version_file = tmp_commitizen_project .join ("__version__.py" )
412415 tmp_version_file .write ("4.5.1+0.1.0" )
413416 tmp_commitizen_cfg_file = tmp_commitizen_project .join ("pyproject.toml" )
@@ -429,7 +432,7 @@ def test_bump_local_version(mocker, tmp_commitizen_project):
429432 assert "4.5.1+0.2.0" in f .read ()
430433
431434
432- def test_bump_dry_run (mocker , capsys , tmp_commitizen_project ):
435+ def test_bump_dry_run (mocker : MockFixture , capsys , tmp_commitizen_project ):
433436 create_file_and_commit ("feat: new file" )
434437
435438 testargs = ["cz" , "bump" , "--yes" , "--dry-run" ]
@@ -444,7 +447,7 @@ def test_bump_dry_run(mocker, capsys, tmp_commitizen_project):
444447 assert tag_exists is False
445448
446449
447- def test_bump_in_non_git_project (tmpdir , config , mocker ):
450+ def test_bump_in_non_git_project (tmpdir , config , mocker : MockFixture ):
448451 testargs = ["cz" , "bump" , "--yes" ]
449452 mocker .patch .object (sys , "argv" , testargs )
450453
@@ -472,7 +475,7 @@ def test_none_increment_exit_is_exception():
472475
473476@pytest .mark .usefixtures ("tmp_commitizen_project" )
474477def test_none_increment_should_not_call_git_tag_and_error_code_is_not_zero (
475- mocker , tmp_commitizen_project
478+ mocker : MockFixture , tmp_commitizen_project
476479):
477480 create_file_and_commit ("test(test_get_all_droplets): fix bad comparison test" )
478481 testargs = ["cz" , "bump" , "--yes" ]
@@ -496,7 +499,7 @@ def test_none_increment_should_not_call_git_tag_and_error_code_is_not_zero(
496499
497500
498501@pytest .mark .usefixtures ("tmp_commitizen_project" )
499- def test_bump_with_changelog_arg (mocker , changelog_path ):
502+ def test_bump_with_changelog_arg (mocker : MockFixture , changelog_path ):
500503 create_file_and_commit ("feat(user): new file" )
501504 testargs = ["cz" , "bump" , "--yes" , "--changelog" ]
502505 mocker .patch .object (sys , "argv" , testargs )
@@ -511,7 +514,7 @@ def test_bump_with_changelog_arg(mocker, changelog_path):
511514
512515
513516@pytest .mark .usefixtures ("tmp_commitizen_project" )
514- def test_bump_with_changelog_config (mocker , changelog_path , config_path ):
517+ def test_bump_with_changelog_config (mocker : MockFixture , changelog_path , config_path ):
515518 create_file_and_commit ("feat(user): new file" )
516519 with open (config_path , "a" ) as fp :
517520 fp .write ("update_changelog_on_bump = true\n " )
@@ -529,7 +532,7 @@ def test_bump_with_changelog_config(mocker, changelog_path, config_path):
529532
530533
531534def test_prevent_prerelease_when_no_increment_detected (
532- mocker , capsys , tmp_commitizen_project
535+ mocker : MockFixture , capsys , tmp_commitizen_project
533536):
534537 create_file_and_commit ("feat: new file" )
535538
@@ -555,7 +558,7 @@ def test_prevent_prerelease_when_no_increment_detected(
555558
556559
557560@pytest .mark .usefixtures ("tmp_commitizen_project" )
558- def test_bump_with_changelog_to_stdout_arg (mocker , capsys , changelog_path ):
561+ def test_bump_with_changelog_to_stdout_arg (mocker : MockFixture , capsys , changelog_path ):
559562 create_file_and_commit ("feat(user): this should appear in stdout" )
560563 testargs = ["cz" , "bump" , "--yes" , "--changelog-to-stdout" ]
561564 mocker .patch .object (sys , "argv" , testargs )
@@ -573,7 +576,9 @@ def test_bump_with_changelog_to_stdout_arg(mocker, capsys, changelog_path):
573576
574577
575578@pytest .mark .usefixtures ("tmp_commitizen_project" )
576- def test_bump_with_changelog_to_stdout_dry_run_arg (mocker , capsys , changelog_path ):
579+ def test_bump_with_changelog_to_stdout_dry_run_arg (
580+ mocker : MockFixture , capsys , changelog_path
581+ ):
577582 create_file_and_commit (
578583 "feat(user): this should appear in stdout with dry-run enabled"
579584 )
0 commit comments