def read(self, raw=False, perform_traversal=True): """ Parse the body of the response using the Content-Type header we pulled from the response, or the hive-defined format, if such couldn't be pulled automatically. """ if not raw: response_body = decode(self.data, self.mimetype(), encoding=self.encoding()) if perform_traversal and self.traversal is not None: return traverse(response_body, *self.traversal) return response_body else: return self.data
def test_empty_data(self): self.assertEqual(decode(bytes(), 'application/json'), None)
def test_decode(self): self.assertEqual(decode(self.bytes, 'text/plain'), self.string)
def test_decode(self): self.assertEqual(decode(self.to_test, 'fake-mime'), self.to_test)
def test_decode(self): self.assertEqual(decode(self.testingbytes, 'application/json'), self.testingdict)