def assert_error(response, status_code, headers=None, **kwargs):
 headers = (headers or {})
 def error_cmp(response_body, body):
  return (isinstance(response_body, dict) and (set(response_body.keys()) == set((list(body.keys()) + ['error']))) and all(((response_body.get(k) == v) for (k, v) in body.items())))
 assert_json_response(response, status_code, kwargs, headers, error_cmp)

def assert_error ( response , status_code , headers = None , ** kwargs ) : headers = ( headers or { } ) def error_cmp ( response_body , body ) : return ( isinstance ( response_body , dict ) and ( set ( response_body . keys ( ) ) == set ( ( list ( body . keys ( ) ) + [ 'error' ] ) ) ) and all ( ( ( response_body . get ( k ) == v ) for ( k , v ) in body . items ( ) ) ) ) assert_json_response ( response , status_code , kwargs , headers , error_cmp )
assert error response has the expected status_code and kwargs .