aboutsummaryrefslogtreecommitdiffstats
path: root/djangorestframework/tests
diff options
context:
space:
mode:
authorTom Christie2012-01-25 20:39:01 +0000
committerTom Christie2012-01-25 20:39:01 +0000
commitc1fe5da85f936453a592fa683928672bb1911217 (patch)
treec8d3c37bd13403ec82846b648ec9715a2c6ae578 /djangorestframework/tests
parentf5e54c7c32e8f42c55947e53ce841622177f6c95 (diff)
downloaddjango-rest-framework-c1fe5da85f936453a592fa683928672bb1911217.tar.bz2
Refactoring get_name/get_description
Diffstat (limited to 'djangorestframework/tests')
-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):
"""