Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Modified a fixtures_regress test case to make it more robust to datab…
…ase ordering.

git-svn-id: http://code.djangoproject.com/svn/django/trunk@13958 bcc190cf-cafb-0310-a4f2-bffc1f526a37
  • Loading branch information
freakboy3742 committed Sep 29, 2010
1 parent e5c41c7 commit e2f55fb
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions tests/regressiontests/fixtures_regress/tests.py
Expand Up @@ -304,10 +304,17 @@ def test_dumpdata_uses_default_manager(self):
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):
"""
Expand Down

0 comments on commit e2f55fb

Please sign in to comment.