From c7cc4cfb9ebef17930db4a92cd0632a536a4ff7a Mon Sep 17 00:00:00 2001 From: Claude Paroz Date: Sat, 17 Mar 2012 22:31:03 +0000 Subject: Fixed #16138 -- Made FormMixin get_initial return a copy of the 'initial' class variable. Thanks hanson2010, wilfred@potatolondon.com and agriffis for their work on the patch. git-svn-id: http://code.djangoproject.com/svn/django/trunk@17765 bcc190cf-cafb-0310-a4f2-bffc1f526a37 --- tests/regressiontests/generic_views/edit.py | 9 +++++++++ tests/regressiontests/generic_views/tests.py | 4 ++-- 2 files changed, 11 insertions(+), 2 deletions(-) (limited to 'tests') diff --git a/tests/regressiontests/generic_views/edit.py b/tests/regressiontests/generic_views/edit.py index 2bd982e3d9..651e14fff3 100644 --- a/tests/regressiontests/generic_views/edit.py +++ b/tests/regressiontests/generic_views/edit.py @@ -5,11 +5,20 @@ from django.core.urlresolvers import reverse from django import forms from django.test import TestCase from django.utils.unittest import expectedFailure +from django.views.generic.edit import FormMixin from . import views from .models import Artist, Author +class FormMixinTests(TestCase): + def test_initial_data(self): + """ Test instance independence of initial data dict (see #16138) """ + initial_1 = FormMixin().get_initial() + initial_1['foo'] = 'bar' + initial_2 = FormMixin().get_initial() + self.assertNotEqual(initial_1, initial_2) + class ModelFormMixinTests(TestCase): def test_get_form(self): form_class = views.AuthorGetQuerySetFormView().get_form_class() diff --git a/tests/regressiontests/generic_views/tests.py b/tests/regressiontests/generic_views/tests.py index d387216d41..72aab035a8 100644 --- a/tests/regressiontests/generic_views/tests.py +++ b/tests/regressiontests/generic_views/tests.py @@ -5,6 +5,6 @@ from .dates import (ArchiveIndexViewTests, YearArchiveViewTests, MonthArchiveViewTests, WeekArchiveViewTests, DayArchiveViewTests, DateDetailViewTests) from .detail import DetailViewTest -from .edit import (ModelFormMixinTests, CreateViewTests, UpdateViewTests, - DeleteViewTests) +from .edit import (FormMixinTests, ModelFormMixinTests, CreateViewTests, + UpdateViewTests, DeleteViewTests) from .list import ListViewTests -- cgit v1.3