Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
self.faker.actual_body = body
def same_bodies(body_a, body_b):
return json.loads(body_a) == json.loads(body_b)
if self.faker.body is not None:
if not same_bodies(self.faker.body, body):
raise Exception("Faker's expected body (%s) doesn't match actual body (%s)" % (
self.faker.body, body))
data = self.faker.open() if self.faker else ''
status = self.faker.status if (
self.faker and self.faker.status) else 200
return self.handle_response(status, data)
c = VerifiedHTTPSConnection(parsed_base_uri.netloc, timeout=self.timeout)
c.request(method, self.build_url(
parsed_base_uri, path, params), body, headers)
response = c.getresponse()
if response.getheader('content-encoding', '') == 'gzip':
data = gzip.GzipFile(fileobj=BytesIO(response.read())).read()
else:
data = response.read()
c.close()
return self.handle_response(response.status, data)