def test_fetch_and_parse__unauthorized(self): from forager.exceptions import Unauthorized unauthorized_request_response = RequestResponse(text='', url='', status_code=401) with mock.patch('forager.requests.get', return_value=unauthorized_request_response): forager = Forager() with self.assertRaises(Unauthorized): forager._fetch_and_parse('a url')