Skip to content

Commit 60cc89e

Browse files
committed
test: file regression on every version of python
1 parent c7b8d97 commit 60cc89e

12 files changed

+20
-15
lines changed

tests/commands/test_common_command.py

Lines changed: 9 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,11 @@
66
from commitizen import cli
77
from commitizen.commands import Example, Info, ListCz, Schema
88

9+
def py_version_tag() -> str:
10+
"""Used in file regression tests to differentiate between Python versions."""
11+
return f"py{sys.version_info.major}_{sys.version_info.minor}"
12+
913

10-
@pytest.mark.skipif(
11-
sys.version_info < (3, 13),
12-
reason="The output message of argparse is different between Python 3.13 and lower than Python 3.13",
13-
)
1414
@pytest.mark.parametrize(
1515
"command",
1616
[
@@ -30,28 +30,22 @@ def test_command_shows_description_when_use_help_option(
3030
mocker: MockFixture,
3131
capsys,
3232
file_regression,
33-
monkeypatch: pytest.MonkeyPatch,
33+
stable_cli_env,
3434
command: str,
3535
):
3636
"""Test that the command shows the description when the help option is used.
3737
38-
Note: If the command description changes, please run `pytest tests/commands/test_common_command.py --regen-all` to regenerate the test files.
38+
Note: If the command description changes, please run `tox -- tests/commands/test_common_command.py --regen-all` to regenerate the test files.
3939
"""
40-
# Force consistent terminal output
41-
monkeypatch.setenv("COLUMNS", "80")
42-
monkeypatch.setenv("TERM", "dumb")
43-
monkeypatch.setenv("LC_ALL", "C")
44-
monkeypatch.setenv("LANG", "C")
45-
monkeypatch.setenv("NO_COLOR", "1")
46-
monkeypatch.setenv("PAGER", "cat")
47-
4840
testargs = ["cz", command, "--help"]
4941
mocker.patch.object(sys, "argv", testargs)
5042
with pytest.raises(SystemExit):
5143
cli.main()
5244

5345
out, _ = capsys.readouterr()
54-
file_regression.check(out, extension=".txt")
46+
47+
# The output message of argparse is different between Python versions, especially below 3.13 and above 3.13.
48+
file_regression.check(out, extension=".txt", basename=f"test_command_shows_description_when_use_help_option_{command}_{py_version_tag()}")
5549

5650

5751
@pytest.mark.parametrize(

tests/commands/test_common_command/test_command_shows_description_when_use_help_option_bump_.txt renamed to tests/commands/test_common_command/test_command_shows_description_when_use_help_option_bump_py3_13.txt

File renamed without changes.

tests/commands/test_common_command/test_command_shows_description_when_use_help_option_changelog_.txt renamed to tests/commands/test_common_command/test_command_shows_description_when_use_help_option_changelog_py3_13.txt

File renamed without changes.

tests/commands/test_common_command/test_command_shows_description_when_use_help_option_check_.txt renamed to tests/commands/test_common_command/test_command_shows_description_when_use_help_option_check_py3_13.txt

File renamed without changes.

tests/commands/test_common_command/test_command_shows_description_when_use_help_option_commit_.txt renamed to tests/commands/test_common_command/test_command_shows_description_when_use_help_option_commit_py3_13.txt

File renamed without changes.

tests/commands/test_common_command/test_command_shows_description_when_use_help_option_example_.txt renamed to tests/commands/test_common_command/test_command_shows_description_when_use_help_option_example_py3_13.txt

File renamed without changes.

tests/commands/test_common_command/test_command_shows_description_when_use_help_option_info_.txt renamed to tests/commands/test_common_command/test_command_shows_description_when_use_help_option_info_py3_13.txt

File renamed without changes.

tests/commands/test_common_command/test_command_shows_description_when_use_help_option_init_.txt renamed to tests/commands/test_common_command/test_command_shows_description_when_use_help_option_init_py3_13.txt

File renamed without changes.

tests/commands/test_common_command/test_command_shows_description_when_use_help_option_ls_.txt renamed to tests/commands/test_common_command/test_command_shows_description_when_use_help_option_ls_py3_13.txt

File renamed without changes.

tests/commands/test_common_command/test_command_shows_description_when_use_help_option_schema_.txt renamed to tests/commands/test_common_command/test_command_shows_description_when_use_help_option_schema_py3_13.txt

File renamed without changes.

0 commit comments

Comments
 (0)