From 93edededddd233ca76aa322c091e1d751fa116a0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Robert=20H=C3=B6nig?= Date: Mon, 27 Nov 2017 15:58:31 +0100 Subject: [PATCH] zulip_bots: Use real Response object for mock_http_conversation(). --- zulip_bots/zulip_bots/test_lib.py | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/zulip_bots/zulip_bots/test_lib.py b/zulip_bots/zulip_bots/test_lib.py index 2cd2c8a..8daa8de 100755 --- a/zulip_bots/zulip_bots/test_lib.py +++ b/zulip_bots/zulip_bots/test_lib.py @@ -136,12 +136,9 @@ class BotTestCaseBase(TestCase): http_response = http_data.get('response') http_headers = http_data.get('response-headers') with patch('requests.get') as mock_get: - mock_result = mock.MagicMock() - mock_result.json.return_value = http_response - if 'text' in http_response: - mock_result.text = http_response.get('text', None) + mock_result = requests.Response() + mock_result._content = json.dumps(http_response).encode() mock_result.status_code = http_headers.get('status', 200) - mock_result.ok.return_value = http_headers.get('ok', True) mock_get.return_value = mock_result yield if 'params' in http_request: