|
1 | | -import __builtin__ |
2 | 1 | import mock |
3 | 2 | import os |
4 | 3 | import pytest |
5 | 4 |
|
6 | 5 | import pre_commit.constants as C |
7 | 6 | from pre_commit import git |
| 7 | +from pre_commit import repository |
8 | 8 | from pre_commit.clientlib.validate_config import CONFIG_JSON_SCHEMA |
9 | 9 | from pre_commit.clientlib.validate_config import validate_config_extra |
10 | 10 | from pre_commit.jsonschema_extensions import apply_defaults |
@@ -135,23 +135,25 @@ def test_languages(config_for_python_hooks_repo): |
135 | 135 |
|
136 | 136 |
|
137 | 137 | @pytest.yield_fixture |
138 | | -def print_mock(): |
139 | | - with mock.patch.object(__builtin__, 'print', autospec=True) as print_mock: |
140 | | - yield print_mock |
| 138 | +def logger_mock(): |
| 139 | + with mock.patch.object( |
| 140 | + repository.logger, 'info', autospec=True, |
| 141 | + ) as info_mock: |
| 142 | + yield info_mock |
141 | 143 |
|
142 | 144 |
|
143 | | -def test_prints_while_creating(config_for_python_hooks_repo, print_mock): |
| 145 | +def test_prints_while_creating(config_for_python_hooks_repo, logger_mock): |
144 | 146 | repo = Repository(config_for_python_hooks_repo) |
145 | 147 | repo.require_created() |
146 | | - print_mock.assert_called_with('This may take a few minutes...') |
147 | | - print_mock.reset_mock() |
| 148 | + logger_mock.assert_called_with('This may take a few minutes...') |
| 149 | + logger_mock.reset_mock() |
148 | 150 | # Reinstall with same repo should not trigger another install |
149 | 151 | repo.require_created() |
150 | | - assert print_mock.call_count == 0 |
| 152 | + assert logger_mock.call_count == 0 |
151 | 153 | # Reinstall on another run should not trigger another install |
152 | 154 | repo = Repository(config_for_python_hooks_repo) |
153 | 155 | repo.require_created() |
154 | | - assert print_mock.call_count == 0 |
| 156 | + assert logger_mock.call_count == 0 |
155 | 157 |
|
156 | 158 |
|
157 | 159 | def test_reinstall(config_for_python_hooks_repo): |
|
0 commit comments