Commit 18d5b053 authored by Vangelis Koukis's avatar Vangelis Koukis
Browse files

Revert "Escape control characters in HTTP body, when json"

This reverts commit 556d5f15.
For more information, please see the discussion on Issue #32.
parent 1accf2cb
...@@ -351,11 +351,7 @@ class ResponseManager(Logged): ...@@ -351,11 +351,7 @@ class ResponseManager(Logged):
""" """
self._get_response() self._get_response()
try: try:
# Ensure there are no line breaks in json string return loads(self._content)
results_in_dict = loads(self._content)
results_in_str = dumps(results_in_dict)
# Escape control characters and parse to python object
return loads(results_in_str.encode('unicode_escape'))
except ValueError as err: except ValueError as err:
raise ClientError('Response not formated in JSON - %s' % err) raise ClientError('Response not formated in JSON - %s' % err)
...@@ -205,14 +205,6 @@ class ResponseManager(TestCase): ...@@ -205,14 +205,6 @@ class ResponseManager(TestCase):
self.assertEqual(self.RM.json, FakeResp.HEADERS) self.assertEqual(self.RM.json, FakeResp.HEADERS)
self.assertTrue(isinstance(perform.call_args[0][0], self.HTTPC)) self.assertTrue(isinstance(perform.call_args[0][0], self.HTTPC))
# Check if some control characters are escaped
sample = dict(k1='Do not \b\b\b\b\b\b\bescape this', k2='Escape \nit')
exp = dict(
k1='Do not \\b\\b\\b\\b\\b\\b\\bescape this', k2='Escape \\nit')
FakeResp.READ = dumps(sample)
self.RM._request_performed = False
self.assertEqual(self.RM.json, exp)
@patch('kamaki.clients.RequestManager.perform', return_value=FakeResp()) @patch('kamaki.clients.RequestManager.perform', return_value=FakeResp())
def test_all(self, perform): def test_all(self, perform):
self.assertEqual(self.RM.content, FakeResp.READ) self.assertEqual(self.RM.content, FakeResp.READ)
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment