diff options
| author | Russell Keith-Magee <russell@keith-magee.com> | 2010-09-29 01:29:10 +0000 |
|---|---|---|
| committer | Russell Keith-Magee <russell@keith-magee.com> | 2010-09-29 01:29:10 +0000 |
| commit | f27d85b8f4fa16f0d98d4dd56a6a77575ac0e952 (patch) | |
| tree | 56d93005178552215cf52b8d44c4b5dde151733a /tests | |
| parent | a40380f37aab87a2bbde205356c7f3f63efe8e6c (diff) | |
[1.2.X] Modified a fixtures_regress test case to make it more robust to database ordering.
Backport of r13958 from trunk.
git-svn-id: http://code.djangoproject.com/svn/django/branches/releases/1.2.X@13959 bcc190cf-cafb-0310-a4f2-bffc1f526a37
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/regressiontests/fixtures_regress/tests.py | 15 |
1 files changed, 11 insertions, 4 deletions
diff --git a/tests/regressiontests/fixtures_regress/tests.py b/tests/regressiontests/fixtures_regress/tests.py index 4b5475e730..7f9890a2cc 100644 --- a/tests/regressiontests/fixtures_regress/tests.py +++ b/tests/regressiontests/fixtures_regress/tests.py @@ -304,10 +304,17 @@ class TestFixtures(TestCase): 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): """ |
