From 29a9c34c655de418a945aa02295425081d52a024 Mon Sep 17 00:00:00 2001 From: Russell Keith-Magee Date: Thu, 14 Aug 2008 14:43:29 +0000 Subject: [PATCH] Fixed #8286 -- Simplified the m2m intermediate serialization test to make it easier to debug, and less prone to failures caused by test execution order. Thanks to jarrow for the report, and Karen Tracey for her help confirming the problem. git-svn-id: http://code.djangoproject.com/svn/django/trunk@8347 bcc190cf-cafb-0310-a4f2-bffc1f526a37 --- .../m2m_through_regress/models.py | 101 ++---------------- 1 file changed, 11 insertions(+), 90 deletions(-) diff --git a/tests/regressiontests/m2m_through_regress/models.py b/tests/regressiontests/m2m_through_regress/models.py index eed0cc1b5f..16a3ab2ce3 100644 --- a/tests/regressiontests/m2m_through_regress/models.py +++ b/tests/regressiontests/m2m_through_regress/models.py @@ -102,18 +102,20 @@ AttributeError: Cannot use create() on a ManyToManyField which specifies an inte # Regression test for #8134 -- # m2m-through models shouldn't be serialized as m2m fields on the model. + +# First, clean up a lot of objects we don't need. +# The serialization test only requires three objects to work - +# one for each end of the m2m, plus the through model. + +>>> User.objects.all().delete() +>>> UserMembership.objects.all().delete() +>>> frank.delete() +>>> rock.delete() +>>> jim.delete() + # Dump the current contents of the database as a JSON fixture >>> management.call_command('dumpdata', 'm2m_through_regress', format='json', indent=2) [ - { - "pk": 1, - "model": "m2m_through_regress.membership", - "fields": { - "person": 1, - "price": 100, - "group": 1 - } - }, { "pk": 2, "model": "m2m_through_regress.membership", @@ -123,42 +125,6 @@ AttributeError: Cannot use create() on a ManyToManyField which specifies an inte "group": 2 } }, - { - "pk": 3, - "model": "m2m_through_regress.membership", - "fields": { - "person": 2, - "price": 100, - "group": 1 - } - }, - { - "pk": 1, - "model": "m2m_through_regress.usermembership", - "fields": { - "price": 100, - "group": 1, - "user": 1 - } - }, - { - "pk": 2, - "model": "m2m_through_regress.usermembership", - "fields": { - "price": 100, - "group": 2, - "user": 1 - } - }, - { - "pk": 3, - "model": "m2m_through_regress.usermembership", - "fields": { - "price": 100, - "group": 1, - "user": 2 - } - }, { "pk": 1, "model": "m2m_through_regress.person", @@ -166,20 +132,6 @@ AttributeError: Cannot use create() on a ManyToManyField which specifies an inte "name": "Bob" } }, - { - "pk": 2, - "model": "m2m_through_regress.person", - "fields": { - "name": "Jim" - } - }, - { - "pk": 1, - "model": "m2m_through_regress.group", - "fields": { - "name": "Rock" - } - }, { "pk": 2, "model": "m2m_through_regress.group", @@ -193,45 +145,14 @@ AttributeError: Cannot use create() on a ManyToManyField which specifies an inte >>> management.call_command('dumpdata', 'm2m_through_regress', format='xml', indent=2) - - 1 - 1 - 100 - 1 2 100 - - 2 - 1 - 100 - - - 1 - 1 - 100 - - - 1 - 2 - 100 - - - 2 - 1 - 100 - Bob - - Jim - - - Rock - Roll