Fixed #13799, a test failure on Postgres. Thanks, Alex.

git-svn-id: http://code.djangoproject.com/svn/django/trunk@13400 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
Jacob Kaplan-Moss 2010-06-23 20:03:41 +00:00
parent 7773a92c7f
commit 6eafd412fc
1 changed files with 10 additions and 8 deletions

View File

@ -66,11 +66,13 @@ class M2MThroughTestCase(TestCase):
p = Person.objects.create(name="Bob") p = Person.objects.create(name="Bob")
g = Group.objects.create(name="Roll") g = Group.objects.create(name="Roll")
Membership.objects.create(person=p, group=g) m =Membership.objects.create(person=p, group=g)
pks = {"p_pk": p.pk, "g_pk": g.pk, "m_pk": m.pk}
out = StringIO() out = StringIO()
management.call_command("dumpdata", "m2m_through_regress", format="json", stdout=out) management.call_command("dumpdata", "m2m_through_regress", format="json", stdout=out)
self.assertEqual(out.getvalue().strip(), """[{"pk": 1, "model": "m2m_through_regress.membership", "fields": {"person": 1, "price": 100, "group": 1}}, {"pk": 1, "model": "m2m_through_regress.person", "fields": {"name": "Bob"}}, {"pk": 1, "model": "m2m_through_regress.group", "fields": {"name": "Roll"}}]""") self.assertEqual(out.getvalue().strip(), """[{"pk": %(m_pk)s, "model": "m2m_through_regress.membership", "fields": {"person": %(p_pk)s, "price": 100, "group": %(g_pk)s}}, {"pk": %(p_pk)s, "model": "m2m_through_regress.person", "fields": {"name": "Bob"}}, {"pk": %(g_pk)s, "model": "m2m_through_regress.group", "fields": {"name": "Roll"}}]""" % pks)
out = StringIO() out = StringIO()
management.call_command("dumpdata", "m2m_through_regress", format="xml", management.call_command("dumpdata", "m2m_through_regress", format="xml",
@ -78,19 +80,19 @@ class M2MThroughTestCase(TestCase):
self.assertEqual(out.getvalue().strip(), """ self.assertEqual(out.getvalue().strip(), """
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<django-objects version="1.0"> <django-objects version="1.0">
<object pk="1" model="m2m_through_regress.membership"> <object pk="%(m_pk)s" model="m2m_through_regress.membership">
<field to="m2m_through_regress.person" name="person" rel="ManyToOneRel">1</field> <field to="m2m_through_regress.person" name="person" rel="ManyToOneRel">%(p_pk)s</field>
<field to="m2m_through_regress.group" name="group" rel="ManyToOneRel">1</field> <field to="m2m_through_regress.group" name="group" rel="ManyToOneRel">%(g_pk)s</field>
<field type="IntegerField" name="price">100</field> <field type="IntegerField" name="price">100</field>
</object> </object>
<object pk="1" model="m2m_through_regress.person"> <object pk="%(p_pk)s" model="m2m_through_regress.person">
<field type="CharField" name="name">Bob</field> <field type="CharField" name="name">Bob</field>
</object> </object>
<object pk="1" model="m2m_through_regress.group"> <object pk="%(g_pk)s" model="m2m_through_regress.group">
<field type="CharField" name="name">Roll</field> <field type="CharField" name="name">Roll</field>
</object> </object>
</django-objects> </django-objects>
""".strip()) """.strip() % pks)
def test_join_trimming(self): def test_join_trimming(self):
"Check that we don't involve too many copies of the intermediate table when doing a join. Refs #8046, #8254" "Check that we don't involve too many copies of the intermediate table when doing a join. Refs #8046, #8254"