diff --git a/formtools/tests/__init__.py b/formtools/tests/__init__.py index 96d1dda..88828e8 100644 --- a/formtools/tests/__init__.py +++ b/formtools/tests/__init__.py @@ -7,16 +7,12 @@ from django.conf import settings from django.contrib.formtools import preview, utils from django.contrib.formtools.wizard import FormWizard 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.utils import unittest from django.contrib.formtools.tests.wizard import * from django.contrib.formtools.tests.forms import * -warnings.filterwarnings('ignore', category=PendingDeprecationWarning, - module='django.contrib.formtools.wizard') - success_string = "Done was called!" class TestFormPreview(preview.FormPreview): @@ -41,20 +37,12 @@ class PreviewTests(TestCase): def setUp(self): 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 self.preview = preview.FormPreview(TestForm) input_template = '' self.input = input_template % (self.preview.unused_name('stage'), "%d") 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): """ Verifies name mangling to get uniue field name. @@ -130,8 +118,9 @@ class PreviewTests(TestCase): self.test_data.update({'stage':2}) hash = self.preview.security_hash(None, TestForm(self.test_data)) self.test_data.update({'hash':hash, 'bool1':u'False'}) - response = self.client.post('/preview/', self.test_data) - self.assertEqual(response.content, success_string) + with warnings.catch_warnings(record=True): + response = self.client.post('/preview/', self.test_data) + self.assertEqual(response.content, success_string) def test_form_submit_good_hash(self): """ @@ -241,6 +230,16 @@ class WizardTests(TestCase): } ) + def setUp(self): + super(WizardTests, self).setUp() + self.save_warnings_state() + warnings.filterwarnings('ignore', category=DeprecationWarning, + module='django.contrib.formtools.wizard') + + def tearDown(self): + super(WizardTests, self).tearDown() + self.restore_warnings_state() + def test_step_starts_at_zero(self): """ step should be zero for the first form