Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Moved IgnorePendingDeprecationWarningsMixin in django.test.utils.

This mixin is useful whenever deprecating a large part of Django.
  • Loading branch information...
commit 3634948c883c89a9dbf303b9687331a2a5db43ce 1 parent 63a9555
Aymeric Augustin authored May 18, 2013
21  django/test/utils.py
... ...
@@ -1,4 +1,5 @@
1 1
 import re
  2
+import sys
2 3
 import warnings
3 4
 from functools import wraps
4 5
 from xml.dom.minidom import parseString, Node
@@ -380,3 +381,23 @@ def __exit__(self, exc_type, exc_value, traceback):
380 381
         if exc_type is not None:
381 382
             return
382 383
         self.final_queries = len(self.connection.queries)
  384
+
  385
+
  386
+class IgnoreDeprecationWarningsMixin(object):
  387
+
  388
+    warning_class = DeprecationWarning
  389
+
  390
+    def setUp(self):
  391
+        super(IgnoreDeprecationWarningsMixin, self).setUp()
  392
+        self.catch_warnings = warnings.catch_warnings()
  393
+        self.catch_warnings.__enter__()
  394
+        warnings.filterwarnings("ignore", category=self.warning_class)
  395
+
  396
+    def tearDown(self):
  397
+        self.catch_warnings.__exit__(*sys.exc_info())
  398
+        super(IgnoreDeprecationWarningsMixin, self).tearDown()
  399
+
  400
+
  401
+class IgnorePendingDeprecationWarningsMixin(IgnoreDeprecationWarningsMixin):
  402
+
  403
+        warning_class = PendingDeprecationWarning
4  tests/middleware/tests.py
@@ -18,14 +18,12 @@
18 18
 from django.middleware.gzip import GZipMiddleware
19 19
 from django.middleware.transaction import TransactionMiddleware
20 20
 from django.test import TransactionTestCase, TestCase, RequestFactory
21  
-from django.test.utils import override_settings
  21
+from django.test.utils import override_settings, IgnorePendingDeprecationWarningsMixin
22 22
 from django.utils import six
23 23
 from django.utils.encoding import force_str
24 24
 from django.utils.six.moves import xrange
25 25
 from django.utils.unittest import expectedFailure, skipIf
26 26
 
27  
-from transactions.tests import IgnorePendingDeprecationWarningsMixin
28  
-
29 27
 from .models import Band
30 28
 
31 29
 
14  tests/transactions/tests.py
@@ -5,6 +5,7 @@
5 5
 
6 6
 from django.db import connection, transaction, IntegrityError
7 7
 from django.test import TransactionTestCase, skipUnlessDBFeature
  8
+from django.test.utils import IgnorePendingDeprecationWarningsMixin
8 9
 from django.utils import six
9 10
 from django.utils.unittest import skipIf, skipUnless
10 11
 
@@ -319,19 +320,6 @@ def __call__(self):
319 320
         transaction.atomic(Callable())
320 321
 
321 322
 
322  
-class IgnorePendingDeprecationWarningsMixin(object):
323  
-
324  
-    def setUp(self):
325  
-        super(IgnorePendingDeprecationWarningsMixin, self).setUp()
326  
-        self.catch_warnings = warnings.catch_warnings()
327  
-        self.catch_warnings.__enter__()
328  
-        warnings.filterwarnings("ignore", category=PendingDeprecationWarning)
329  
-
330  
-    def tearDown(self):
331  
-        self.catch_warnings.__exit__(*sys.exc_info())
332  
-        super(IgnorePendingDeprecationWarningsMixin, self).tearDown()
333  
-
334  
-
335 323
 class TransactionTests(IgnorePendingDeprecationWarningsMixin, TransactionTestCase):
336 324
 
337 325
     def create_a_reporter_then_fail(self, first, last):
4  tests/transactions_regress/tests.py
@@ -4,11 +4,9 @@
4 4
                        IntegrityError)
5 5
 from django.db.transaction import commit_on_success, commit_manually, TransactionManagementError
6 6
 from django.test import TransactionTestCase, skipUnlessDBFeature
7  
-from django.test.utils import override_settings
  7
+from django.test.utils import override_settings, IgnorePendingDeprecationWarningsMixin
8 8
 from django.utils.unittest import skipIf, skipUnless
9 9
 
10  
-from transactions.tests import IgnorePendingDeprecationWarningsMixin
11  
-
12 10
 from .models import Mod, M2mA, M2mB, SubMod
13 11
 
14 12
 class ModelInheritanceTests(TransactionTestCase):

0 notes on commit 3634948

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