Advanced deprecation warnings for 1.8.

This commit is contained in:
Aymeric Augustin 2014-03-22 21:08:59 +01:00
parent 74b3467646
commit 232181d1c5
9 changed files with 24 additions and 22 deletions

View File

@ -18,7 +18,7 @@ from django.template import Template, loader, TemplateDoesNotExist
from django.template.loaders import cached
from django.test.signals import template_rendered, setting_changed
from django.utils import six
from django.utils.deprecation import RemovedInDjango18Warning, RemovedInDjango19Warning
from django.utils.deprecation import RemovedInDjango19Warning, RemovedInDjango20Warning
from django.utils.encoding import force_str
from django.utils.translation import deactivate
@ -458,7 +458,7 @@ class CaptureQueriesContext(object):
class IgnoreDeprecationWarningsMixin(object):
warning_classes = [RemovedInDjango18Warning]
warning_classes = [RemovedInDjango19Warning]
def setUp(self):
super(IgnoreDeprecationWarningsMixin, self).setUp()
@ -473,11 +473,11 @@ class IgnoreDeprecationWarningsMixin(object):
class IgnorePendingDeprecationWarningsMixin(IgnoreDeprecationWarningsMixin):
warning_classes = [RemovedInDjango19Warning]
warning_classes = [RemovedInDjango20Warning]
class IgnoreAllDeprecationWarningsMixin(IgnoreDeprecationWarningsMixin):
warning_classes = [RemovedInDjango19Warning, RemovedInDjango18Warning]
warning_classes = [RemovedInDjango20Warning, RemovedInDjango19Warning]
@contextmanager

View File

@ -2,15 +2,15 @@ import inspect
import warnings
class RemovedInDjango20Warning(DeprecationWarning):
pass
class RemovedInDjango19Warning(PendingDeprecationWarning):
pass
class RemovedInDjango18Warning(DeprecationWarning):
pass
RemovedInNextVersionWarning = RemovedInDjango18Warning
RemovedInNextVersionWarning = RemovedInDjango19Warning
class warn_about_renamed_method(object):

View File

@ -26,7 +26,7 @@ from django.middleware.cache import (FetchFromCacheMiddleware,
from django.template import Template
from django.template.response import TemplateResponse
from django.test import TestCase, TransactionTestCase, RequestFactory, override_settings
from django.test.utils import IgnorePendingDeprecationWarningsMixin
from django.test.utils import IgnoreDeprecationWarningsMixin
from django.utils import six
from django.utils import timezone
from django.utils import translation
@ -1176,7 +1176,7 @@ class CustomCacheKeyValidationTests(TestCase):
}
}
)
class GetCacheTests(IgnorePendingDeprecationWarningsMixin, TestCase):
class GetCacheTests(IgnoreDeprecationWarningsMixin, TestCase):
def test_simple(self):
from django.core.cache import caches, get_cache

View File

