Fixed result ordering assumptions in the select_related tests.

git-svn-id: http://code.djangoproject.com/svn/django/trunk@14762 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
Ian Kelly 2010-12-01 21:35:54 +00:00
parent 21f5dc467e
commit cd847db17f
1 changed files with 12 additions and 12 deletions

View File

@ -64,11 +64,11 @@ class SelectRelatedTests(TestCase):
def test(): def test():
world = Species.objects.all() world = Species.objects.all()
families = [o.genus.family.name for o in world] families = [o.genus.family.name for o in world]
self.assertEqual(families, [ self.assertEqual(sorted(families), [
'Drosophilidae',
'Hominidae',
'Fabaceae',
'Amanitacae', 'Amanitacae',
'Drosophilidae',
'Fabaceae',
'Hominidae',
]) ])
self.assertNumQueries(9, test) self.assertNumQueries(9, test)
@ -80,11 +80,11 @@ class SelectRelatedTests(TestCase):
def test(): def test():
world = Species.objects.all().select_related() world = Species.objects.all().select_related()
families = [o.genus.family.name for o in world] families = [o.genus.family.name for o in world]
self.assertEqual(families, [ self.assertEqual(sorted(families), [
'Drosophilidae',
'Hominidae',
'Fabaceae',
'Amanitacae', 'Amanitacae',
'Drosophilidae',
'Fabaceae',
'Hominidae',
]) ])
self.assertNumQueries(1, test) self.assertNumQueries(1, test)
@ -117,8 +117,8 @@ class SelectRelatedTests(TestCase):
def test(): def test():
world = Species.objects.all().select_related(depth=2) world = Species.objects.all().select_related(depth=2)
orders = [o.genus.family.order.name for o in world] orders = [o.genus.family.order.name for o in world]
self.assertEqual(orders, self.assertEqual(sorted(orders),
['Diptera', 'Primates', 'Fabales', 'Agaricales']) ['Agaricales', 'Diptera', 'Fabales', 'Primates'])
self.assertNumQueries(5, test) self.assertNumQueries(5, test)
def test_select_related_with_extra(self): def test_select_related_with_extra(self):
@ -138,8 +138,8 @@ class SelectRelatedTests(TestCase):
def test(): def test():
world = Species.objects.select_related('genus__family') world = Species.objects.select_related('genus__family')
families = [o.genus.family.name for o in world] families = [o.genus.family.name for o in world]
self.assertEqual(families, self.assertEqual(sorted(families),
['Drosophilidae', 'Hominidae', 'Fabaceae', 'Amanitacae']) ['Amanitacae', 'Drosophilidae', 'Fabaceae', 'Hominidae'])
self.assertNumQueries(1, test) self.assertNumQueries(1, test)
def test_more_certain_fields(self): def test_more_certain_fields(self):