Skip to content

Commit 8f4dbe9

Browse files
committed
test(commands): add skip_if_below_py_3_10 as the message of argument changes in python 3.10
Optional arguments -> options
1 parent 4636e50 commit 8f4dbe9

11 files changed

+34
-2
lines changed

tests/commands/test_bump_command.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
NoVersionSpecifiedError,
3030
)
3131
from commitizen.changelog_formats import ChangelogFormat
32-
from tests.utils import create_file_and_commit, create_tag
32+
from tests.utils import create_file_and_commit, create_tag, skip_below_py_3_10
3333

3434

3535
@pytest.mark.parametrize(
@@ -1451,6 +1451,7 @@ def test_bump_changelog_contains_increment_only(mocker, tmp_commitizen_project,
14511451
assert "2.0.0" not in out
14521452

14531453

1454+
@skip_below_py_3_10
14541455
def test_bump_command_shows_description_when_use_help_option(
14551456
mocker: MockFixture, capsys, file_regression
14561457
):

tests/commands/test_changelog_command.py

+2
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
merge_branch,
3232
switch_branch,
3333
wait_for_tag,
34+
skip_below_py_3_10,
3435
)
3536

3637

@@ -1639,6 +1640,7 @@ def test_export_changelog_template_from_plugin(
16391640
assert target.read_text() == tpl
16401641

16411642

1643+
@skip_below_py_3_10
16421644
def test_changelog_command_shows_description_when_use_help_option(
16431645
mocker: MockFixture, capsys, file_regression
16441646
):

tests/commands/test_check_command.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
InvalidCommitMessageError,
1313
NoCommitsFoundError,
1414
)
15-
from tests.utils import create_file_and_commit
15+
from tests.utils import create_file_and_commit, skip_below_py_3_10
1616

1717
COMMIT_LOG = [
1818
"refactor: A code change that neither fixes a bug nor adds a feature",
@@ -416,6 +416,7 @@ def test_check_conventional_commit_succeed_with_git_diff(mocker, capsys):
416416
assert "Commit validation: successful!" in out
417417

418418

419+
@skip_below_py_3_10
419420
def test_check_command_shows_description_when_use_help_option(
420421
mocker: MockFixture, capsys, file_regression
421422
):

tests/commands/test_commit_command.py

+3
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@
2020
NothingToCommitError,
2121
)
2222

23+
from tests.utils import skip_below_py_3_10
24+
2325

2426
@pytest.fixture
2527
def staging_is_clean(mocker: MockFixture, tmp_git_project):
@@ -409,6 +411,7 @@ def test_commit_command_with_message_length_limit(config, mocker: MockFixture):
409411
commands.Commit(config, {"message_length_limit": message_length - 1})()
410412

411413

414+
@skip_below_py_3_10
412415
def test_commit_command_shows_description_when_use_help_option(
413416
mocker: MockFixture, capsys, file_regression
414417
):

tests/commands/test_example_command.py

+3
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,16 @@
44

55
from pytest_mock import MockerFixture
66

7+
from tests.utils import skip_below_py_3_10
8+
79

810
def test_example(config, mocker: MockerFixture):
911
write_mock = mocker.patch("commitizen.out.write")
1012
commands.Example(config)()
1113
write_mock.assert_called_once()
1214

1315

16+
@skip_below_py_3_10
1417
def test_example_command_shows_description_when_use_help_option(
1518
mocker: MockerFixture, capsys, file_regression
1619
):

tests/commands/test_info_command.py

+2
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
from commitizen import cli, commands
44

55
from pytest_mock import MockerFixture
6+
from tests.utils import skip_below_py_3_10
67

78

89
def test_info(config, mocker: MockerFixture):
@@ -11,6 +12,7 @@ def test_info(config, mocker: MockerFixture):
1112
write_mock.assert_called_once()
1213

1314

15+
@skip_below_py_3_10
1416
def test_info_command_shows_description_when_use_help_option(
1517
mocker: MockerFixture, capsys, file_regression
1618
):

tests/commands/test_init_command.py

+3
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@
1313
from commitizen.__version__ import __version__
1414
from commitizen.exceptions import InitFailedError, NoAnswersError
1515

16+
from tests.utils import skip_below_py_3_10
17+
1618

1719
class FakeQuestion:
1820
def __init__(self, expected_return):
@@ -254,6 +256,7 @@ def test_pre_commit_exec_failed(
254256
commands.Init(config)()
255257

256258

259+
@skip_below_py_3_10
257260
def test_init_command_shows_description_when_use_help_option(
258261
mocker: MockFixture, capsys, file_regression
259262
):

tests/commands/test_ls_command.py

+3
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,16 @@
44

55
from pytest_mock import MockerFixture
66

7+
from tests.utils import skip_below_py_3_10
8+
79

810
def test_list_cz(config, mocker: MockerFixture):
911
write_mock = mocker.patch("commitizen.out.write")
1012
commands.ListCz(config)()
1113
write_mock.assert_called_once()
1214

1315

16+
@skip_below_py_3_10
1417
def test_ls_command_shows_description_when_use_help_option(
1518
mocker: MockerFixture, capsys, file_regression
1619
):

tests/commands/test_schema_command.py

+3
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,16 @@
44

55
from pytest_mock import MockerFixture
66

7+
from tests.utils import skip_below_py_3_10
8+
79

810
def test_schema(config, mocker: MockerFixture):
911
write_mock = mocker.patch("commitizen.out.write")
1012
commands.Schema(config)()
1113
write_mock.assert_called_once()
1214

1315

16+
@skip_below_py_3_10
1417
def test_schema_command_shows_description_when_use_help_option(
1518
mocker: MockerFixture, capsys, file_regression
1619
):

tests/commands/test_version_command.py

+2
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
from commitizen import cli, commands
88
from commitizen.__version__ import __version__
99
from commitizen.config.base_config import BaseConfig
10+
from tests.utils import skip_below_py_3_10
1011

1112

1213
def test_version_for_showing_project_version(config, capsys):
@@ -108,6 +109,7 @@ def test_version_use_version_provider(
108109
mock.set_version.assert_not_called()
109110

110111

112+
@skip_below_py_3_10
111113
def test_version_command_shows_description_when_use_help_option(
112114
mocker: MockerFixture, capsys, file_regression
113115
):

tests/utils.py

+9
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,21 @@
22

33
import time
44
import uuid
5+
import sys
56
from pathlib import Path
7+
8+
import pytest
69
from deprecated import deprecated
710

811
from commitizen import cmd, exceptions, git
912

1013

14+
skip_below_py_3_10 = pytest.mark.skipif(
15+
sys.version_info < (3, 10),
16+
reason="The output meesage of argparse is different between Python 3.10 and lower than Python 3.10",
17+
)
18+
19+
1120
class FakeCommand:
1221
def __init__(self, out=None, err=None, return_code=0):
1322
self.out = out

0 commit comments

Comments
 (0)