From 4c047b8222d04d352fd6fc08506284a48cab579a Mon Sep 17 00:00:00 2001 From: Charles Ruhland Date: Thu, 17 Nov 2016 06:27:11 -0800 Subject: [PATCH] test_marathon: fix failing test caused by requests library update (#834) --- tests/test_marathon.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/tests/test_marathon.py b/tests/test_marathon.py index d835eba..04d65cc 100644 --- a/tests/test_marathon.py +++ b/tests/test_marathon.py @@ -361,10 +361,12 @@ def test_rpc_client_http_req_returns_method_fn_result(): def test_rpc_client_http_req_propagates_method_fn_exception_1(): request = requests.Request(method='ANY', url='http://arbitrary/url') - response = requests.Response() + # Need the mock so that the `.json()` method can be overridden + response = mock.create_autospec(requests.Response) response.status_code = 403 response.reason = 'Forbidden' response.request = request + response.json.side_effect = Exception('not JSON') def method_fn(*args, **kwargs): raise DCOSHTTPException(response) @@ -384,7 +386,7 @@ def test_rpc_client_http_req_propagates_method_fn_exception_1(): def test_rpc_client_http_req_propagates_method_fn_exception_2(): request = requests.Request(method='NONE', url='http://host/path') - # Need the mock so that the json() method can be overridden + # Need the mock so that the `.json()` method can be overridden response = mock.create_autospec(requests.Response) response.status_code = 422 response.reason = 'Something Bad'