diff --git a/tests/commands/test_bump_command.py b/tests/commands/test_bump_command.py index ad7f4db64..b20f75169 100644 --- a/tests/commands/test_bump_command.py +++ b/tests/commands/test_bump_command.py @@ -29,7 +29,7 @@ NoVersionSpecifiedError, ) from commitizen.changelog_formats import ChangelogFormat -from tests.utils import create_file_and_commit, create_tag +from tests.utils import create_file_and_commit, create_tag, skip_below_py_3_10 @pytest.mark.parametrize( @@ -1451,6 +1451,7 @@ def test_bump_changelog_contains_increment_only(mocker, tmp_commitizen_project, assert "2.0.0" not in out +@skip_below_py_3_10 def test_bump_command_shows_description_when_use_help_option( mocker: MockFixture, capsys, file_regression ): diff --git a/tests/commands/test_changelog_command.py b/tests/commands/test_changelog_command.py index 6f8919d71..67f10a8ac 100644 --- a/tests/commands/test_changelog_command.py +++ b/tests/commands/test_changelog_command.py @@ -31,6 +31,7 @@ merge_branch, switch_branch, wait_for_tag, + skip_below_py_3_10, ) @@ -1639,6 +1640,7 @@ def test_export_changelog_template_from_plugin( assert target.read_text() == tpl +@skip_below_py_3_10 def test_changelog_command_shows_description_when_use_help_option( mocker: MockFixture, capsys, file_regression ): diff --git a/tests/commands/test_check_command.py b/tests/commands/test_check_command.py index bd65e75b7..47bdafd65 100644 --- a/tests/commands/test_check_command.py +++ b/tests/commands/test_check_command.py @@ -12,7 +12,7 @@ InvalidCommitMessageError, NoCommitsFoundError, ) -from tests.utils import create_file_and_commit +from tests.utils import create_file_and_commit, skip_below_py_3_10 COMMIT_LOG = [ "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): assert "Commit validation: successful!" in out +@skip_below_py_3_10 def test_check_command_shows_description_when_use_help_option( mocker: MockFixture, capsys, file_regression ): diff --git a/tests/commands/test_commit_command.py b/tests/commands/test_commit_command.py index da54e7b6e..208527875 100644 --- a/tests/commands/test_commit_command.py +++ b/tests/commands/test_commit_command.py @@ -20,6 +20,8 @@ NothingToCommitError, ) +from tests.utils import skip_below_py_3_10 + @pytest.fixture def staging_is_clean(mocker: MockFixture, tmp_git_project): @@ -409,6 +411,7 @@ def test_commit_command_with_message_length_limit(config, mocker: MockFixture): commands.Commit(config, {"message_length_limit": message_length - 1})() +@skip_below_py_3_10 def test_commit_command_shows_description_when_use_help_option( mocker: MockFixture, capsys, file_regression ): diff --git a/tests/commands/test_example_command.py b/tests/commands/test_example_command.py index 93d9368f5..e0c214145 100644 --- a/tests/commands/test_example_command.py +++ b/tests/commands/test_example_command.py @@ -4,6 +4,8 @@ from pytest_mock import MockerFixture +from tests.utils import skip_below_py_3_10 + def test_example(config, mocker: MockerFixture): write_mock = mocker.patch("commitizen.out.write") @@ -11,6 +13,7 @@ def test_example(config, mocker: MockerFixture): write_mock.assert_called_once() +@skip_below_py_3_10 def test_example_command_shows_description_when_use_help_option( mocker: MockerFixture, capsys, file_regression ): diff --git a/tests/commands/test_info_command.py b/tests/commands/test_info_command.py index b9c8e10d3..6221630ac 100644 --- a/tests/commands/test_info_command.py +++ b/tests/commands/test_info_command.py @@ -3,6 +3,7 @@ from commitizen import cli, commands from pytest_mock import MockerFixture +from tests.utils import skip_below_py_3_10 def test_info(config, mocker: MockerFixture): @@ -11,6 +12,7 @@ def test_info(config, mocker: MockerFixture): write_mock.assert_called_once() +@skip_below_py_3_10 def test_info_command_shows_description_when_use_help_option( mocker: MockerFixture, capsys, file_regression ): diff --git a/tests/commands/test_init_command.py b/tests/commands/test_init_command.py index a3f8a8d73..a263e73a8 100644 --- a/tests/commands/test_init_command.py +++ b/tests/commands/test_init_command.py @@ -13,6 +13,8 @@ from commitizen.__version__ import __version__ from commitizen.exceptions import InitFailedError, NoAnswersError +from tests.utils import skip_below_py_3_10 + class FakeQuestion: def __init__(self, expected_return): @@ -254,6 +256,7 @@ def test_pre_commit_exec_failed( commands.Init(config)() +@skip_below_py_3_10 def test_init_command_shows_description_when_use_help_option( mocker: MockFixture, capsys, file_regression ): diff --git a/tests/commands/test_ls_command.py b/tests/commands/test_ls_command.py index e2a311fc7..d783305fc 100644 --- a/tests/commands/test_ls_command.py +++ b/tests/commands/test_ls_command.py @@ -4,6 +4,8 @@ from pytest_mock import MockerFixture +from tests.utils import skip_below_py_3_10 + def test_list_cz(config, mocker: MockerFixture): write_mock = mocker.patch("commitizen.out.write") @@ -11,6 +13,7 @@ def test_list_cz(config, mocker: MockerFixture): write_mock.assert_called_once() +@skip_below_py_3_10 def test_ls_command_shows_description_when_use_help_option( mocker: MockerFixture, capsys, file_regression ): diff --git a/tests/commands/test_schema_command.py b/tests/commands/test_schema_command.py index fd0693dcf..f69638dba 100644 --- a/tests/commands/test_schema_command.py +++ b/tests/commands/test_schema_command.py @@ -4,6 +4,8 @@ from pytest_mock import MockerFixture +from tests.utils import skip_below_py_3_10 + def test_schema(config, mocker: MockerFixture): write_mock = mocker.patch("commitizen.out.write") @@ -11,6 +13,7 @@ def test_schema(config, mocker: MockerFixture): write_mock.assert_called_once() +@skip_below_py_3_10 def test_schema_command_shows_description_when_use_help_option( mocker: MockerFixture, capsys, file_regression ): diff --git a/tests/commands/test_version_command.py b/tests/commands/test_version_command.py index 0a6109311..f7d38c202 100644 --- a/tests/commands/test_version_command.py +++ b/tests/commands/test_version_command.py @@ -7,6 +7,7 @@ from commitizen import cli, commands from commitizen.__version__ import __version__ from commitizen.config.base_config import BaseConfig +from tests.utils import skip_below_py_3_10 def test_version_for_showing_project_version(config, capsys): @@ -108,6 +109,7 @@ def test_version_use_version_provider( mock.set_version.assert_not_called() +@skip_below_py_3_10 def test_version_command_shows_description_when_use_help_option( mocker: MockerFixture, capsys, file_regression ): diff --git a/tests/utils.py b/tests/utils.py index 08d4414ba..39fb0a17f 100644 --- a/tests/utils.py +++ b/tests/utils.py @@ -2,12 +2,21 @@ import time import uuid +import sys from pathlib import Path + +import pytest from deprecated import deprecated from commitizen import cmd, exceptions, git +skip_below_py_3_10 = pytest.mark.skipif( + sys.version_info < (3, 10), + reason="The output meesage of argparse is different between Python 3.10 and lower than Python 3.10", +) + + class FakeCommand: def __init__(self, out=None, err=None, return_code=0): self.out = out