Skip to content

Commit 1323724

Browse files
committed
fix mockito usage
fixes #3986
1 parent a45812a commit 1323724

File tree

4 files changed

+8
-8
lines changed

4 files changed

+8
-8
lines changed

tools/setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ def readme():
4646
'pytest',
4747
'GitPython',
4848
'pytest-xdist',
49-
'mockito==1.3.0',
49+
'mockito>=1.3.3',
5050
'pytest-mockito',
5151
],
5252
entry_points={

tools/src/test/python/test_mirror.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -211,7 +211,7 @@ def test_disabled_command_api():
211211
call is specified in the configuration for disabled project.
212212
"""
213213
def mock_call_rest_api(command, b, http_headers=None, timeout=None, api_timeout=None):
214-
return mock(spec=requests.Response)
214+
return mock({"status_code": 200}, spec=requests.Response, strict=False)
215215

216216
with patch(opengrok_tools.utils.mirror.call_rest_api,
217217
mock_call_rest_api):
@@ -249,7 +249,7 @@ def mock_call_rest_api(call, b, http_headers=None, timeout=None, api_timeout=Non
249249
assert text
250250
assert text.find(text_to_append)
251251

252-
return mock(spec=requests.Response)
252+
return mock({"status_code": 200}, spec=requests.Response, strict=False)
253253

254254
with monkeypatch.context() as m:
255255
m.setattr("opengrok_tools.utils.mirror.call_rest_api",
@@ -302,7 +302,7 @@ def test_ignore_errors_sync(monkeypatch, per_project):
302302
Test that ignore errors overrides failed repository sync().
303303
"""
304304

305-
mock_repo = mock(spec=GitRepository)
305+
mock_repo = mock({"path": "foo"}, spec=GitRepository, strict=False)
306306
when(mock_repo).sync().thenReturn(FAILURE_EXITVAL)
307307

308308
def mock_get_repos(*args, **kwargs):
@@ -338,7 +338,7 @@ def test_ignore_errors_hooks(monkeypatch, hook_type, per_project):
338338
"""
339339

340340
def mock_get_repos(*args, **kwargs):
341-
return [mock(spec=GitRepository)]
341+
return [mock({"path": "foo"}, spec=GitRepository, strict=False)]
342342

343343
spy2(opengrok_tools.utils.mirror.process_hook)
344344
project_name = "foo"
@@ -381,7 +381,7 @@ def test_disabled_command_run_args():
381381
"""
382382
Make sure that run_command() calls Command.execute().
383383
"""
384-
cmd = mock(spec=Command)
384+
cmd = mock(spec=Command, strict=False)
385385
project_name = "foo"
386386
run_command(cmd, project_name)
387387
verify(cmd).execute()

tools/src/test/python/test_readconfig.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ def test_read_config_empty_yaml():
3434
tmpf = tempfile.NamedTemporaryFile(mode='w+t', delete=False)
3535
tmpf.file.write('#foo\n')
3636
tmpf.close()
37-
res = read_config(mock(spec=logging.Logger), tmpf.name)
37+
res = read_config(mock(spec=logging.Logger, strict=False), tmpf.name)
3838
os.remove(tmpf.name)
3939
assert res is not None
4040
assert type(res) == dict

tools/src/test/python/test_restful.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,7 @@ def test_headers_timeout_requests():
167167
timeout = 44
168168

169169
def mock_requests_get(uri, **kwargs):
170-
return mock(spec=requests.Response)
170+
return mock({"status_code": 200}, spec=requests.Response, strict=False)
171171

172172
with patch(requests.get, mock_requests_get):
173173
do_api_call("GET", uri, headers=headers, timeout=timeout)

0 commit comments

Comments
 (0)