diff options
author | Ramiro Morales <cramm0@gmail.com> | 2013-09-01 10:47:35 -0300 |
---|---|---|
committer | Ramiro Morales <cramm0@gmail.com> | 2013-09-01 10:47:35 -0300 |
commit | c01cd4c4234368b050cb872defe5f16597db4bdb (patch) | |
tree | 20cb003e6ac39d63970a654ce400498c6e34ab98 /tests/serializers/tests.py | |
parent | 17d898dedd52db947a1b78383890d8a4c92ab6c2 (diff) | |
download | django-c01cd4c4234368b050cb872defe5f16597db4bdb.tar.gz |
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.
Diffstat (limited to 'tests/serializers/tests.py')
-rw-r--r-- | tests/serializers/tests.py | 22 |
1 files 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): |