Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

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
  • Loading branch information...
commit 29a9c34c655de418a945aa02295425081d52a024 1 parent 2da6628
@freakboy3742 freakboy3742 authored
Showing with 11 additions and 90 deletions.
  1. +11 −90 tests/regressiontests/m2m_through_regress/models.py
View
101 tests/regressiontests/m2m_through_regress/models.py
@@ -102,19 +102,21 @@ def __unicode__(self):
# 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",
"fields": {
@@ -124,42 +126,6 @@ def __unicode__(self):
}
},
{
- "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",
"fields": {
@@ -168,20 +134,6 @@ def __unicode__(self):
},
{
"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",
"fields": {
"name": "Roll"
@@ -193,45 +145,14 @@ def __unicode__(self):
>>> management.call_command('dumpdata', 'm2m_through_regress', format='xml', indent=2)
<?xml version="1.0" encoding="utf-8"?>
<django-objects version="1.0">
- <object pk="1" model="m2m_through_regress.membership">
- <field to="m2m_through_regress.person" name="person" rel="ManyToOneRel">1</field>
- <field to="m2m_through_regress.group" name="group" rel="ManyToOneRel">1</field>
- <field type="IntegerField" name="price">100</field>
- </object>
<object pk="2" model="m2m_through_regress.membership">
<field to="m2m_through_regress.person" name="person" rel="ManyToOneRel">1</field>
<field to="m2m_through_regress.group" name="group" rel="ManyToOneRel">2</field>
<field type="IntegerField" name="price">100</field>
</object>
- <object pk="3" model="m2m_through_regress.membership">
- <field to="m2m_through_regress.person" name="person" rel="ManyToOneRel">2</field>
- <field to="m2m_through_regress.group" name="group" rel="ManyToOneRel">1</field>
- <field type="IntegerField" name="price">100</field>
- </object>
- <object pk="1" model="m2m_through_regress.usermembership">
- <field to="auth.user" name="user" rel="ManyToOneRel">1</field>
- <field to="m2m_through_regress.group" name="group" rel="ManyToOneRel">1</field>
- <field type="IntegerField" name="price">100</field>
- </object>
- <object pk="2" model="m2m_through_regress.usermembership">
- <field to="auth.user" name="user" rel="ManyToOneRel">1</field>
- <field to="m2m_through_regress.group" name="group" rel="ManyToOneRel">2</field>
- <field type="IntegerField" name="price">100</field>
- </object>
- <object pk="3" model="m2m_through_regress.usermembership">
- <field to="auth.user" name="user" rel="ManyToOneRel">2</field>
- <field to="m2m_through_regress.group" name="group" rel="ManyToOneRel">1</field>
- <field type="IntegerField" name="price">100</field>
- </object>
<object pk="1" model="m2m_through_regress.person">
<field type="CharField" name="name">Bob</field>
</object>
- <object pk="2" model="m2m_through_regress.person">
- <field type="CharField" name="name">Jim</field>
- </object>
- <object pk="1" model="m2m_through_regress.group">
- <field type="CharField" name="name">Rock</field>
- </object>
<object pk="2" model="m2m_through_regress.group">
<field type="CharField" name="name">Roll</field>
</object>
Please sign in to comment.
Something went wrong with that request. Please try again.