Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

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
@aaugustin aaugustin authored
View
21 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 @@ def __exit__(self, exc_type, exc_value, traceback):
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
View
4 tests/middleware/tests.py
@@ -18,14 +18,12 @@
from django.middleware.gzip import GZipMiddleware
from django.middleware.transaction import TransactionMiddleware
from django.test import TransactionTestCase, TestCase, RequestFactory
-from django.test.utils import override_settings
+from django.test.utils import override_settings, IgnorePendingDeprecationWarningsMixin
from django.utils import six
from django.utils.encoding import force_str
from django.utils.six.moves import xrange
from django.utils.unittest import expectedFailure, skipIf
-from transactions.tests import IgnorePendingDeprecationWarningsMixin
-
from .models import Band
View
14 tests/transactions/tests.py
@@ -5,6 +5,7 @@
from django.db import connection, transaction, IntegrityError
from django.test import TransactionTestCase, skipUnlessDBFeature
+from django.test.utils import IgnorePendingDeprecationWarningsMixin
from django.utils import six
from django.utils.unittest import skipIf, skipUnless
@@ -319,19 +320,6 @@ def __call__(self):
transaction.atomic(Callable())
-class IgnorePendingDeprecationWarningsMixin(object):
-
- def setUp(self):
- super(IgnorePendingDeprecationWarningsMixin, self).setUp()
- self.catch_warnings = warnings.catch_warnings()
- self.catch_warnings.__enter__()
- warnings.filterwarnings("ignore", category=PendingDeprecationWarning)
-
- def tearDown(self):
- self.catch_warnings.__exit__(*sys.exc_info())
- super(IgnorePendingDeprecationWarningsMixin, self).tearDown()
-
-
class TransactionTests(IgnorePendingDeprecationWarningsMixin, TransactionTestCase):
def create_a_reporter_then_fail(self, first, last):
View
4 tests/transactions_regress/tests.py
@@ -4,11 +4,9 @@
IntegrityError)
from django.db.transaction import commit_on_success, commit_manually, TransactionManagementError
from django.test import TransactionTestCase, skipUnlessDBFeature
-from django.test.utils import override_settings
+from django.test.utils import override_settings, IgnorePendingDeprecationWarningsMixin
from django.utils.unittest import skipIf, skipUnless
-from transactions.tests import IgnorePendingDeprecationWarningsMixin
-
from .models import Mod, M2mA, M2mB, SubMod
class ModelInheritanceTests(TransactionTestCase):

0 comments on commit 3634948

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