Skip to content

Commit fe8c373

Browse files
committed
test: file regression on every version of python
1 parent b5636b9 commit fe8c373

12 files changed

+25
-15
lines changed

tests/commands/test_common_command.py

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

99

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-
)
10+
def py_version_tag() -> str:
11+
"""Used in file regression tests to differentiate between Python versions."""
12+
return f"py{sys.version_info.major}_{sys.version_info.minor}"
13+
14+
1415
@pytest.mark.parametrize(
1516
"command",
1617
[
@@ -30,28 +31,26 @@ def test_command_shows_description_when_use_help_option(
3031
mocker: MockFixture,
3132
capsys,
3233
file_regression,
33-
monkeypatch: pytest.MonkeyPatch,
34+
stable_cli_env,
3435
command: str,
3536
):
3637
"""Test that the command shows the description when the help option is used.
3738
38-
Note: If the command description changes, please run `pytest tests/commands/test_common_command.py --regen-all` to regenerate the test files.
39+
Note: If the command description changes, please run `tox -- tests/commands/test_common_command.py --regen-all` to regenerate the test files.
3940
"""
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-
4841
testargs = ["cz", command, "--help"]
4942
mocker.patch.object(sys, "argv", testargs)
5043
with pytest.raises(SystemExit):
5144
cli.main()
5245

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

5655

5756
@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)