Skip to content

Commit

Permalink
Change test added in 3e34005 to be more stable.
Browse files Browse the repository at this point in the history
It could fail when actual serialization JSON field ordering was
different from the hard-coded one. Refs #13182.
  • Loading branch information
ramiro committed Sep 1, 2013
1 parent 17d898d commit c01cd4c
Showing 1 changed file with 5 additions and 17 deletions.
22 changes: 5 additions & 17 deletions tests/serializers/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

import json
from datetime import datetime
import re
import unittest
from xml.dom import minidom
try:
Expand Down Expand Up @@ -404,23 +405,10 @@ def test_indentation_whitespace(self):
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):
Expand Down

0 comments on commit c01cd4c

Please sign in to comment.