1
0
mirror of https://github.com/django/django.git synced 2025-10-24 06:06:09 +00:00

Refs #23656 -- Required FormMixin.get_form() form_class parameter to be optional.

Per deprecation timeline.
This commit is contained in:
Tim Graham
2015-09-03 14:41:54 -04:00
parent 849037af36
commit 491de4f07c
3 changed files with 1 additions and 56 deletions

View File

@@ -1,13 +1,10 @@
from __future__ import unicode_literals
import warnings
from django import forms
from django.core.exceptions import ImproperlyConfigured
from django.core.urlresolvers import reverse
from django.test import SimpleTestCase, TestCase, override_settings
from django.test.client import RequestFactory
from django.utils.deprecation import RemovedInDjango110Warning
from django.views.generic.base import View
from django.views.generic.edit import CreateView, FormMixin, ModelFormMixin
@@ -59,28 +56,6 @@ class FormMixinTests(SimpleTestCase):
'get_form() should fallback to get_form_class() if none is provided.'
)
def test_get_form_missing_form_class_default_value(self):
with warnings.catch_warnings(record=True) as w:
warnings.filterwarnings('always')
class MissingDefaultValue(FormMixin):
request = RequestFactory().get('/')
form_class = forms.Form
def get_form(self, form_class):
return form_class(**self.get_form_kwargs())
self.assertEqual(len(w), 1)
self.assertEqual(w[0].category, RemovedInDjango110Warning)
self.assertEqual(
str(w[0].message),
'`generic_views.test_edit.MissingDefaultValue.get_form` method '
'must define a default value for its `form_class` argument.'
)
self.assertIsInstance(
MissingDefaultValue().get_form(), forms.Form,
)
def test_get_context_data(self):
class FormContext(FormMixin):
request = RequestFactory().get('/')