66from commitizen import cli
77from 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 (
0 commit comments