Fixed #18042 -- Advanced deprecation warnings.
Thanks Ramiro for the patch.
This commit is contained in:
@@ -7,6 +7,7 @@ from django.conf import settings
|
|||||||
from django.contrib.formtools import preview, utils
|
from django.contrib.formtools import preview, utils
|
||||||
from django.contrib.formtools.wizard import FormWizard
|
from django.contrib.formtools.wizard import FormWizard
|
||||||
from django.test import TestCase
|
from django.test import TestCase
|
||||||
|
from django.test.utils import get_warnings_state, restore_warnings_state
|
||||||
from django.test.utils import override_settings
|
from django.test.utils import override_settings
|
||||||
from django.utils import unittest
|
from django.utils import unittest
|
||||||
|
|
||||||
@@ -40,12 +41,20 @@ class PreviewTests(TestCase):
|
|||||||
|
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
super(PreviewTests, self).setUp()
|
super(PreviewTests, self).setUp()
|
||||||
|
self.save_warnings_state()
|
||||||
|
warnings.filterwarnings('ignore', category=DeprecationWarning,
|
||||||
|
module='django.contrib.formtools.wizard.legacy')
|
||||||
|
|
||||||
# Create a FormPreview instance to share between tests
|
# Create a FormPreview instance to share between tests
|
||||||
self.preview = preview.FormPreview(TestForm)
|
self.preview = preview.FormPreview(TestForm)
|
||||||
input_template = '<input type="hidden" name="%s" value="%s" />'
|
input_template = '<input type="hidden" name="%s" value="%s" />'
|
||||||
self.input = input_template % (self.preview.unused_name('stage'), "%d")
|
self.input = input_template % (self.preview.unused_name('stage'), "%d")
|
||||||
self.test_data = {'field1':u'foo', 'field1_':u'asdf'}
|
self.test_data = {'field1':u'foo', 'field1_':u'asdf'}
|
||||||
|
|
||||||
|
def tearDown(self):
|
||||||
|
super(PreviewTests, self).tearDown()
|
||||||
|
self.restore_warnings_state()
|
||||||
|
|
||||||
def test_unused_name(self):
|
def test_unused_name(self):
|
||||||
"""
|
"""
|
||||||
Verifies name mangling to get uniue field name.
|
Verifies name mangling to get uniue field name.
|
||||||
|
|||||||
@@ -39,7 +39,7 @@ class FormWizard(object):
|
|||||||
warnings.warn(
|
warnings.warn(
|
||||||
'Old-style form wizards have been deprecated; use the class-based '
|
'Old-style form wizards have been deprecated; use the class-based '
|
||||||
'views in django.contrib.formtools.wizard.views instead.',
|
'views in django.contrib.formtools.wizard.views instead.',
|
||||||
PendingDeprecationWarning)
|
DeprecationWarning)
|
||||||
|
|
||||||
def __repr__(self):
|
def __repr__(self):
|
||||||
return "step: %d\nform_list: %s\ninitial_data: %s" % (self.step, self.form_list, self.initial)
|
return "step: %d\nform_list: %s\ninitial_data: %s" % (self.step, self.form_list, self.initial)
|
||||||
|
|||||||
Reference in New Issue
Block a user