Debian Codegraph @

tests/commands/test_common_command.py

raw
1 import pytest
2 from pytest_mock import MockFixture
3
4 from commitizen.commands import Example, Info, ListCz, Schema
5 from tests.utils import UtilFixture
6
7
8 @pytest.mark.parametrize(
9 "command",
10 [
11 "bump",
12 "changelog",
13 "check",
14 "commit",
15 "example",
16 "info",
17 "init",
18 "ls",
19 "schema",
20 "version",
21 ],
22 )
23 @pytest.mark.usefixtures("python_version", "consistent_terminal_output")
24 def test_command_shows_description_when_use_help_option(
25 capsys,
26 file_regression,
27 command: str,
28 util: UtilFixture,
29 ):
30 """Test that the command shows the description when the help option is used.
31
32 Note: If the command description changes, please run `poe test:regen` to regenerate the test files.
33 """
34
35 with pytest.raises(SystemExit):
36 util.run_cli(command, "--help")
37
38 out, _ = capsys.readouterr()
39 file_regression.check(out, extension=".txt")
40
41
42 @pytest.mark.parametrize(
43 "command",
44 [
45 Example,
46 Info,
47 ListCz,
48 Schema,
49 ],
50 )
51 def test_simple_command_call_once(config, mocker: MockFixture, command):
52 write_mock = mocker.patch("commitizen.out.write")
53 command(config)()
54 write_mock.assert_called_once()