summaryrefslogtreecommitdiff
path: root/django
diff options
context:
space:
mode:
authorAymeric Augustin <aymeric.augustin@m4x.org>2013-05-18 16:40:03 +0200
committerAymeric Augustin <aymeric.augustin@m4x.org>2013-05-18 16:49:15 +0200
commit3634948c883c89a9dbf303b9687331a2a5db43ce (patch)
tree7ca7c36b50b8d66d9effbee5e801312d8c7c2613 /django
parent63a9555d57069cee32de388821dbe580da1f97c0 (diff)
Moved IgnorePendingDeprecationWarningsMixin in django.test.utils.
This mixin is useful whenever deprecating a large part of Django.
Diffstat (limited to 'django')
-rw-r--r--django/test/utils.py21
1 files changed, 21 insertions, 0 deletions
diff --git a/django/test/utils.py b/django/test/utils.py
index 92cef59f72..fb9221d25c 100644
--- a/django/test/utils.py
+++ b/django/test/utils.py
@@ -1,4 +1,5 @@
import re
+import sys
import warnings
from functools import wraps
from xml.dom.minidom import parseString, Node
@@ -380,3 +381,23 @@ class CaptureQueriesContext(object):
if exc_type is not None:
return
self.final_queries = len(self.connection.queries)
+
+
+class IgnoreDeprecationWarningsMixin(object):
+
+ warning_class = DeprecationWarning
+
+ def setUp(self):
+ super(IgnoreDeprecationWarningsMixin, self).setUp()
+ self.catch_warnings = warnings.catch_warnings()
+ self.catch_warnings.__enter__()
+ warnings.filterwarnings("ignore", category=self.warning_class)
+
+ def tearDown(self):
+ self.catch_warnings.__exit__(*sys.exc_info())
+ super(IgnoreDeprecationWarningsMixin, self).tearDown()
+
+
+class IgnorePendingDeprecationWarningsMixin(IgnoreDeprecationWarningsMixin):
+
+ warning_class = PendingDeprecationWarning