def assert_response(response, status_code, body, headers=None, body_cmp=operator.eq):
 headers = (headers or {})
 assert (response.status_code == status_code), 'Expected status code {}, got {}'.format(status_code, response.status_code)
 for (header, value) in headers.items():
  response_value = response.headers.get(header)
  assert (response_value == value), 'Expected {} header value {}, got {}'.format(header, value, response_value)
 assert body_cmp(response.data, body), 'Unexpected response body'

def assert_response ( response , status_code , body , headers = None , body_cmp = operator . eq ) : headers = ( headers or { } ) assert ( response . status_code == status_code ) , 'Expected status code {}, got {}' . format ( status_code , response . status_code ) for ( header , value ) in headers . items ( ) : response_value = response . headers . get ( header ) assert ( response_value == value ) , 'Expected {} header value {}, got {}' . format ( header , value , response_value ) assert body_cmp ( response . data , body ) , 'Unexpected response body'
assert response has the expected status_code .