aboutsummaryrefslogtreecommitdiffstats
path: root/rest_framework/tests/fields.py
diff options
context:
space:
mode:
authorPablo Recio2013-05-18 12:51:40 +0200
committerPablo Recio2013-05-18 12:51:40 +0200
commit53a80044016c2ea0f4551735b0f974d1571d52ee (patch)
treeb79711fc0854ea614f8a51c850fda870e4d07630 /rest_framework/tests/fields.py
parentab8bd566f9db327a4c463317011818d421bbf89c (diff)
parent2a3056d03844a31373f1e30aec58e70616115838 (diff)
downloaddjango-rest-framework-53a80044016c2ea0f4551735b0f974d1571d52ee.tar.bz2
Merge branch 'master' into 725-blank-choice-dash
Conflicts: rest_framework/tests/fields.py
Diffstat (limited to 'rest_framework/tests/fields.py')
-rw-r--r--rest_framework/tests/fields.py17
1 files changed, 15 insertions, 2 deletions
diff --git a/rest_framework/tests/fields.py b/rest_framework/tests/fields.py
index f313ba60..6b1cdfc7 100644
--- a/rest_framework/tests/fields.py
+++ b/rest_framework/tests/fields.py
@@ -2,13 +2,12 @@
General serializer field tests.
"""
from __future__ import unicode_literals
+from django.utils.datastructures import SortedDict
import datetime
from decimal import Decimal
-
from django.db import models
from django.test import TestCase
from django.core import validators
-
from rest_framework import serializers
from rest_framework.serializers import Serializer
@@ -63,6 +62,20 @@ class BasicFieldTests(TestCase):
serializer = CharPrimaryKeyModelSerializer()
self.assertEqual(serializer.fields['id'].read_only, False)
+ def test_dict_field_ordering(self):
+ """
+ Field should preserve dictionary ordering, if it exists.
+ See: https://github.com/tomchristie/django-rest-framework/issues/832
+ """
+ ret = SortedDict()
+ ret['c'] = 1
+ ret['b'] = 1
+ ret['a'] = 1
+ ret['z'] = 1
+ field = serializers.Field()
+ keys = list(field.to_native(ret).keys())
+ self.assertEqual(keys, ['c', 'b', 'a', 'z'])
+
class DateFieldTest(TestCase):
"""