@ -9,6 +9,7 @@ from django.contrib.contenttypes.forms import generic_inlineformset_factory
from django.forms.formsets import DEFAULT_MAX_NUM
from django.forms.models import ModelForm
from django.test import TestCase, override_settings
from django.utils.deprecation import RemovedInDjango19Warning
# local test models
from .admin import MediaInline, MediaPermanentInline
@ -376,7 +377,7 @@ class GenericInlineModelAdminTest(TestCase):
# Verify that the deprecation warning was triggered when get_formsets was called
# This verifies that we called that method.
self.assertEqual(len(w), 1)
self.assertTrue(issubclass(w[0].category, PendingDeprecationWarning))
self.assertTrue(issubclass(w[0].category, RemovedInDjango19Warning))
class EpisodeAdmin(admin.ModelAdmin):
inlines = [

View File

@ -14,6 +14,7 @@ from django.db.models.sql.where import WhereNode, EverythingNode, NothingNode
from django.db.models.sql.datastructures import EmptyResultSet
from django.test import TestCase, skipUnlessDBFeature
from django.test.utils import str_prefix, CaptureQueriesContext
from django.utils.deprecation import RemovedInDjango19Warning
from django.utils import six
from .models import (
@ -1149,7 +1150,7 @@ class Queries1Tests(BaseQuerysetTest):
['<Tag: t1>', '<Tag: t2>', '<Tag: t3>', '<Tag: t4>', '<Tag: t5>']
)
self.assertEqual(len(w), 1)
self.assertTrue(issubclass(w[0].category, PendingDeprecationWarning))
self.assertTrue(issubclass(w[0].category, RemovedInDjango19Warning))
class Queries2Tests(TestCase):

View File

@ -11,13 +11,13 @@ import warnings
import django
from django import contrib
from django.utils.deprecation import RemovedInDjango18Warning, RemovedInDjango19Warning
from django.utils.deprecation import RemovedInDjango19Warning, RemovedInDjango20Warning
from django.utils._os import upath
from django.utils import six
warnings.simplefilter("default", RemovedInDjango19Warning)
warnings.simplefilter("default", RemovedInDjango18Warning)
warnings.simplefilter("default", RemovedInDjango20Warning)
CONTRIB_MODULE_PATH = 'django.contrib'

View File

@ -6,13 +6,13 @@ import copy
import pickle
from django.test import SimpleTestCase
from django.test.utils import IgnorePendingDeprecationWarningsMixin
from django.test.utils import IgnoreDeprecationWarningsMixin
from django.utils.datastructures import (DictWrapper, ImmutableList,
MultiValueDict, MultiValueDictKeyError, MergeDict, SortedDict)
from django.utils import six
class SortedDictTests(IgnorePendingDeprecationWarningsMixin, SimpleTestCase):
class SortedDictTests(IgnoreDeprecationWarningsMixin, SimpleTestCase):
def setUp(self):
super(SortedDictTests, self).setUp()
self.d1 = SortedDict()
@ -136,7 +136,7 @@ class SortedDictTests(IgnorePendingDeprecationWarningsMixin, SimpleTestCase):
self.assertEqual(list(reversed(self.d2)), [7, 0, 9, 1])
class MergeDictTests(IgnorePendingDeprecationWarningsMixin, SimpleTestCase):
class MergeDictTests(IgnoreDeprecationWarningsMixin, SimpleTestCase):
def test_simple_mergedict(self):
d1 = {'chris': 'cool', 'camri': 'cute', 'cotton': 'adorable',

View File

@ -8,7 +8,7 @@ from zipimport import zipimporter
from django.core.exceptions import ImproperlyConfigured
from django.test import SimpleTestCase, modify_settings
from django.test.utils import IgnorePendingDeprecationWarningsMixin, extend_sys_path
from django.test.utils import IgnoreDeprecationWarningsMixin, extend_sys_path
from django.utils import six
from django.utils.deprecation import RemovedInDjango19Warning
from django.utils.module_loading import (autodiscover_modules, import_by_path, import_string,
@ -110,7 +110,7 @@ class EggLoader(unittest.TestCase):
self.assertRaises(ImportError, import_module, 'egg_module.sub1.sub2.no_such_module')
class ModuleImportTestCase(IgnorePendingDeprecationWarningsMixin, unittest.TestCase):
class ModuleImportTestCase(IgnoreDeprecationWarningsMixin, unittest.TestCase):
def test_import_by_path(self):
cls = import_by_path('django.utils.module_loading.import_by_path')
self.assertEqual(cls, import_by_path)

View File

@ -6,7 +6,7 @@ import time
import unittest
import warnings
from django.test.utils import IgnorePendingDeprecationWarningsMixin
from django.test.utils import IgnoreDeprecationWarningsMixin
from django.utils.deprecation import RemovedInDjango19Warning
@ -16,7 +16,7 @@ with warnings.catch_warnings():
from django.utils.tzinfo import FixedOffset, LocalTimezone
class TzinfoTests(IgnorePendingDeprecationWarningsMixin, unittest.TestCase):
class TzinfoTests(IgnoreDeprecationWarningsMixin, unittest.TestCase):
@classmethod
def setUpClass(cls):