From c01cd4c4234368b050cb872defe5f16597db4bdb Mon Sep 17 00:00:00 2001 From: Ramiro Morales Date: Sun, 1 Sep 2013 10:47:35 -0300 Subject: [PATCH] Change test added in 3e34005b1b to be more stable. It could fail when actual serialization JSON field ordering was different from the hard-coded one. Refs #13182. --- tests/serializers/tests.py | 22 +++++----------------- 1 file changed, 5 insertions(+), 17 deletions(-) diff --git a/tests/serializers/tests.py b/tests/serializers/tests.py index 849c93c37e..381cc5ed87 100644 --- a/tests/serializers/tests.py +++ b/tests/serializers/tests.py @@ -3,6 +3,7 @@ from __future__ import unicode_literals import json from datetime import datetime +import re import unittest from xml.dom import minidom try: @@ -404,23 +405,10 @@ class JsonSerializerTestCase(SerializersTestBase, TestCase): 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 - } -} -] -""") + json_data = s.serialize(qset, indent=2) + for line in json_data.splitlines(): + if re.search(r'.+,\s*$', line): + self.assertEqual(line, line.rstrip()) class JsonSerializerTransactionTestCase(SerializersTransactionTestBase, TransactionTestCase):