77from 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 (
0 commit comments