Ticket #16138: form_mixin_test.diff

File form_mixin_test.diff, 1.8 KB (added by wilfred@…, 13 years ago)

Test case to ensure get_initial() returns a fresh dict

  • tests/regressiontests/generic_views/edit.py

    diff --git a/tests/regressiontests/generic_views/edit.py b/tests/regressiontests/generic_views/edit.py
    index 0adcb15..e6113b0 100644
    a b from django.core.urlresolvers import reverse  
    33from django import forms
    44from django.test import TestCase
    55from django.utils.unittest import expectedFailure
     6from django.views.generic.edit import FormMixin
    67
    78from regressiontests.generic_views.models import Artist, Author
    89from regressiontests.generic_views import views
    910
     11class FormMixinTests(TestCase):
     12    def test_initial_not_shared(self):
     13        initial = FormMixin().get_initial()
     14        initial['foo'] = 'bar'
     15
     16        fresh_initial = FormMixin().get_initial()
     17
     18        self.assertNotEqual(initial, fresh_initial)
     19
    1020class ModelFormMixinTests(TestCase):
    1121    def test_get_form(self):
    1222        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 a4010aa..cc8b15b 100644
    a b  
    11from regressiontests.generic_views.base import ViewTest, TemplateViewTest, RedirectViewTest
    22from regressiontests.generic_views.dates import ArchiveIndexViewTests, YearArchiveViewTests, MonthArchiveViewTests, WeekArchiveViewTests, DayArchiveViewTests, DateDetailViewTests
    33from regressiontests.generic_views.detail import DetailViewTest
    4 from regressiontests.generic_views.edit import ModelFormMixinTests, CreateViewTests, UpdateViewTests, DeleteViewTests
     4from regressiontests.generic_views.edit import FormMixinTests, ModelFormMixinTests, CreateViewTests, UpdateViewTests, DeleteViewTests
    55from regressiontests.generic_views.list import ListViewTests
Back to Top