Skip to content

Commit 9fa878c

Browse files
committed
test(init): correctly mock is_pre_commit_installed
1 parent a36b7ef commit 9fa878c

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

tests/commands/test_init_command.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
import os
55
import sys
66
from typing import Any
7+
from unittest import mock
78

89
import pytest
910
import yaml
@@ -125,6 +126,7 @@ def pre_commit_installed(mocker: MockFixture):
125126
# Assume the `pre-commit` is installed
126127
mocker.patch(
127128
"commitizen.commands.init.ProjectInfo.is_pre_commit_installed",
129+
new_callable=mock.PropertyMock,
128130
return_value=True,
129131
)
130132
# And installation success (i.e. no exception raised)
@@ -229,6 +231,7 @@ def test_pre_commit_not_installed(
229231
# Assume `pre-commit` is not installed
230232
mocker.patch(
231233
"commitizen.commands.init.ProjectInfo.is_pre_commit_installed",
234+
new_callable=mock.PropertyMock,
232235
return_value=False,
233236
)
234237
with tmpdir.as_cwd():
@@ -241,6 +244,7 @@ def test_pre_commit_exec_failed(
241244
# Assume `pre-commit` is installed
242245
mocker.patch(
243246
"commitizen.commands.init.ProjectInfo.is_pre_commit_installed",
247+
new_callable=mock.PropertyMock,
244248
return_value=True,
245249
)
246250
# But pre-commit installation will fail

0 commit comments

Comments
 (0)