Skip to content

Commit b06c8b6

Browse files
jakob-kellerLee-W
authored andcommitted
test: update tests with less redundant output generated by argparse --help in Python 3.13
1 parent 8335f6b commit b06c8b6

9 files changed

+23
-20
lines changed

tests/commands/test_bump_command.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
NotAllowed,
3131
NoVersionSpecifiedError,
3232
)
33-
from tests.utils import create_file_and_commit, create_tag, skip_below_py_3_10
33+
from tests.utils import create_file_and_commit, create_tag, skip_below_py_3_13
3434

3535

3636
@pytest.mark.parametrize(
@@ -1452,7 +1452,7 @@ def test_bump_changelog_contains_increment_only(mocker, tmp_commitizen_project,
14521452
assert "2.0.0" not in out
14531453

14541454

1455-
@skip_below_py_3_10
1455+
@skip_below_py_3_13
14561456
def test_bump_command_shows_description_when_use_help_option(
14571457
mocker: MockFixture, capsys, file_regression
14581458
):

tests/commands/test_bump_command/test_bump_command_shows_description_when_use_help_option.txt

+5-6
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,9 @@ options:
3333
--bump-message BUMP_MESSAGE
3434
template used to create the release commit, useful
3535
when working with CI
36-
--prerelease {alpha,beta,rc}, -pr {alpha,beta,rc}
36+
--prerelease, -pr {alpha,beta,rc}
3737
choose type of prerelease
38-
--devrelease DEVRELEASE, -d DEVRELEASE
38+
--devrelease, -d DEVRELEASE
3939
specify non-negative integer for dev. release
4040
--increment {MAJOR,MINOR,PATCH}
4141
manually specify the desired increment
@@ -53,7 +53,7 @@ options:
5353
check consistency among versions defined in commitizen
5454
configuration and version_files
5555
--annotated-tag, -at create annotated tag instead of lightweight one
56-
--annotated-tag-message ANNOTATED_TAG_MESSAGE, -atm ANNOTATED_TAG_MESSAGE
56+
--annotated-tag-message, -atm ANNOTATED_TAG_MESSAGE
5757
create annotated tag message
5858
--gpg-sign, -s sign tag instead of lightweight one
5959
--changelog-to-stdout
@@ -62,11 +62,10 @@ options:
6262
Redirect git output to stderr
6363
--retry retry commit if it fails the 1st time
6464
--major-version-zero keep major version at zero, even for breaking changes
65-
--template TEMPLATE, -t TEMPLATE
65+
--template, -t TEMPLATE
6666
changelog template file name (relative to the current
6767
working directory)
68-
--extra EXTRA, -e EXTRA
69-
a changelog extra variable (in the form 'key=value')
68+
--extra, -e EXTRA a changelog extra variable (in the form 'key=value')
7069
--file-name FILE_NAME
7170
file name of changelog (default: 'CHANGELOG.md')
7271
--prerelease-offset PRERELEASE_OFFSET

tests/commands/test_changelog_command.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
create_tag,
3030
get_current_branch,
3131
merge_branch,
32-
skip_below_py_3_10,
32+
skip_below_py_3_13,
3333
switch_branch,
3434
wait_for_tag,
3535
)
@@ -1640,7 +1640,7 @@ def test_export_changelog_template_from_plugin(
16401640
assert target.read_text() == tpl
16411641

16421642

1643-
@skip_below_py_3_10
1643+
@skip_below_py_3_13
16441644
def test_changelog_command_shows_description_when_use_help_option(
16451645
mocker: MockFixture, capsys, file_regression
16461646
):

tests/commands/test_changelog_command/test_changelog_command_shows_description_when_use_help_option.txt

+2-3
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,7 @@ options:
3333
--export-template EXPORT_TEMPLATE
3434
Export the changelog template into this file instead
3535
of rendering it
36-
--template TEMPLATE, -t TEMPLATE
36+
--template, -t TEMPLATE
3737
changelog template file name (relative to the current
3838
working directory)
39-
--extra EXTRA, -e EXTRA
40-
a changelog extra variable (in the form 'key=value')
39+
--extra, -e EXTRA a changelog extra variable (in the form 'key=value')

tests/commands/test_check_command.py

+2-2
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, skip_below_py_3_10
15+
from tests.utils import create_file_and_commit, skip_below_py_3_13
1616

1717
COMMIT_LOG = [
1818
"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):
416416
assert "Commit validation: successful!" in out
417417

418418

419-
@skip_below_py_3_10
419+
@skip_below_py_3_13
420420
def test_check_command_shows_description_when_use_help_option(
421421
mocker: MockFixture, capsys, file_regression
422422
):

tests/commands/test_check_command/test_check_command_shows_description_when_use_help_option.txt

+2-2
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,13 @@ options:
1313
MSG_FILE=$1
1414
--rev-range REV_RANGE
1515
a range of git rev to check. e.g, master..HEAD
16-
-m MESSAGE, --message MESSAGE
16+
-m, --message MESSAGE
1717
commit message that needs to be checked
1818
--allow-abort allow empty commit messages, which typically abort a
1919
commit
2020
--allowed-prefixes [ALLOWED_PREFIXES ...]
2121
allowed commit message prefixes. If the message starts
2222
by one of these prefixes, the message won't be checked
2323
against the regex
24-
-l MESSAGE_LENGTH_LIMIT, --message-length-limit MESSAGE_LENGTH_LIMIT
24+
-l, --message-length-limit MESSAGE_LENGTH_LIMIT
2525
length limit of the commit message; 0 for no limit

tests/commands/test_commit_command.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
NotAllowed,
2020
NothingToCommitError,
2121
)
22-
from tests.utils import skip_below_py_3_10
22+
from tests.utils import skip_below_py_3_13
2323

2424

2525
@pytest.fixture
@@ -410,7 +410,7 @@ def test_commit_command_with_message_length_limit(config, mocker: MockFixture):
410410
commands.Commit(config, {"message_length_limit": message_length - 1})()
411411

412412

413-
@skip_below_py_3_10
413+
@skip_below_py_3_13
414414
def test_commit_command_shows_description_when_use_help_option(
415415
mocker: MockFixture, capsys, file_regression
416416
):

tests/commands/test_commit_command/test_commit_command_shows_description_when_use_help_option.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,5 +16,5 @@ options:
1616
-a, --all Tell the command to automatically stage files that
1717
have been modified and deleted, but new files you have
1818
not told Git about are not affected.
19-
-l MESSAGE_LENGTH_LIMIT, --message-length-limit MESSAGE_LENGTH_LIMIT
19+
-l, --message-length-limit MESSAGE_LENGTH_LIMIT
2020
length limit of the commit message; 0 for no limit

tests/utils.py

+5
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,11 @@
1515
reason="The output message of argparse is different between Python 3.10 and lower than Python 3.10",
1616
)
1717

18+
skip_below_py_3_13 = pytest.mark.skipif(
19+
sys.version_info < (3, 13),
20+
reason="The output message of argparse is different between Python 3.13 and lower than Python 3.13",
21+
)
22+
1823

1924
class FakeCommand:
2025
def __init__(self, out=None, err=None, return_code=0):

0 commit comments

Comments
 (0)