return resp


class GetDataTest(unittest.TestCase):

    def test_get_data(self):
        with mock.patch.object(requests, 'get') as get_mock:
            get_mock.return_value = mock_response = mock.Mock()
mock_response.status_code = 200
mock_response.content = {'twitter_handle': '@twitter'}
resp = get_data('http://this_address_does_not_exist.com')
self.assertEqual(resp.status_code, 200)
self.assertEqual(resp.content['twitter_handle'], '@twitter')
Как издеваться над внешними серверами в модульных тестах Python?