def assert_json_response(response, status_code, body, headers=None, body_cmp=operator.eq):
 headers = dict((headers or {}))
 headers['Content-Type'] = 'application/json'
 def json_cmp(response_body, body):
  return body_cmp(json.loads(response_body.decode('utf-8')), body)
 assert_response(response, status_code, body, headers, json_cmp)

def assert_json_response ( response , status_code , body , headers = None , body_cmp = operator . eq ) : headers = dict ( ( headers or { } ) ) headers [ 'Content-Type' ] = 'application/json' def json_cmp ( response_body , body ) : return body_cmp ( json . loads ( response_body . decode ( 'utf-8' ) ) , body ) assert_response ( response , status_code , body , headers , json_cmp )
assert json response has the expected status_code .