Advanced deprecation warnings for 1.8.
This commit is contained in:
parent
74b3467646
commit
232181d1c5
|
@ -18,7 +18,7 @@ from django.template import Template, loader, TemplateDoesNotExist
|
||||||
from django.template.loaders import cached
|
from django.template.loaders import cached
|
||||||
from django.test.signals import template_rendered, setting_changed
|
from django.test.signals import template_rendered, setting_changed
|
||||||
from django.utils import six
|
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.encoding import force_str
|
||||||
from django.utils.translation import deactivate
|
from django.utils.translation import deactivate
|
||||||
|
|
||||||
|
@ -458,7 +458,7 @@ class CaptureQueriesContext(object):
|
||||||
|
|
||||||
|
|
||||||
class IgnoreDeprecationWarningsMixin(object):
|
class IgnoreDeprecationWarningsMixin(object):
|
||||||
warning_classes = [RemovedInDjango18Warning]
|
warning_classes = [RemovedInDjango19Warning]
|
||||||
|
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
super(IgnoreDeprecationWarningsMixin, self).setUp()
|
super(IgnoreDeprecationWarningsMixin, self).setUp()
|
||||||
|
@ -473,11 +473,11 @@ class IgnoreDeprecationWarningsMixin(object):
|
||||||
|
|
||||||
|
|
||||||
class IgnorePendingDeprecationWarningsMixin(IgnoreDeprecationWarningsMixin):
|
class IgnorePendingDeprecationWarningsMixin(IgnoreDeprecationWarningsMixin):
|
||||||
warning_classes = [RemovedInDjango19Warning]
|
warning_classes = [RemovedInDjango20Warning]
|
||||||
|
|
||||||
|
|
||||||
class IgnoreAllDeprecationWarningsMixin(IgnoreDeprecationWarningsMixin):
|
class IgnoreAllDeprecationWarningsMixin(IgnoreDeprecationWarningsMixin):
|
||||||
warning_classes = [RemovedInDjango19Warning, RemovedInDjango18Warning]
|
warning_classes = [RemovedInDjango20Warning, RemovedInDjango19Warning]
|
||||||
|
|
||||||
|
|
||||||
@contextmanager
|
@contextmanager
|
||||||
|
|
|
@ -2,15 +2,15 @@ import inspect
|
||||||
import warnings
|
import warnings
|
||||||
|
|
||||||
|
|
||||||
|
class RemovedInDjango20Warning(DeprecationWarning):
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
class RemovedInDjango19Warning(PendingDeprecationWarning):
|
class RemovedInDjango19Warning(PendingDeprecationWarning):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
class RemovedInDjango18Warning(DeprecationWarning):
|
RemovedInNextVersionWarning = RemovedInDjango19Warning
|
||||||
pass
|
|
||||||
|
|
||||||
|
|
||||||
RemovedInNextVersionWarning = RemovedInDjango18Warning
|
|
||||||
|
|
||||||
|
|
||||||
class warn_about_renamed_method(object):
|
class warn_about_renamed_method(object):
|
||||||
|
|
|
@ -26,7 +26,7 @@ from django.middleware.cache import (FetchFromCacheMiddleware,
|
||||||
from django.template import Template
|
from django.template import Template
|
||||||
from django.template.response import TemplateResponse
|
from django.template.response import TemplateResponse
|
||||||
from django.test import TestCase, TransactionTestCase, RequestFactory, override_settings
|
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 six
|
||||||
from django.utils import timezone
|
from django.utils import timezone
|
||||||
from django.utils import translation
|
from django.utils import translation
|
||||||
|
@ -1176,7 +1176,7 @@ class CustomCacheKeyValidationTests(TestCase):
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
class GetCacheTests(IgnorePendingDeprecationWarningsMixin, TestCase):
|
class GetCacheTests(IgnoreDeprecationWarningsMixin, TestCase):
|
||||||
|
|
||||||
def test_simple(self):
|
def test_simple(self):
|
||||||
from django.core.cache import caches, get_cache
|
from django.core.cache import caches, get_cache
|
||||||
|
|
|
@ -9,6 +9,7 @@ from django.contrib.contenttypes.forms import generic_inlineformset_factory
|
||||||
from django.forms.formsets import DEFAULT_MAX_NUM
|
from django.forms.formsets import DEFAULT_MAX_NUM
|
||||||
from django.forms.models import ModelForm
|
from django.forms.models import ModelForm
|
||||||
from django.test import TestCase, override_settings
|
from django.test import TestCase, override_settings
|
||||||
|
from django.utils.deprecation import RemovedInDjango19Warning
|
||||||
|
|
||||||
# local test models
|
# local test models
|
||||||
from .admin import MediaInline, MediaPermanentInline
|
from .admin import MediaInline, MediaPermanentInline
|
||||||
|
@ -376,7 +377,7 @@ class GenericInlineModelAdminTest(TestCase):
|
||||||
# Verify that the deprecation warning was triggered when get_formsets was called
|
# Verify that the deprecation warning was triggered when get_formsets was called
|
||||||
# This verifies that we called that method.
|
# This verifies that we called that method.
|
||||||
self.assertEqual(len(w), 1)
|
self.assertEqual(len(w), 1)
|
||||||
self.assertTrue(issubclass(w[0].category, PendingDeprecationWarning))
|
self.assertTrue(issubclass(w[0].category, RemovedInDjango19Warning))
|
||||||
|
|
||||||
class EpisodeAdmin(admin.ModelAdmin):
|
class EpisodeAdmin(admin.ModelAdmin):
|
||||||
inlines = [
|
inlines = [
|
||||||
|
|
|
@ -14,6 +14,7 @@ from django.db.models.sql.where import WhereNode, EverythingNode, NothingNode
|
||||||
from django.db.models.sql.datastructures import EmptyResultSet
|
from django.db.models.sql.datastructures import EmptyResultSet
|
||||||
from django.test import TestCase, skipUnlessDBFeature
|
from django.test import TestCase, skipUnlessDBFeature
|
||||||
from django.test.utils import str_prefix, CaptureQueriesContext
|
from django.test.utils import str_prefix, CaptureQueriesContext
|
||||||
|
from django.utils.deprecation import RemovedInDjango19Warning
|
||||||
from django.utils import six
|
from django.utils import six
|
||||||
|
|
||||||
from .models import (
|
from .models import (
|
||||||
|
@ -1149,7 +1150,7 @@ class Queries1Tests(BaseQuerysetTest):
|
||||||
['<Tag: t1>', '<Tag: t2>', '<Tag: t3>', '<Tag: t4>', '<Tag: t5>']
|
['<Tag: t1>', '<Tag: t2>', '<Tag: t3>', '<Tag: t4>', '<Tag: t5>']
|
||||||
)
|
)
|
||||||
self.assertEqual(len(w), 1)
|
self.assertEqual(len(w), 1)
|
||||||
self.assertTrue(issubclass(w[0].category, PendingDeprecationWarning))
|
self.assertTrue(issubclass(w[0].category, RemovedInDjango19Warning))
|
||||||
|
|
||||||
|
|
||||||
class Queries2Tests(TestCase):
|
class Queries2Tests(TestCase):
|
||||||
|
|
|
@ -11,13 +11,13 @@ import warnings
|
||||||
|
|
||||||
import django
|
import django
|
||||||
from django import contrib
|
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._os import upath
|
||||||
from django.utils import six
|
from django.utils import six
|
||||||
|
|
||||||
|
|
||||||
warnings.simplefilter("default", RemovedInDjango19Warning)
|
warnings.simplefilter("default", RemovedInDjango19Warning)
|
||||||
warnings.simplefilter("default", RemovedInDjango18Warning)
|
warnings.simplefilter("default", RemovedInDjango20Warning)
|
||||||
|
|
||||||
CONTRIB_MODULE_PATH = 'django.contrib'
|
CONTRIB_MODULE_PATH = 'django.contrib'
|
||||||
|
|
||||||
|
|
|
@ -6,13 +6,13 @@ import copy
|
||||||
import pickle
|
import pickle
|
||||||
|
|
||||||
from django.test import SimpleTestCase
|
from django.test import SimpleTestCase
|
||||||
from django.test.utils import IgnorePendingDeprecationWarningsMixin
|
from django.test.utils import IgnoreDeprecationWarningsMixin
|
||||||
from django.utils.datastructures import (DictWrapper, ImmutableList,
|
from django.utils.datastructures import (DictWrapper, ImmutableList,
|
||||||
MultiValueDict, MultiValueDictKeyError, MergeDict, SortedDict)
|
MultiValueDict, MultiValueDictKeyError, MergeDict, SortedDict)
|
||||||
from django.utils import six
|
from django.utils import six
|
||||||
|
|
||||||
|
|
||||||
class SortedDictTests(IgnorePendingDeprecationWarningsMixin, SimpleTestCase):
|
class SortedDictTests(IgnoreDeprecationWarningsMixin, SimpleTestCase):
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
super(SortedDictTests, self).setUp()
|
super(SortedDictTests, self).setUp()
|
||||||
self.d1 = SortedDict()
|
self.d1 = SortedDict()
|
||||||
|
@ -136,7 +136,7 @@ class SortedDictTests(IgnorePendingDeprecationWarningsMixin, SimpleTestCase):
|
||||||
self.assertEqual(list(reversed(self.d2)), [7, 0, 9, 1])
|
self.assertEqual(list(reversed(self.d2)), [7, 0, 9, 1])
|
||||||
|
|
||||||
|
|
||||||
class MergeDictTests(IgnorePendingDeprecationWarningsMixin, SimpleTestCase):
|
class MergeDictTests(IgnoreDeprecationWarningsMixin, SimpleTestCase):
|
||||||
|
|
||||||
def test_simple_mergedict(self):
|
def test_simple_mergedict(self):
|
||||||
d1 = {'chris': 'cool', 'camri': 'cute', 'cotton': 'adorable',
|
d1 = {'chris': 'cool', 'camri': 'cute', 'cotton': 'adorable',
|
||||||
|
|
|
@ -8,7 +8,7 @@ from zipimport import zipimporter
|
||||||
|
|
||||||
from django.core.exceptions import ImproperlyConfigured
|
from django.core.exceptions import ImproperlyConfigured
|
||||||
from django.test import SimpleTestCase, modify_settings
|
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 import six
|
||||||
from django.utils.deprecation import RemovedInDjango19Warning
|
from django.utils.deprecation import RemovedInDjango19Warning
|
||||||
from django.utils.module_loading import (autodiscover_modules, import_by_path, import_string,
|
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')
|
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):
|
def test_import_by_path(self):
|
||||||
cls = import_by_path('django.utils.module_loading.import_by_path')
|
cls = import_by_path('django.utils.module_loading.import_by_path')
|
||||||
self.assertEqual(cls, import_by_path)
|
self.assertEqual(cls, import_by_path)
|
||||||
|
|
|
@ -6,7 +6,7 @@ import time
|
||||||
import unittest
|
import unittest
|
||||||
import warnings
|
import warnings
|
||||||
|
|
||||||
from django.test.utils import IgnorePendingDeprecationWarningsMixin
|
from django.test.utils import IgnoreDeprecationWarningsMixin
|
||||||
from django.utils.deprecation import RemovedInDjango19Warning
|
from django.utils.deprecation import RemovedInDjango19Warning
|
||||||
|
|
||||||
|
|
||||||
|
@ -16,7 +16,7 @@ with warnings.catch_warnings():
|
||||||
from django.utils.tzinfo import FixedOffset, LocalTimezone
|
from django.utils.tzinfo import FixedOffset, LocalTimezone
|
||||||
|
|
||||||
|
|
||||||
class TzinfoTests(IgnorePendingDeprecationWarningsMixin, unittest.TestCase):
|
class TzinfoTests(IgnoreDeprecationWarningsMixin, unittest.TestCase):
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def setUpClass(cls):
|
def setUpClass(cls):
|
||||||
|
|
Loading…
Reference in New Issue