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