1
0
mirror of https://github.com/django/django.git synced 2025-10-24 06:06:09 +00:00

Fixed #13182 -- Prevented trailing spaces in indented json output

Thanks Stéphane Raimbault for the report and the initial patch.
This commit is contained in:
Claude Paroz
2013-08-31 15:05:17 +02:00
parent 9885f07757
commit 3e34005b1b
2 changed files with 28 additions and 0 deletions

View File

@@ -392,6 +392,31 @@ class JsonSerializerTestCase(SerializersTestBase, TestCase):
ret_list.append(obj_dict["fields"][field_name])
return ret_list
def test_indentation_whitespace(self):
Score.objects.create(score=5.0)
Score.objects.create(score=6.0)
qset = Score.objects.all()
s = serializers.json.Serializer()
self.assertEqual(s.serialize(qset, indent=2), """[
{
"pk": 1,
"model": "serializers.score",
"fields": {
"score": 5.0
}
},
{
"pk": 2,
"model": "serializers.score",
"fields": {
"score": 6.0
}
}
]
""")
class JsonSerializerTransactionTestCase(SerializersTransactionTestBase, TransactionTestCase):
serializer_name = "json"
fwd_ref_str = """[