Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 3eb31ac

Browse files
test(init): correctly mock is_pre_commit_installed
1 parent ca7d7c4 commit 3eb31ac

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)

AltStyle によって変換されたページ (->オリジナル) /