Skip to content

Commit f1f5841

Browse files
committed
refactor(example): command logic removed from commitizen base
1 parent 0f0813c commit f1f5841

File tree

4 files changed

+8
-16
lines changed

4 files changed

+8
-16
lines changed

commitizen/commands/example.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
from commitizen import factory
1+
from commitizen import factory, out
22

33

44
class Example:
@@ -9,4 +9,4 @@ def __init__(self, config: dict, *args):
99
self.cz = factory.commiter_factory(self.config)
1010

1111
def __call__(self):
12-
self.cz.show_example()
12+
out.write(self.cz.example())

commitizen/cz/base.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,6 @@ def info(self) -> str:
3232
"""Information about the standardized commit message."""
3333
raise NotImplementedError("Not Implemented yet")
3434

35-
def show_example(self, *args, **kwargs):
36-
out.write(self.example())
37-
3835
def show_schema(self, *args, **kwargs):
3936
out.write(self.schema())
4037

tests/test_commands.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,13 +24,14 @@ def test_commit(mocker):
2424

2525

2626
def test_example():
27-
with mock.patch("commitizen.factory.commiter_factory") as mocked_factory:
28-
mock_cz = mock.Mock()
29-
mocked_factory.return_value = mock_cz
27+
with mock.patch("commitizen.out.write") as write_mock:
28+
# mock_cz = mock.Mock()
29+
# mocked_factory.return_value = mock_cz
3030
commands.Example(config)()
31+
write_mock.assert_called_once()
3132

32-
mocked_factory.assert_called_once()
33-
mock_cz.show_example.assert_called_once()
33+
# mocked_factory.assert_called_once()
34+
# mock_cz.show_example.assert_called_once()
3435

3536

3637
def test_info():

tests/test_cz_base.py

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -46,12 +46,6 @@ def test_info():
4646
cz.info()
4747

4848

49-
def test_show_example():
50-
cz = DummyCz(config)
51-
with pytest.raises(NotImplementedError):
52-
cz.show_example()
53-
54-
5549
def test_show_schema():
5650
cz = DummyCz(config)
5751
with pytest.raises(NotImplementedError):

0 commit comments

Comments
 (0)