Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Fixed #8067 -- Replaced dict literals in the model_formsets tests wit…

…h sorted lists of tuples to ensure compatibilty on different implementations of Python. Thanks Leo Soto for the patch.

git-svn-id: http://code.djangoproject.com/svn/django/trunk@8178 bcc190cf-cafb-0310-a4f2-bffc1f526a37
  • Loading branch information...
commit 61b335700ca89bbabc25fecd0df476dcae9a4309 1 parent 4c02342
@brosner brosner authored
Showing with 10 additions and 4 deletions.
  1. +10 −4 tests/modeltests/model_formsets/models.py
View
14 tests/modeltests/model_formsets/models.py
@@ -1,5 +1,10 @@
from django.db import models
+try:
+ sorted
+except NameError:
+ from django.utils.itercompat import sorted
+
class Author(models.Model):
name = models.CharField(max_length=100)
@@ -212,13 +217,14 @@ def __unicode__(self):
>>> AuthorFormSet = modelformset_factory(Author, max_num=2)
>>> formset = AuthorFormSet(queryset=qs)
->>> formset.initial
-[{'id': 1, 'name': u'Charles Baudelaire'}, {'id': 3, 'name': u'Paul Verlaine'}]
+>>> [sorted(x.items()) for x in formset.initial]
+[[('id', 1), ('name', u'Charles Baudelaire')], [('id', 3), ('name', u'Paul Verlaine')]]
>>> AuthorFormSet = modelformset_factory(Author, max_num=3)
>>> formset = AuthorFormSet(queryset=qs)
->>> formset.initial
-[{'id': 1, 'name': u'Charles Baudelaire'}, {'id': 3, 'name': u'Paul Verlaine'}, {'id': 2, 'name': u'Walt Whitman'}]
+>>> [sorted(x.items()) for x in formset.initial]
+[[('id', 1), ('name', u'Charles Baudelaire')], [('id', 3), ('name', u'Paul Verlaine')], [('id', 2), ('name', u'Walt Whitman')]]
+
# Inline Formsets ############################################################
Please sign in to comment.
Something went wrong with that request. Please try again.