aboutsummaryrefslogtreecommitdiffstats
path: root/djangorestframework/tests/renderers.py
diff options
context:
space:
mode:
authorSébastien Piquemal2012-02-02 08:39:15 +0200
committerSébastien Piquemal2012-02-02 08:39:15 +0200
commit5f59d90645dfddc293bbbbc4ca9b4c3f3125b590 (patch)
treeaa3d091a1f61f5717f7f1a9e96334308bb13c7d9 /djangorestframework/tests/renderers.py
parent152c385f4de37558fe4e522abad5b97f0cf7ddce (diff)
parent894f63259880252ed5317ce485eb13c4429b65c1 (diff)
downloaddjango-rest-framework-5f59d90645dfddc293bbbbc4ca9b4c3f3125b590.tar.bz2
merged with trunk's master
Diffstat (limited to 'djangorestframework/tests/renderers.py')
-rw-r--r--djangorestframework/tests/renderers.py12
1 files changed, 11 insertions, 1 deletions
diff --git a/djangorestframework/tests/renderers.py b/djangorestframework/tests/renderers.py
index adb46f7f..9a02d0a9 100644
--- a/djangorestframework/tests/renderers.py
+++ b/djangorestframework/tests/renderers.py
@@ -1,3 +1,5 @@
+import re
+
from django.conf.urls.defaults import patterns, url
from django.test import TestCase
@@ -175,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
@@ -187,6 +196,7 @@ class JSONRendererTests(TestCase):
obj = {'foo': ['bar', 'baz']}
renderer = JSONRenderer(None)
content = renderer.render(obj, 'application/json')
+ # Fix failing test case which depends on version of JSON library.
self.assertEquals(content, _flat_repr)
def test_with_content_type_args(self):
@@ -196,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):
"""