def test_bad_response(self, http): http.return_value = BadResponse('the url', 'some err') with self.assertRaises(RuntimeError) as ctx: _get_json_for_fragment({'node-url': 'http://localhost:1234'}, '/fragment') self.assertTrue( "Failed to get" in str(ctx.exception) )
def test_bad_response(self): def do_http(*args, **kw): return with self.assertRaises(RuntimeError) as ctx: _handle_response_for_fragment( BadResponse('the url', 'some err'), 'http://localhost:1234', ) self.assertIn( "Failed to get", str(ctx.exception), )