From c1fe5da85f936453a592fa683928672bb1911217 Mon Sep 17 00:00:00 2001 From: Tom Christie Date: Wed, 25 Jan 2012 20:39:01 +0000 Subject: Refactoring get_name/get_description --- djangorestframework/tests/renderers.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'djangorestframework/tests/renderers.py') diff --git a/djangorestframework/tests/renderers.py b/djangorestframework/tests/renderers.py index 77b5430f..9a02d0a9 100644 --- a/djangorestframework/tests/renderers.py +++ b/djangorestframework/tests/renderers.py @@ -177,6 +177,13 @@ _flat_repr = '{"foo": ["bar", "baz"]}' _indented_repr = '{\n "foo": [\n "bar",\n "baz"\n ]\n}' +def strip_trailing_whitespace(content): + """ + Seems to be some inconsistencies re. trailing whitespace with + different versions of the json lib. + """ + return re.sub(' +\n', '\n', content) + class JSONRendererTests(TestCase): """ Tests specific to the JSON Renderer @@ -190,7 +197,6 @@ class JSONRendererTests(TestCase): renderer = JSONRenderer(None) content = renderer.render(obj, 'application/json') # Fix failing test case which depends on version of JSON library. - content = re.sub(' +\n', '\n', content) self.assertEquals(content, _flat_repr) def test_with_content_type_args(self): @@ -200,7 +206,7 @@ class JSONRendererTests(TestCase): obj = {'foo': ['bar', 'baz']} renderer = JSONRenderer(None) content = renderer.render(obj, 'application/json; indent=2') - self.assertEquals(content, _indented_repr) + self.assertEquals(strip_trailing_whitespace(content), _indented_repr) def test_render_and_parse(self): """ -- cgit v1.2.3