aboutsummaryrefslogtreecommitdiffstats
path: root/djangorestframework/tests/renderers.py
diff options
context:
space:
mode:
Diffstat (limited to 'djangorestframework/tests/renderers.py')
-rw-r--r--djangorestframework/tests/renderers.py10
1 files changed, 8 insertions, 2 deletions
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):
"""