Author: russellm
Date: 2010-09-28 20:20:34 -0500 (Tue, 28 Sep 2010)
New Revision: 13958

Modified:
   django/trunk/tests/regressiontests/fixtures_regress/tests.py
Log:
Modified a fixtures_regress test case to make it more robust to database 
ordering.

Modified: django/trunk/tests/regressiontests/fixtures_regress/tests.py
===================================================================
--- django/trunk/tests/regressiontests/fixtures_regress/tests.py        
2010-09-28 15:09:06 UTC (rev 13957)
+++ django/trunk/tests/regressiontests/fixtures_regress/tests.py        
2010-09-29 01:20:34 UTC (rev 13958)
@@ -304,11 +304,18 @@
             format='json',
             stdout=stdout
         )
-        self.assertEqual(
-            stdout.getvalue(),
-            """[{"pk": 1, "model": "fixtures_regress.animal", "fields": 
{"count": 3, "weight": 1.2, "name": "Lion", "latin_name": "Panthera leo"}}, 
{"pk": 10, "model": "fixtures_regress.animal", "fields": {"count": 42, 
"weight": 1.2, "name": "Emu", "latin_name": "Dromaius novaehollandiae"}}, 
{"pk": 11, "model": "fixtures_regress.animal", "fields": {"count": 2, "weight": 
2.2000000000000002, "name": "Platypus", "latin_name": "Ornithorhynchus 
anatinus"}}]"""
-        )
 
+        # Output order isn't guaranteed, so check for parts
+        data = stdout.getvalue()
+        lion_json = '{"pk": 1, "model": "fixtures_regress.animal", "fields": 
{"count": 3, "weight": 1.2, "name": "Lion", "latin_name": "Panthera leo"}}'
+        emu_json = '{"pk": 10, "model": "fixtures_regress.animal", "fields": 
{"count": 42, "weight": 1.2, "name": "Emu", "latin_name": "Dromaius 
novaehollandiae"}}'
+        platypus_json = '{"pk": 11, "model": "fixtures_regress.animal", 
"fields": {"count": 2, "weight": 2.2000000000000002, "name": "Platypus", 
"latin_name": "Ornithorhynchus anatinus"}}'
+
+        self.assertEqual(len(data), len('[%s]' % ', '.join([lion_json, 
emu_json, platypus_json])))
+        self.assertTrue(lion_json in data)
+        self.assertTrue(emu_json in data)
+        self.assertTrue(platypus_json in data)
+
     def test_proxy_model_included(self):
         """
         Regression for #11428 - Proxy models aren't included when you dumpdata

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To post to this group, send email to django-upda...@googlegroups.com.
To unsubscribe from this group, send email to 
django-updates+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-updates?hl=en.

Reply via email to