From b147c9e221134a3b47de101cb4f5ddde050cbb70 Mon Sep 17 00:00:00 2001 From: Alex Gaynor Date: Tue, 28 May 2013 07:22:42 -0700 Subject: [PATCH] Made tests use a JSON parser in liue of eval. The results that are being parsed are really JSON, so using a JSON parser is more semantically correct; in addition using eval anywhere can set a bad example. Change-Id: Idcd55400b2571aba0f2f377cf66a3cbf4d3af960 --- test/unit/container/test_server.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/test/unit/container/test_server.py b/test/unit/container/test_server.py index ca261f12e8..201e9d8b86 100644 --- a/test/unit/container/test_server.py +++ b/test/unit/container/test_server.py @@ -722,7 +722,7 @@ class TestContainerController(unittest.TestCase): environ={'REQUEST_METHOD': 'GET'}) resp = self.controller.GET(req) self.assertEquals(resp.status_int, 200) - self.assertEquals(eval(resp.body), []) + self.assertEquals(simplejson.loads(resp.body), []) # fill the container for i in range(3): req = Request.blank('/sda1/p/a/jsonc/%s' % i, environ={ @@ -754,7 +754,7 @@ class TestContainerController(unittest.TestCase): environ={'REQUEST_METHOD': 'GET'}) resp = self.controller.GET(req) self.assertEquals(resp.content_type, 'application/json') - self.assertEquals(eval(resp.body), json_body) + self.assertEquals(simplejson.loads(resp.body), json_body) self.assertEquals(resp.charset, 'utf-8') resp = self.controller.HEAD(req) @@ -766,7 +766,7 @@ class TestContainerController(unittest.TestCase): environ={'REQUEST_METHOD': 'GET'}) req.accept = accept resp = self.controller.GET(req) - self.assertEquals(eval(resp.body), json_body, + self.assertEquals(simplejson.loads(resp.body), json_body, 'Invalid body for Accept: %s' % accept) self.assertEquals(resp.content_type, 'application/json', 'Invalid content_type for Accept: %s' % accept) @@ -871,7 +871,7 @@ class TestContainerController(unittest.TestCase): environ={'REQUEST_METHOD': 'GET'}) resp = self.controller.GET(req) self.assertEquals(resp.content_type, 'application/json') - self.assertEquals(eval(resp.body), json_body) + self.assertEquals(simplejson.loads(resp.body), json_body) self.assertEquals(resp.charset, 'utf-8') def test_GET_xml(self):