From f0dad854d64a4069029421e5fd08a9abff798638 Mon Sep 17 00:00:00 2001 From: Jakob Keller <57402305+jakob-keller@users.noreply.github.com> Date: Wed, 26 Jun 2024 21:52:35 +0200 Subject: [PATCH 1/4] ci(github-actions): add "3.13-dev" to Python tests (#1145) --- .github/workflows/pythonpackage.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/pythonpackage.yml b/.github/workflows/pythonpackage.yml index 3b5d5305a3..f0a517686f 100644 --- a/.github/workflows/pythonpackage.yml +++ b/.github/workflows/pythonpackage.yml @@ -6,7 +6,7 @@ jobs: python-check: strategy: matrix: - python-version: ["3.8", "3.9", "3.10", "3.11", "3.12"] + python-version: ["3.8", "3.9", "3.10", "3.11", "3.12", "3.13-dev"] platform: [ubuntu-20.04, macos-latest, windows-latest] runs-on: ${{ matrix.platform }} steps: From 604fe5fc30327ced8446fa5e17107140bf17c41e Mon Sep 17 00:00:00 2001 From: Jakob Keller <57402305+jakob-keller@users.noreply.github.com> Date: Thu, 8 Aug 2024 23:17:44 +0200 Subject: [PATCH 2/4] test: fix typo --- tests/utils.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/utils.py b/tests/utils.py index 971ff91820..efd3c38570 100644 --- a/tests/utils.py +++ b/tests/utils.py @@ -12,7 +12,7 @@ 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", + reason="The output message of argparse is different between Python 3.10 and lower than Python 3.10", ) From b0bee8e28948b8e3d3083a72d76561d3b9b437c1 Mon Sep 17 00:00:00 2001 From: Jakob Keller <57402305+jakob-keller@users.noreply.github.com> Date: Thu, 8 Aug 2024 23:26:01 +0200 Subject: [PATCH 3/4] test: update tests with less redundant output generated by argparse --help in Python 3.13 --- tests/commands/test_bump_command.py | 4 ++-- ...command_shows_description_when_use_help_option.txt | 11 +++++------ tests/commands/test_changelog_command.py | 4 ++-- ...command_shows_description_when_use_help_option.txt | 5 ++--- tests/commands/test_check_command.py | 4 ++-- ...command_shows_description_when_use_help_option.txt | 4 ++-- tests/commands/test_commit_command.py | 4 ++-- ...command_shows_description_when_use_help_option.txt | 2 +- tests/utils.py | 5 +++++ 9 files changed, 23 insertions(+), 20 deletions(-) diff --git a/tests/commands/test_bump_command.py b/tests/commands/test_bump_command.py index a0271c322e..7278de90de 100644 --- a/tests/commands/test_bump_command.py +++ b/tests/commands/test_bump_command.py @@ -29,7 +29,7 @@ NotAllowed, NoVersionSpecifiedError, ) -from tests.utils import create_file_and_commit, create_tag, skip_below_py_3_10 +from tests.utils import create_file_and_commit, create_tag, skip_below_py_3_13 @pytest.mark.parametrize( @@ -1451,7 +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 +@skip_below_py_3_13 def test_bump_command_shows_description_when_use_help_option( mocker: MockFixture, capsys, file_regression ): diff --git a/tests/commands/test_bump_command/test_bump_command_shows_description_when_use_help_option.txt b/tests/commands/test_bump_command/test_bump_command_shows_description_when_use_help_option.txt index de76f2efcf..c9b7bc0a06 100644 --- a/tests/commands/test_bump_command/test_bump_command_shows_description_when_use_help_option.txt +++ b/tests/commands/test_bump_command/test_bump_command_shows_description_when_use_help_option.txt @@ -33,9 +33,9 @@ options: --bump-message BUMP_MESSAGE template used to create the release commit, useful when working with CI - --prerelease {alpha,beta,rc}, -pr {alpha,beta,rc} + --prerelease, -pr {alpha,beta,rc} choose type of prerelease - --devrelease DEVRELEASE, -d DEVRELEASE + --devrelease, -d DEVRELEASE specify non-negative integer for dev. release --increment {MAJOR,MINOR,PATCH} manually specify the desired increment @@ -53,7 +53,7 @@ options: check consistency among versions defined in commitizen configuration and version_files --annotated-tag, -at create annotated tag instead of lightweight one - --annotated-tag-message ANNOTATED_TAG_MESSAGE, -atm ANNOTATED_TAG_MESSAGE + --annotated-tag-message, -atm ANNOTATED_TAG_MESSAGE create annotated tag message --gpg-sign, -s sign tag instead of lightweight one --changelog-to-stdout @@ -62,11 +62,10 @@ options: Redirect git output to stderr --retry retry commit if it fails the 1st time --major-version-zero keep major version at zero, even for breaking changes - --template TEMPLATE, -t TEMPLATE + --template, -t TEMPLATE changelog template file name (relative to the current working directory) - --extra EXTRA, -e EXTRA - a changelog extra variable (in the form 'key=value') + --extra, -e EXTRA a changelog extra variable (in the form 'key=value') --file-name FILE_NAME file name of changelog (default: 'CHANGELOG.md') --prerelease-offset PRERELEASE_OFFSET diff --git a/tests/commands/test_changelog_command.py b/tests/commands/test_changelog_command.py index 4694d33305..3d9a5c5c48 100644 --- a/tests/commands/test_changelog_command.py +++ b/tests/commands/test_changelog_command.py @@ -29,7 +29,7 @@ create_tag, get_current_branch, merge_branch, - skip_below_py_3_10, + skip_below_py_3_13, switch_branch, wait_for_tag, ) @@ -1640,7 +1640,7 @@ def test_export_changelog_template_from_plugin( assert target.read_text() == tpl -@skip_below_py_3_10 +@skip_below_py_3_13 def test_changelog_command_shows_description_when_use_help_option( mocker: MockFixture, capsys, file_regression ): diff --git a/tests/commands/test_changelog_command/test_changelog_command_shows_description_when_use_help_option.txt b/tests/commands/test_changelog_command/test_changelog_command_shows_description_when_use_help_option.txt index dae438ca24..461eb2edd6 100644 --- a/tests/commands/test_changelog_command/test_changelog_command_shows_description_when_use_help_option.txt +++ b/tests/commands/test_changelog_command/test_changelog_command_shows_description_when_use_help_option.txt @@ -33,8 +33,7 @@ options: --export-template EXPORT_TEMPLATE Export the changelog template into this file instead of rendering it - --template TEMPLATE, -t TEMPLATE + --template, -t TEMPLATE changelog template file name (relative to the current working directory) - --extra EXTRA, -e EXTRA - a changelog extra variable (in the form 'key=value') + --extra, -e EXTRA a changelog extra variable (in the form 'key=value') diff --git a/tests/commands/test_check_command.py b/tests/commands/test_check_command.py index 328ebd78a9..57bfe3f10a 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, skip_below_py_3_10 +from tests.utils import create_file_and_commit, skip_below_py_3_13 COMMIT_LOG = [ "refactor: A code change that neither fixes a bug nor adds a feature", @@ -416,7 +416,7 @@ def test_check_conventional_commit_succeed_with_git_diff(mocker, capsys): assert "Commit validation: successful!" in out -@skip_below_py_3_10 +@skip_below_py_3_13 def test_check_command_shows_description_when_use_help_option( mocker: MockFixture, capsys, file_regression ): diff --git a/tests/commands/test_check_command/test_check_command_shows_description_when_use_help_option.txt b/tests/commands/test_check_command/test_check_command_shows_description_when_use_help_option.txt index 74b9df7196..2ccf97270e 100644 --- a/tests/commands/test_check_command/test_check_command_shows_description_when_use_help_option.txt +++ b/tests/commands/test_check_command/test_check_command_shows_description_when_use_help_option.txt @@ -13,7 +13,7 @@ options: MSG_FILE=$1 --rev-range REV_RANGE a range of git rev to check. e.g, master..HEAD - -m MESSAGE, --message MESSAGE + -m, --message MESSAGE commit message that needs to be checked --allow-abort allow empty commit messages, which typically abort a commit @@ -21,5 +21,5 @@ options: allowed commit message prefixes. If the message starts by one of these prefixes, the message won't be checked against the regex - -l MESSAGE_LENGTH_LIMIT, --message-length-limit MESSAGE_LENGTH_LIMIT + -l, --message-length-limit MESSAGE_LENGTH_LIMIT length limit of the commit message; 0 for no limit diff --git a/tests/commands/test_commit_command.py b/tests/commands/test_commit_command.py index 8ae7568a9d..03ff51c42c 100644 --- a/tests/commands/test_commit_command.py +++ b/tests/commands/test_commit_command.py @@ -19,7 +19,7 @@ NotAllowed, NothingToCommitError, ) -from tests.utils import skip_below_py_3_10 +from tests.utils import skip_below_py_3_13 @pytest.fixture @@ -410,7 +410,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 +@skip_below_py_3_13 def test_commit_command_shows_description_when_use_help_option( mocker: MockFixture, capsys, file_regression ): diff --git a/tests/commands/test_commit_command/test_commit_command_shows_description_when_use_help_option.txt b/tests/commands/test_commit_command/test_commit_command_shows_description_when_use_help_option.txt index ebdb68446e..92f3cf5e87 100644 --- a/tests/commands/test_commit_command/test_commit_command_shows_description_when_use_help_option.txt +++ b/tests/commands/test_commit_command/test_commit_command_shows_description_when_use_help_option.txt @@ -16,5 +16,5 @@ options: -a, --all Tell the command to automatically stage files that have been modified and deleted, but new files you have not told Git about are not affected. - -l MESSAGE_LENGTH_LIMIT, --message-length-limit MESSAGE_LENGTH_LIMIT + -l, --message-length-limit MESSAGE_LENGTH_LIMIT length limit of the commit message; 0 for no limit diff --git a/tests/utils.py b/tests/utils.py index efd3c38570..5e26b2d70a 100644 --- a/tests/utils.py +++ b/tests/utils.py @@ -15,6 +15,11 @@ reason="The output message of argparse is different between Python 3.10 and lower than Python 3.10", ) +skip_below_py_3_13 = pytest.mark.skipif( + sys.version_info < (3, 13), + reason="The output message of argparse is different between Python 3.13 and lower than Python 3.13", +) + class FakeCommand: def __init__(self, out=None, err=None, return_code=0): From 82c04597c1220237a133503dc71ef28882558fa9 Mon Sep 17 00:00:00 2001 From: Jakob Keller <57402305+jakob-keller@users.noreply.github.com> Date: Fri, 9 Aug 2024 00:24:53 +0200 Subject: [PATCH 4/4] test: skip test on Python 3.13 due to incompatible pre-commit hook `mirrors-prettier` --- tests/test_bump_create_commit_message.py | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/tests/test_bump_create_commit_message.py b/tests/test_bump_create_commit_message.py index 517c7a0459..0002659396 100644 --- a/tests/test_bump_create_commit_message.py +++ b/tests/test_bump_create_commit_message.py @@ -24,7 +24,19 @@ def test_create_tag(test_input, expected): assert new_tag == expected -@pytest.mark.parametrize("retry", (True, False)) +@pytest.mark.parametrize( + "retry", + ( + pytest.param( + True, + marks=pytest.mark.skipif( + sys.version_info >= (3, 13), + reason="mirrors-prettier is not supported with Python 3.13 or higher", + ), + ), + False, + ), +) @pytest.mark.usefixtures("tmp_commitizen_project") def test_bump_pre_commit_changelog(mocker: MockFixture, freezer, retry): freezer.move_to("2022-04-01")