0
0
mirror of https://github.com/django/django.git synced 2024-12-01 15:42:04 +01:00

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.
This commit is contained in:
Ramiro Morales 2013-09-01 10:47:35 -03:00
parent 17d898dedd
commit c01cd4c423

View File

@ -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):