'm2m-through models aren\'t serialized as m2m fields. Refs #8134'

def test_serialization(self):

    pks = {'p_pk': self.bob.pk, 'g_pk': self.roll.pk, 'm_pk': self.bob_roll.pk}
    out = StringIO()
    management.call_command('dumpdata', 'm2m_through_regress', format='json', stdout=out)
    self.assertJSONEqual(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()
    management.call_command('dumpdata', 'm2m_through_regress', format='xml', indent=2, stdout=out)
    self.assertXMLEqual(out.getvalue().strip(), ('\n<?xml    version="1.0"    encoding="utf-8"?>\n<django-objects    version="1.0">\n        <object    pk="%(m_pk)s"    model="m2m_through_regress.membership">\n                <field    to="m2m_through_regress.person"    name="person"    rel="ManyToOneRel">%(p_pk)s</field>\n                <field    to="m2m_through_regress.group"    name="group"    rel="ManyToOneRel">%(g_pk)s</field>\n                <field    type="IntegerField"    name="price">100</field>\n        </object>\n        <object    pk="%(p_pk)s"    model="m2m_through_regress.person">\n                <field    type="CharField"    name="name">Bob</field>\n        </object>\n        <object    pk="%(g_pk)s"    model="m2m_through_regress.group">\n                <field    type="CharField"    name="name">Roll</field>\n        </object>\n</django-objects>\n                                '.strip() % pks))
