4
4
from unittest .mock import MagicMock
5
5
6
6
import pytest
7
+ from pytest_mock import MockFixture
7
8
8
9
import commitizen .commands .bump as bump
9
10
from commitizen import cli , cmd , git
37
38
),
38
39
)
39
40
@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 ):
41
42
create_file_and_commit (commit_msg )
42
43
testargs = ["cz" , "bump" , "--yes" ]
43
44
mocker .patch .object (sys , "argv" , testargs )
@@ -48,7 +49,7 @@ def test_bump_patch_increment(commit_msg, mocker):
48
49
49
50
@pytest .mark .parametrize ("commit_msg" , ("feat: new file" , "feat(user): new file" ))
50
51
@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 ):
52
53
create_file_and_commit (commit_msg )
53
54
testargs = ["cz" , "bump" , "--yes" ]
54
55
mocker .patch .object (sys , "argv" , testargs )
@@ -60,7 +61,7 @@ def test_bump_minor_increment(commit_msg, mocker):
60
61
61
62
@pytest .mark .parametrize ("commit_msg" , ("feat: new file" , "feat(user): new file" ))
62
63
@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 ):
64
65
create_file_and_commit (commit_msg )
65
66
testargs = ["cz" , "bump" , "--yes" , "--annotated-tag" ]
66
67
mocker .patch .object (sys , "argv" , testargs )
@@ -75,7 +76,7 @@ def test_bump_minor_increment_annotated(commit_msg, mocker):
75
76
76
77
@pytest .mark .parametrize ("commit_msg" , ("feat: new file" , "feat(user): new file" ))
77
78
@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 ):
79
80
create_file_and_commit (commit_msg )
80
81
testargs = ["cz" , "bump" , "--yes" , "--gpg-sign" ]
81
82
mocker .patch .object (sys , "argv" , testargs )
@@ -90,7 +91,7 @@ def test_bump_minor_increment_signed(commit_msg, mocker):
90
91
91
92
@pytest .mark .parametrize ("commit_msg" , ("feat: new file" , "feat(user): new file" ))
92
93
def test_bump_minor_increment_annotated_config_file (
93
- commit_msg , mocker , tmp_commitizen_project
94
+ commit_msg , mocker : MockFixture , tmp_commitizen_project
94
95
):
95
96
tmp_commitizen_cfg_file = tmp_commitizen_project .join ("pyproject.toml" )
96
97
tmp_commitizen_cfg_file .write (
@@ -110,7 +111,7 @@ def test_bump_minor_increment_annotated_config_file(
110
111
111
112
@pytest .mark .parametrize ("commit_msg" , ("feat: new file" , "feat(user): new file" ))
112
113
def 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
114
115
):
115
116
tmp_commitizen_cfg_file = tmp_commitizen_project_with_gpg .join ("pyproject.toml" )
116
117
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(
140
141
"BREAKING-CHANGE: age is no longer supported" ,
141
142
),
142
143
)
143
- def test_bump_major_increment (commit_msg , mocker ):
144
+ def test_bump_major_increment (commit_msg , mocker : MockFixture ):
144
145
create_file_and_commit (commit_msg )
145
146
146
147
testargs = ["cz" , "bump" , "--yes" ]
@@ -186,7 +187,9 @@ def test_bump_major_increment_major_version_zero(commit_msg, mocker):
186
187
("BREAKING CHANGE: age is no longer supported" , "minor" , "0.2.0" ),
187
188
],
188
189
)
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
+ ):
190
193
create_file_and_commit (commit_msg )
191
194
192
195
testargs = ["cz" , "bump" , "--increment" , increment , "--yes" ]
@@ -198,7 +201,7 @@ def test_bump_command_increment_option(commit_msg, increment, expected_tag, mock
198
201
199
202
200
203
@pytest .mark .usefixtures ("tmp_commitizen_project" )
201
- def test_bump_command_prelease (mocker ):
204
+ def test_bump_command_prelease (mocker : MockFixture ):
202
205
# PRERELEASE
203
206
create_file_and_commit ("feat: location" )
204
207
@@ -219,7 +222,7 @@ def test_bump_command_prelease(mocker):
219
222
220
223
221
224
@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 ):
223
226
"""Bump commit without --no-verify"""
224
227
cmd .run ("mkdir .git/hooks" )
225
228
with open (".git/hooks/pre-commit" , "w" ) as f :
@@ -239,7 +242,7 @@ def test_bump_on_git_with_hooks_no_verify_disabled(mocker):
239
242
240
243
241
244
@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 ):
243
246
cmd .run ("mkdir .git/hooks" )
244
247
with open (".git/hooks/post-commit" , "w" ) as f :
245
248
f .write ("#!/usr/bin/env bash\n " "exit 9" )
@@ -258,7 +261,7 @@ def test_bump_tag_exists_raises_exception(mocker):
258
261
259
262
260
263
@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 ):
262
265
cmd .run ("mkdir .git/hooks" )
263
266
with open (".git/hooks/pre-commit" , "w" ) as f :
264
267
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):
275
278
assert tag_exists is True
276
279
277
280
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 ):
279
282
create_file_and_commit (
280
283
"feat: new user interface\n \n BREAKING CHANGE: age is no longer supported"
281
284
)
@@ -290,7 +293,7 @@ def test_bump_when_bumpping_is_not_support(mocker, tmp_commitizen_project):
290
293
291
294
292
295
@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 ):
294
297
mocker .patch .object (sys , "argv" , ["cz" , "bump" ])
295
298
296
299
with pytest .raises (NoVersionSpecifiedError ) as excinfo :
@@ -300,7 +303,7 @@ def test_bump_when_version_is_not_specify(mocker):
300
303
301
304
302
305
@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 ):
304
307
"""bump without any commits since the last bump."""
305
308
# We need this first commit otherwise the revision is invalid.
306
309
create_file_and_commit ("feat: initial" )
@@ -322,7 +325,7 @@ def test_bump_when_no_new_commit(mocker):
322
325
323
326
324
327
def test_bump_when_version_inconsistent_in_version_files (
325
- tmp_commitizen_project , mocker
328
+ tmp_commitizen_project , mocker : MockFixture
326
329
):
327
330
tmp_version_file = tmp_commitizen_project .join ("__version__.py" )
328
331
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
374
377
assert expected_error_message in str (excinfo .value )
375
378
376
379
377
- def test_bump_files_only (mocker , tmp_commitizen_project ):
380
+ def test_bump_files_only (mocker : MockFixture , tmp_commitizen_project ):
378
381
tmp_version_file = tmp_commitizen_project .join ("__version__.py" )
379
382
tmp_version_file .write ("0.1.0" )
380
383
tmp_commitizen_cfg_file = tmp_commitizen_project .join ("pyproject.toml" )
@@ -407,7 +410,7 @@ def test_bump_files_only(mocker, tmp_commitizen_project):
407
410
assert "0.3.0" in f .read ()
408
411
409
412
410
- def test_bump_local_version (mocker , tmp_commitizen_project ):
413
+ def test_bump_local_version (mocker : MockFixture , tmp_commitizen_project ):
411
414
tmp_version_file = tmp_commitizen_project .join ("__version__.py" )
412
415
tmp_version_file .write ("4.5.1+0.1.0" )
413
416
tmp_commitizen_cfg_file = tmp_commitizen_project .join ("pyproject.toml" )
@@ -429,7 +432,7 @@ def test_bump_local_version(mocker, tmp_commitizen_project):
429
432
assert "4.5.1+0.2.0" in f .read ()
430
433
431
434
432
- def test_bump_dry_run (mocker , capsys , tmp_commitizen_project ):
435
+ def test_bump_dry_run (mocker : MockFixture , capsys , tmp_commitizen_project ):
433
436
create_file_and_commit ("feat: new file" )
434
437
435
438
testargs = ["cz" , "bump" , "--yes" , "--dry-run" ]
@@ -444,7 +447,7 @@ def test_bump_dry_run(mocker, capsys, tmp_commitizen_project):
444
447
assert tag_exists is False
445
448
446
449
447
- def test_bump_in_non_git_project (tmpdir , config , mocker ):
450
+ def test_bump_in_non_git_project (tmpdir , config , mocker : MockFixture ):
448
451
testargs = ["cz" , "bump" , "--yes" ]
449
452
mocker .patch .object (sys , "argv" , testargs )
450
453
@@ -472,7 +475,7 @@ def test_none_increment_exit_is_exception():
472
475
473
476
@pytest .mark .usefixtures ("tmp_commitizen_project" )
474
477
def 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
476
479
):
477
480
create_file_and_commit ("test(test_get_all_droplets): fix bad comparison test" )
478
481
testargs = ["cz" , "bump" , "--yes" ]
@@ -496,7 +499,7 @@ def test_none_increment_should_not_call_git_tag_and_error_code_is_not_zero(
496
499
497
500
498
501
@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 ):
500
503
create_file_and_commit ("feat(user): new file" )
501
504
testargs = ["cz" , "bump" , "--yes" , "--changelog" ]
502
505
mocker .patch .object (sys , "argv" , testargs )
@@ -511,7 +514,7 @@ def test_bump_with_changelog_arg(mocker, changelog_path):
511
514
512
515
513
516
@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 ):
515
518
create_file_and_commit ("feat(user): new file" )
516
519
with open (config_path , "a" ) as fp :
517
520
fp .write ("update_changelog_on_bump = true\n " )
@@ -529,7 +532,7 @@ def test_bump_with_changelog_config(mocker, changelog_path, config_path):
529
532
530
533
531
534
def test_prevent_prerelease_when_no_increment_detected (
532
- mocker , capsys , tmp_commitizen_project
535
+ mocker : MockFixture , capsys , tmp_commitizen_project
533
536
):
534
537
create_file_and_commit ("feat: new file" )
535
538
@@ -555,7 +558,7 @@ def test_prevent_prerelease_when_no_increment_detected(
555
558
556
559
557
560
@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 ):
559
562
create_file_and_commit ("feat(user): this should appear in stdout" )
560
563
testargs = ["cz" , "bump" , "--yes" , "--changelog-to-stdout" ]
561
564
mocker .patch .object (sys , "argv" , testargs )
@@ -573,7 +576,9 @@ def test_bump_with_changelog_to_stdout_arg(mocker, capsys, changelog_path):
573
576
574
577
575
578
@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
+ ):
577
582
create_file_and_commit (
578
583
"feat(user): this should appear in stdout with dry-run enabled"
579
584
)
0 commit comments