Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Silenced a DeprecationWarning in formtools caused by testing the depr…

…ecated security_hash function

git-svn-id: http://code.djangoproject.com/svn/django/trunk@15996 bcc190cf-cafb-0310-a4f2-bffc1f526a37
  • Loading branch information...
commit 4749159d48c42c706cd14ab105179f29deab734d 1 parent 27efda5
Russell Keith-Magee authored April 02, 2011
16  django/contrib/formtools/tests/__init__.py
... ...
@@ -1,9 +1,11 @@
1 1
 import os
  2
+import warnings
2 3
 
3 4
 from django import forms, http
4 5
 from django.conf import settings
5 6
 from django.contrib.formtools import preview, wizard, utils
6 7
 from django.test import TestCase
  8
+from django.test.utils import get_warnings_state, restore_warnings_state
7 9
 from django.utils import unittest
8 10
 
9 11
 
@@ -32,12 +34,19 @@ class PreviewTests(TestCase):
32 34
     urls = 'django.contrib.formtools.tests.urls'
33 35
 
34 36
     def setUp(self):
  37
+        self.save_warnings_state()
  38
+        warnings.filterwarnings('ignore', category=DeprecationWarning,
  39
+                                module='django.contrib.formtools.utils')
  40
+
35 41
         # Create a FormPreview instance to share between tests
36 42
         self.preview = preview.FormPreview(TestForm)
37 43
         input_template = '<input type="hidden" name="%s" value="%s" />'
38 44
         self.input = input_template % (self.preview.unused_name('stage'), "%d")
39 45
         self.test_data = {'field1':u'foo', 'field1_':u'asdf'}
40 46
 
  47
+    def tearDown(self):
  48
+        self.restore_warnings_state()
  49
+
41 50
     def test_unused_name(self):
42 51
         """
43 52
         Verifies name mangling to get uniue field name.
@@ -150,6 +159,13 @@ def test_form_submit_bad_hash(self):
150 159
 
151 160
 
152 161
 class SecurityHashTests(unittest.TestCase):
  162
+    def setUp(self):
  163
+        self._warnings_state = get_warnings_state()
  164
+        warnings.filterwarnings('ignore', category=DeprecationWarning,
  165
+                                module='django.contrib.formtools.utils')
  166
+
  167
+    def tearDown(self):
  168
+        restore_warnings_state(self._warnings_state)
153 169
 
154 170
     def test_textfield_hash(self):
155 171
         """

0 notes on commit 4749159

Please sign in to comment.
Something went wrong with that request. Please try again.