Ticket #17759: 17759-2.diff

File 17759-2.diff, 2.1 KB (added by Claude Paroz, 12 years ago)

With test

  • django/views/generic/edit.py

    diff --git a/django/views/generic/edit.py b/django/views/generic/edit.py
    index 3cade52..f97027b 100644
    a b class FormMixin(object):  
    1919        """
    2020        Returns the initial data to use for forms on this view.
    2121        """
    22         return self.initial
     22        return dict(self.initial)
    2323
    2424    def get_form_class(self):
    2525        """
  • tests/regressiontests/generic_views/edit.py

    diff --git a/tests/regressiontests/generic_views/edit.py b/tests/regressiontests/generic_views/edit.py
    index 182615a..d70c786 100644
    a b from django.core.urlresolvers import reverse  
    55from django import forms
    66from django.test import TestCase
    77from django.utils.unittest import expectedFailure
     8from django.views.generic.edit import FormMixin
    89
    910from . import views
    1011from .models import Artist, Author
    1112
    1213
     14class FormMixinTests(TestCase):
     15    def test_initial_data(self):
     16        """ Test instance independence of initial data dict (see #17759) """
     17        form_1 = FormMixin()
     18        form_2 = FormMixin()
     19        initial_1 = form_1.get_initial()
     20        initial_1['a'] = 'abc'
     21        self.assertEqual(form_2.get_initial(), {})
     22
    1323class ModelFormMixinTests(TestCase):
    1424    def test_get_form(self):
    1525        form_class = views.AuthorGetQuerySetFormView().get_form_class()
  • tests/regressiontests/generic_views/tests.py

    diff --git a/tests/regressiontests/generic_views/tests.py b/tests/regressiontests/generic_views/tests.py
    index d387216..72aab03 100644
    a b from .dates import (ArchiveIndexViewTests, YearArchiveViewTests,  
    55    MonthArchiveViewTests, WeekArchiveViewTests, DayArchiveViewTests,
    66    DateDetailViewTests)
    77from .detail import DetailViewTest
    8 from .edit import (ModelFormMixinTests, CreateViewTests, UpdateViewTests,
    9     DeleteViewTests)
     8from .edit import (FormMixinTests, ModelFormMixinTests, CreateViewTests,
     9    UpdateViewTests, DeleteViewTests)
    1010from .list import ListViewTests
Back to Top