Advanced deprecation warnings for Django 1.7.

This commit is contained in:
Aymeric Augustin 2013-06-29 18:34:41 +02:00
parent 8b9b8d3bda
commit acd7b34aaf
41 changed files with 80 additions and 81 deletions

View File

@ -3,7 +3,7 @@ import warnings
from django.conf.urls import patterns from django.conf.urls import patterns
warnings.warn("django.conf.urls.shortcut will be removed in Django 1.8.", warnings.warn("django.conf.urls.shortcut will be removed in Django 1.8.",
PendingDeprecationWarning) DeprecationWarning)
urlpatterns = patterns('django.views', urlpatterns = patterns('django.views',
(r'^(?P<content_type_id>\d+)/(?P<object_id>.*)/$', 'defaults.shortcut'), (r'^(?P<content_type_id>\d+)/(?P<object_id>.*)/$', 'defaults.shortcut'),

View File

@ -76,7 +76,7 @@ csrf_protect_m = method_decorator(csrf_protect)
class RenameBaseModelAdminMethods(forms.MediaDefiningClass, RenameMethodsBase): class RenameBaseModelAdminMethods(forms.MediaDefiningClass, RenameMethodsBase):
renamed_methods = ( renamed_methods = (
('queryset', 'get_queryset', PendingDeprecationWarning), ('queryset', 'get_queryset', DeprecationWarning),
) )

View File

@ -52,7 +52,7 @@ def _is_changelist_popup(request):
warnings.warn( warnings.warn(
"The `%s` GET parameter has been renamed to `%s`." % "The `%s` GET parameter has been renamed to `%s`." %
(IS_LEGACY_POPUP_VAR, IS_POPUP_VAR), (IS_LEGACY_POPUP_VAR, IS_POPUP_VAR),
PendingDeprecationWarning, 2) DeprecationWarning, 2)
return True return True
return False return False
@ -60,7 +60,7 @@ def _is_changelist_popup(request):
class RenameChangeListMethods(RenameMethodsBase): class RenameChangeListMethods(RenameMethodsBase):
renamed_methods = ( renamed_methods = (
('get_query_set', 'get_queryset', PendingDeprecationWarning), ('get_query_set', 'get_queryset', DeprecationWarning),
) )
@ -115,14 +115,14 @@ class ChangeList(six.with_metaclass(RenameChangeListMethods)):
def root_query_set(self): def root_query_set(self):
warnings.warn("`ChangeList.root_query_set` is deprecated, " warnings.warn("`ChangeList.root_query_set` is deprecated, "
"use `root_queryset` instead.", "use `root_queryset` instead.",
PendingDeprecationWarning, 2) DeprecationWarning, 2)
return self.root_queryset return self.root_queryset
@property @property
def query_set(self): def query_set(self):
warnings.warn("`ChangeList.query_set` is deprecated, " warnings.warn("`ChangeList.query_set` is deprecated, "
"use `queryset` instead.", "use `queryset` instead.",
PendingDeprecationWarning, 2) DeprecationWarning, 2)
return self.queryset return self.queryset
def get_filters_params(self, params=None): def get_filters_params(self, params=None):

View File

@ -6,7 +6,7 @@ from django.contrib.comments.models import Comment
from django.contrib.comments.forms import CommentForm from django.contrib.comments.forms import CommentForm
from django.utils.importlib import import_module from django.utils.importlib import import_module
warnings.warn("django.contrib.comments is deprecated and will be removed before Django 1.8.", PendingDeprecationWarning) warnings.warn("django.contrib.comments is deprecated and will be removed before Django 1.8.", DeprecationWarning)
DEFAULT_COMMENTS_APP = 'django.contrib.comments' DEFAULT_COMMENTS_APP = 'django.contrib.comments'

View File

@ -12,7 +12,7 @@ register = template.Library()
class RenameBaseCommentNodeMethods(RenameMethodsBase): class RenameBaseCommentNodeMethods(RenameMethodsBase):
renamed_methods = ( renamed_methods = (
('get_query_set', 'get_queryset', PendingDeprecationWarning), ('get_query_set', 'get_queryset', DeprecationWarning),
) )

View File

@ -25,7 +25,7 @@ from django.utils.encoding import smart_text
class RenameGenericForeignKeyMethods(RenameMethodsBase): class RenameGenericForeignKeyMethods(RenameMethodsBase):
renamed_methods = ( renamed_methods = (
('get_prefetch_query_set', 'get_prefetch_queryset', PendingDeprecationWarning), ('get_prefetch_query_set', 'get_prefetch_queryset', DeprecationWarning),
) )

View File

@ -49,7 +49,7 @@ class DefaultBackendProxy(object):
@cached_property @cached_property
def _backend(self): def _backend(self):
warnings.warn("Accessing django.db.backend is deprecated.", warnings.warn("Accessing django.db.backend is deprecated.",
PendingDeprecationWarning, stacklevel=2) DeprecationWarning, stacklevel=2)
return load_backend(connections[DEFAULT_DB_ALIAS].settings_dict['ENGINE']) return load_backend(connections[DEFAULT_DB_ALIAS].settings_dict['ENGINE'])
def __getattr__(self, item): def __getattr__(self, item):
@ -66,7 +66,7 @@ backend = DefaultBackendProxy()
def close_connection(**kwargs): def close_connection(**kwargs):
warnings.warn( warnings.warn(
"close_connection is superseded by close_old_connections.", "close_connection is superseded by close_old_connections.",
PendingDeprecationWarning, stacklevel=2) DeprecationWarning, stacklevel=2)
# Avoid circular imports # Avoid circular imports
from django.db import transaction from django.db import transaction
for conn in connections: for conn in connections:

View File

@ -465,7 +465,7 @@ class BaseDatabaseCreation(object):
""" """
warnings.warn( warnings.warn(
"set_autocommit was moved from BaseDatabaseCreation to " "set_autocommit was moved from BaseDatabaseCreation to "
"BaseDatabaseWrapper.", PendingDeprecationWarning, stacklevel=2) "BaseDatabaseWrapper.", DeprecationWarning, stacklevel=2)
return self.connection.set_autocommit(True) return self.connection.set_autocommit(True)
def sql_table_creation_suffix(self): def sql_table_creation_suffix(self):

View File

@ -144,8 +144,8 @@ class RelatedField(Field):
class RenameRelatedObjectDescriptorMethods(RenameMethodsBase): class RenameRelatedObjectDescriptorMethods(RenameMethodsBase):
renamed_methods = ( renamed_methods = (
('get_query_set', 'get_queryset', PendingDeprecationWarning), ('get_query_set', 'get_queryset', DeprecationWarning),
('get_prefetch_query_set', 'get_prefetch_queryset', PendingDeprecationWarning), ('get_prefetch_query_set', 'get_prefetch_queryset', DeprecationWarning),
) )

View File

@ -50,8 +50,8 @@ signals.class_prepared.connect(ensure_default_manager)
class RenameManagerMethods(RenameMethodsBase): class RenameManagerMethods(RenameMethodsBase):
renamed_methods = ( renamed_methods = (
('get_query_set', 'get_queryset', PendingDeprecationWarning), ('get_query_set', 'get_queryset', DeprecationWarning),
('get_prefetch_query_set', 'get_prefetch_queryset', PendingDeprecationWarning), ('get_prefetch_query_set', 'get_prefetch_queryset', DeprecationWarning),
) )

View File

@ -130,7 +130,7 @@ class Options(object):
""" """
warnings.warn( warnings.warn(
"Options.module_name has been deprecated in favor of model_name", "Options.module_name has been deprecated in favor of model_name",
PendingDeprecationWarning, stacklevel=2) DeprecationWarning, stacklevel=2)
return self.model_name return self.model_name
def _prepare(self, model): def _prepare(self, model):
@ -421,7 +421,7 @@ class Options(object):
warnings.warn( warnings.warn(
"`Options.get_add_permission` has been deprecated in favor " "`Options.get_add_permission` has been deprecated in favor "
"of `django.contrib.auth.get_permission_codename`.", "of `django.contrib.auth.get_permission_codename`.",
PendingDeprecationWarning, stacklevel=2) DeprecationWarning, stacklevel=2)
return 'add_%s' % self.model_name return 'add_%s' % self.model_name
def get_change_permission(self): def get_change_permission(self):
@ -432,7 +432,7 @@ class Options(object):
warnings.warn( warnings.warn(
"`Options.get_change_permission` has been deprecated in favor " "`Options.get_change_permission` has been deprecated in favor "
"of `django.contrib.auth.get_permission_codename`.", "of `django.contrib.auth.get_permission_codename`.",
PendingDeprecationWarning, stacklevel=2) DeprecationWarning, stacklevel=2)
return 'change_%s' % self.model_name return 'change_%s' % self.model_name
def get_delete_permission(self): def get_delete_permission(self):
@ -443,7 +443,7 @@ class Options(object):
warnings.warn( warnings.warn(
"`Options.get_delete_permission` has been deprecated in favor " "`Options.get_delete_permission` has been deprecated in favor "
"of `django.contrib.auth.get_permission_codename`.", "of `django.contrib.auth.get_permission_codename`.",
PendingDeprecationWarning, stacklevel=2) DeprecationWarning, stacklevel=2)
return 'delete_%s' % self.model_name return 'delete_%s' % self.model_name
def get_all_related_objects(self, local_only=False, include_hidden=False, def get_all_related_objects(self, local_only=False, include_hidden=False,

View File

@ -101,19 +101,19 @@ def set_clean(using=None):
def is_managed(using=None): def is_managed(using=None):
warnings.warn("'is_managed' is deprecated.", warnings.warn("'is_managed' is deprecated.",
PendingDeprecationWarning, stacklevel=2) DeprecationWarning, stacklevel=2)
def managed(flag=True, using=None): def managed(flag=True, using=None):
warnings.warn("'managed' no longer serves a purpose.", warnings.warn("'managed' no longer serves a purpose.",
PendingDeprecationWarning, stacklevel=2) DeprecationWarning, stacklevel=2)
def commit_unless_managed(using=None): def commit_unless_managed(using=None):
warnings.warn("'commit_unless_managed' is now a no-op.", warnings.warn("'commit_unless_managed' is now a no-op.",
PendingDeprecationWarning, stacklevel=2) DeprecationWarning, stacklevel=2)
def rollback_unless_managed(using=None): def rollback_unless_managed(using=None):
warnings.warn("'rollback_unless_managed' is now a no-op.", warnings.warn("'rollback_unless_managed' is now a no-op.",
PendingDeprecationWarning, stacklevel=2) DeprecationWarning, stacklevel=2)
############### ###############
# Public APIs # # Public APIs #
@ -430,7 +430,7 @@ def autocommit(using=None):
your settings file and want the default behavior in some view functions. your settings file and want the default behavior in some view functions.
""" """
warnings.warn("autocommit is deprecated in favor of set_autocommit.", warnings.warn("autocommit is deprecated in favor of set_autocommit.",
PendingDeprecationWarning, stacklevel=2) DeprecationWarning, stacklevel=2)
def entering(using): def entering(using):
enter_transaction_management(managed=False, using=using) enter_transaction_management(managed=False, using=using)
@ -448,7 +448,7 @@ def commit_on_success(using=None):
control in Web apps. control in Web apps.
""" """
warnings.warn("commit_on_success is deprecated in favor of atomic.", warnings.warn("commit_on_success is deprecated in favor of atomic.",
PendingDeprecationWarning, stacklevel=2) DeprecationWarning, stacklevel=2)
def entering(using): def entering(using):
enter_transaction_management(using=using) enter_transaction_management(using=using)
@ -478,7 +478,7 @@ def commit_manually(using=None):
themselves. themselves.
""" """
warnings.warn("commit_manually is deprecated in favor of set_autocommit.", warnings.warn("commit_manually is deprecated in favor of set_autocommit.",
PendingDeprecationWarning, stacklevel=2) DeprecationWarning, stacklevel=2)
def entering(using): def entering(using):
enter_transaction_management(using=using) enter_transaction_management(using=using)

View File

@ -174,7 +174,7 @@ class ConnectionHandler(object):
if settings.TRANSACTIONS_MANAGED: if settings.TRANSACTIONS_MANAGED:
warnings.warn( warnings.warn(
"TRANSACTIONS_MANAGED is deprecated. Use AUTOCOMMIT instead.", "TRANSACTIONS_MANAGED is deprecated. Use AUTOCOMMIT instead.",
PendingDeprecationWarning, stacklevel=2) DeprecationWarning, stacklevel=2)
conn.setdefault('AUTOCOMMIT', False) conn.setdefault('AUTOCOMMIT', False)
conn.setdefault('AUTOCOMMIT', True) conn.setdefault('AUTOCOMMIT', True)
conn.setdefault('ENGINE', 'django.db.backends.dummy') conn.setdefault('ENGINE', 'django.db.backends.dummy')

View File

@ -352,7 +352,7 @@ class BaseForm(object):
if hasattr(field.widget, '_has_changed'): if hasattr(field.widget, '_has_changed'):
warnings.warn("The _has_changed method on widgets is deprecated," warnings.warn("The _has_changed method on widgets is deprecated,"
" define it at field level instead.", " define it at field level instead.",
PendingDeprecationWarning, stacklevel=2) DeprecationWarning, stacklevel=2)
if field.widget._has_changed(initial_value, data_value): if field.widget._has_changed(initial_value, data_value):
self._changed_data.append(name) self._changed_data.append(name)
elif field._has_changed(initial_value, data_value): elif field._has_changed(initial_value, data_value):

View File

@ -260,7 +260,7 @@ class ModelFormMetaclass(type):
warnings.warn("Creating a ModelForm without either the 'fields' attribute " warnings.warn("Creating a ModelForm without either the 'fields' attribute "
"or the 'exclude' attribute is deprecated - form %s " "or the 'exclude' attribute is deprecated - form %s "
"needs updating" % name, "needs updating" % name,
PendingDeprecationWarning, stacklevel=2) DeprecationWarning, stacklevel=2)
if opts.fields == ALL_FIELDS: if opts.fields == ALL_FIELDS:
# sentinel for fields_for_model to indicate "get the list of # sentinel for fields_for_model to indicate "get the list of
@ -513,7 +513,7 @@ def modelform_factory(model, form=ModelForm, fields=None, exclude=None,
getattr(Meta, 'exclude', None) is None): getattr(Meta, 'exclude', None) is None):
warnings.warn("Calling modelform_factory without defining 'fields' or " warnings.warn("Calling modelform_factory without defining 'fields' or "
"'exclude' explicitly is deprecated", "'exclude' explicitly is deprecated",
PendingDeprecationWarning, stacklevel=2) DeprecationWarning, stacklevel=2)
# Instatiate type(form) in order to use the same metaclass as form. # Instatiate type(form) in order to use the same metaclass as form.
return type(form)(class_name, (form,), form_class_attrs) return type(form)(class_name, (form,), form_class_attrs)
@ -796,7 +796,7 @@ def modelformset_factory(model, form=ModelForm, formfield_callback=None,
getattr(meta, 'exclude', exclude) is None): getattr(meta, 'exclude', exclude) is None):
warnings.warn("Calling modelformset_factory without defining 'fields' or " warnings.warn("Calling modelformset_factory without defining 'fields' or "
"'exclude' explicitly is deprecated", "'exclude' explicitly is deprecated",
PendingDeprecationWarning, stacklevel=2) DeprecationWarning, stacklevel=2)
form = modelform_factory(model, form=form, fields=fields, exclude=exclude, form = modelform_factory(model, form=form, fields=fields, exclude=exclude,
formfield_callback=formfield_callback, formfield_callback=formfield_callback,

View File

@ -636,7 +636,7 @@ class RadioChoiceInput(ChoiceInput):
class RadioInput(RadioChoiceInput): class RadioInput(RadioChoiceInput):
def __init__(self, *args, **kwargs): def __init__(self, *args, **kwargs):
msg = "RadioInput has been deprecated. Use RadioChoiceInput instead." msg = "RadioInput has been deprecated. Use RadioChoiceInput instead."
warnings.warn(msg, PendingDeprecationWarning, stacklevel=2) warnings.warn(msg, DeprecationWarning, stacklevel=2)
super(RadioInput, self).__init__(*args, **kwargs) super(RadioInput, self).__init__(*args, **kwargs)

View File

@ -199,7 +199,7 @@ class CacheMiddleware(UpdateCacheMiddleware, FetchFromCacheMiddleware):
if self.cache_anonymous_only: if self.cache_anonymous_only:
msg = "CACHE_MIDDLEWARE_ANONYMOUS_ONLY has been deprecated and will be removed in Django 1.8." msg = "CACHE_MIDDLEWARE_ANONYMOUS_ONLY has been deprecated and will be removed in Django 1.8."
warnings.warn(msg, PendingDeprecationWarning, stacklevel=1) warnings.warn(msg, DeprecationWarning, stacklevel=1)
self.cache = get_cache(self.cache_alias, **cache_kwargs) self.cache = get_cache(self.cache_alias, **cache_kwargs)
self.cache_timeout = self.cache.default_timeout self.cache_timeout = self.cache.default_timeout

View File

@ -110,7 +110,7 @@ class CommonMiddleware(object):
if settings.SEND_BROKEN_LINK_EMAILS: if settings.SEND_BROKEN_LINK_EMAILS:
warnings.warn("SEND_BROKEN_LINK_EMAILS is deprecated. " warnings.warn("SEND_BROKEN_LINK_EMAILS is deprecated. "
"Use BrokenLinkEmailsMiddleware instead.", "Use BrokenLinkEmailsMiddleware instead.",
PendingDeprecationWarning, stacklevel=2) DeprecationWarning, stacklevel=2)
BrokenLinkEmailsMiddleware().process_response(request, response) BrokenLinkEmailsMiddleware().process_response(request, response)
if settings.USE_ETAGS: if settings.USE_ETAGS:

View File

@ -1,6 +1,6 @@
"""XViewMiddleware has been moved to django.contrib.admindocs.middleware.""" """XViewMiddleware has been moved to django.contrib.admindocs.middleware."""
import warnings import warnings
warnings.warn(__doc__, PendingDeprecationWarning, stacklevel=2) warnings.warn(__doc__, DeprecationWarning, stacklevel=2)
from django.contrib.admindocs.middleware import XViewMiddleware from django.contrib.admindocs.middleware import XViewMiddleware

View File

@ -14,7 +14,7 @@ class TransactionMiddleware(object):
def __init__(self): def __init__(self):
warnings.warn( warnings.warn(
"TransactionMiddleware is deprecated in favor of ATOMIC_REQUESTS.", "TransactionMiddleware is deprecated in favor of ATOMIC_REQUESTS.",
PendingDeprecationWarning, stacklevel=2) DeprecationWarning, stacklevel=2)
if connection.settings_dict['ATOMIC_REQUESTS']: if connection.settings_dict['ATOMIC_REQUESTS']:
raise MiddlewareNotUsed raise MiddlewareNotUsed

View File

@ -568,7 +568,7 @@ def cycle(parser, token, escape=False):
"'The `cycle` template tag is changing to escape its arguments; " "'The `cycle` template tag is changing to escape its arguments; "
"the non-autoescaping version is deprecated. Load it " "the non-autoescaping version is deprecated. Load it "
"from the `future` tag library to start using the new behavior.", "from the `future` tag library to start using the new behavior.",
PendingDeprecationWarning, stacklevel=2) DeprecationWarning, stacklevel=2)
# Note: This returns the exact same node on each {% cycle name %} call; # Note: This returns the exact same node on each {% cycle name %} call;
# that is, the node object returned from {% cycle a b c as name %} and the # that is, the node object returned from {% cycle a b c as name %} and the
@ -712,7 +712,7 @@ def firstof(parser, token, escape=False):
"'The `firstof` template tag is changing to escape its arguments; " "'The `firstof` template tag is changing to escape its arguments; "
"the non-autoescaping version is deprecated. Load it " "the non-autoescaping version is deprecated. Load it "
"from the `future` tag library to start using the new behavior.", "from the `future` tag library to start using the new behavior.",
PendingDeprecationWarning, stacklevel=2) DeprecationWarning, stacklevel=2)
bits = token.split_contents()[1:] bits = token.split_contents()[1:]
if len(bits) < 1: if len(bits) < 1:

View File

@ -54,7 +54,7 @@ import warnings
warnings.warn( warnings.warn(
"The django.test._doctest module is deprecated; " "The django.test._doctest module is deprecated; "
"use the doctest module from the Python standard library instead.", "use the doctest module from the Python standard library instead.",
PendingDeprecationWarning) DeprecationWarning)
__docformat__ = 'reStructuredText en' __docformat__ = 'reStructuredText en'

View File

@ -21,7 +21,7 @@ __all__ = ('DjangoTestSuiteRunner',)
warnings.warn( warnings.warn(
"The django.test.simple module and DjangoTestSuiteRunner are deprecated; " "The django.test.simple module and DjangoTestSuiteRunner are deprecated; "
"use django.test.runner.DiscoverRunner instead.", "use django.test.runner.DiscoverRunner instead.",
PendingDeprecationWarning) DeprecationWarning)
# The module name for tests outside models.py # The module name for tests outside models.py
TEST_MODULE = 'tests' TEST_MODULE = 'tests'

View File

@ -139,7 +139,7 @@ def _detect_image_library():
warnings.warn( warnings.warn(
"Support for the PIL will be removed in Django 1.8. Please " + "Support for the PIL will be removed in Django 1.8. Please " +
"uninstall it & install Pillow instead.", "uninstall it & install Pillow instead.",
PendingDeprecationWarning DeprecationWarning
) )
return PILImage, PIL_imaging, PILImageFile return PILImage, PIL_imaging, PILImageFile

View File

@ -83,6 +83,6 @@ def shortcut(request, content_type_id, object_id):
warnings.warn( warnings.warn(
"django.views.defaults.shortcut will be removed in Django 1.8. " "django.views.defaults.shortcut will be removed in Django 1.8. "
"Import it from django.contrib.contenttypes.views instead.", "Import it from django.contrib.contenttypes.views instead.",
PendingDeprecationWarning, stacklevel=2) DeprecationWarning, stacklevel=2)
from django.contrib.contenttypes.views import shortcut as real_shortcut from django.contrib.contenttypes.views import shortcut as real_shortcut
return real_shortcut(request, content_type_id, object_id) return real_shortcut(request, content_type_id, object_id)

View File

@ -113,7 +113,7 @@ class ModelFormMixin(FormMixin, SingleObjectMixin):
if self.fields is None: if self.fields is None:
warnings.warn("Using ModelFormMixin (base class of %s) without " warnings.warn("Using ModelFormMixin (base class of %s) without "
"the 'fields' attribute is deprecated." % self.__class__.__name__, "the 'fields' attribute is deprecated." % self.__class__.__name__,
PendingDeprecationWarning) DeprecationWarning)
return model_forms.modelform_factory(model, fields=self.fields) return model_forms.modelform_factory(model, fields=self.fields)

View File

@ -1,8 +1,8 @@
from django.db import models from django.db import models
from django.contrib.comments.models import Comment from django.contrib.auth.models import User
# Regression for #13368. This is an example of a model # Regression for #13368. This is an example of a model
# that imports a class that has an abstract base class. # that imports a class that has an abstract base class.
class CommentScore(models.Model): class UserProfile(models.Model):
comment = models.OneToOneField(Comment, primary_key=True) user = models.OneToOneField(User, primary_key=True)

View File

@ -1079,7 +1079,6 @@ class ManageValidate(AdminScriptTestCase):
"manage.py validate does not raise errors when an app imports a base class that itself has an abstract base" "manage.py validate does not raise errors when an app imports a base class that itself has an abstract base"
self.write_settings('settings.py', self.write_settings('settings.py',
apps=['admin_scripts.app_with_import', apps=['admin_scripts.app_with_import',
'django.contrib.comments',
'django.contrib.auth', 'django.contrib.auth',
'django.contrib.contenttypes', 'django.contrib.contenttypes',
'django.contrib.sites'], 'django.contrib.sites'],

View File

@ -28,7 +28,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 from django.test import TestCase, TransactionTestCase, RequestFactory
from django.test.utils import override_settings, IgnorePendingDeprecationWarningsMixin from django.test.utils import override_settings, IgnoreDeprecationWarningsMixin
from django.utils import six, timezone, translation, unittest from django.utils import six, timezone, translation, unittest
from django.utils.cache import (patch_vary_headers, get_cache_key, from django.utils.cache import (patch_vary_headers, get_cache_key,
learn_cache_key, patch_cache_control, patch_response_headers) learn_cache_key, patch_cache_control, patch_response_headers)
@ -1594,7 +1594,7 @@ def hello_world_view(request, value):
}, },
}, },
) )
class CacheMiddlewareTest(IgnorePendingDeprecationWarningsMixin, TestCase): class CacheMiddlewareTest(IgnoreDeprecationWarningsMixin, TestCase):
def setUp(self): def setUp(self):
super(CacheMiddlewareTest, self).setUp() super(CacheMiddlewareTest, self).setUp()

View File

@ -8,7 +8,7 @@ from django.utils.deprecation import RenameMethodsBase
class RenameManagerMethods(RenameMethodsBase): class RenameManagerMethods(RenameMethodsBase):
renamed_methods = ( renamed_methods = (
('old', 'new', PendingDeprecationWarning), ('old', 'new', DeprecationWarning),
) )

View File

@ -146,7 +146,7 @@ class CreateViewTests(TestCase):
def test_create_view_all_fields(self): def test_create_view_all_fields(self):
with warnings.catch_warnings(record=True) as w: with warnings.catch_warnings(record=True) as w:
warnings.simplefilter("always", PendingDeprecationWarning) warnings.simplefilter("always", DeprecationWarning)
class MyCreateView(CreateView): class MyCreateView(CreateView):
model = Author model = Author
@ -160,7 +160,7 @@ class CreateViewTests(TestCase):
def test_create_view_without_explicit_fields(self): def test_create_view_without_explicit_fields(self):
with warnings.catch_warnings(record=True) as w: with warnings.catch_warnings(record=True) as w:
warnings.simplefilter("always", PendingDeprecationWarning) warnings.simplefilter("always", DeprecationWarning)
class MyCreateView(CreateView): class MyCreateView(CreateView):
model = Author model = Author
@ -171,7 +171,7 @@ class CreateViewTests(TestCase):
['name', 'slug']) ['name', 'slug'])
# but with a warning: # but with a warning:
self.assertEqual(w[0].category, PendingDeprecationWarning) self.assertEqual(w[0].category, DeprecationWarning)
class UpdateViewTests(TestCase): class UpdateViewTests(TestCase):

View File

@ -18,7 +18,7 @@ from django.middleware.http import ConditionalGetMiddleware
from django.middleware.gzip import GZipMiddleware from django.middleware.gzip import GZipMiddleware
from django.middleware.transaction import TransactionMiddleware from django.middleware.transaction import TransactionMiddleware
from django.test import TransactionTestCase, TestCase, RequestFactory from django.test import TransactionTestCase, TestCase, RequestFactory
from django.test.utils import override_settings, IgnorePendingDeprecationWarningsMixin from django.test.utils import override_settings, IgnoreDeprecationWarningsMixin
from django.utils import six from django.utils import six
from django.utils.encoding import force_str from django.utils.encoding import force_str
from django.utils.six.moves import xrange from django.utils.six.moves import xrange
@ -249,7 +249,7 @@ class CommonMiddlewareTest(TestCase):
request = self._get_request('regular_url/that/does/not/exist') request = self._get_request('regular_url/that/does/not/exist')
request.META['HTTP_REFERER'] = '/another/url/' request.META['HTTP_REFERER'] = '/another/url/'
with warnings.catch_warnings(): with warnings.catch_warnings():
warnings.simplefilter("ignore", PendingDeprecationWarning) warnings.simplefilter("ignore", DeprecationWarning)
response = self.client.get(request.path) response = self.client.get(request.path)
CommonMiddleware().process_response(request, response) CommonMiddleware().process_response(request, response)
self.assertEqual(len(mail.outbox), 1) self.assertEqual(len(mail.outbox), 1)
@ -261,7 +261,7 @@ class CommonMiddlewareTest(TestCase):
def test_404_error_reporting_no_referer(self): def test_404_error_reporting_no_referer(self):
request = self._get_request('regular_url/that/does/not/exist') request = self._get_request('regular_url/that/does/not/exist')
with warnings.catch_warnings(): with warnings.catch_warnings():
warnings.simplefilter("ignore", PendingDeprecationWarning) warnings.simplefilter("ignore", DeprecationWarning)
response = self.client.get(request.path) response = self.client.get(request.path)
CommonMiddleware().process_response(request, response) CommonMiddleware().process_response(request, response)
self.assertEqual(len(mail.outbox), 0) self.assertEqual(len(mail.outbox), 0)
@ -273,7 +273,7 @@ class CommonMiddlewareTest(TestCase):
request = self._get_request('foo_url/that/does/not/exist/either') request = self._get_request('foo_url/that/does/not/exist/either')
request.META['HTTP_REFERER'] = '/another/url/' request.META['HTTP_REFERER'] = '/another/url/'
with warnings.catch_warnings(): with warnings.catch_warnings():
warnings.simplefilter("ignore", PendingDeprecationWarning) warnings.simplefilter("ignore", DeprecationWarning)
response = self.client.get(request.path) response = self.client.get(request.path)
CommonMiddleware().process_response(request, response) CommonMiddleware().process_response(request, response)
self.assertEqual(len(mail.outbox), 0) self.assertEqual(len(mail.outbox), 0)
@ -703,7 +703,7 @@ class ETagGZipMiddlewareTest(TestCase):
self.assertNotEqual(gzip_etag, nogzip_etag) self.assertNotEqual(gzip_etag, nogzip_etag)
class TransactionMiddlewareTest(IgnorePendingDeprecationWarningsMixin, TransactionTestCase): class TransactionMiddlewareTest(IgnoreDeprecationWarningsMixin, TransactionTestCase):
""" """
Test the transaction middleware. Test the transaction middleware.
""" """

View File

@ -266,7 +266,7 @@ class ModelFormBaseTest(TestCase):
def test_missing_fields_attribute(self): def test_missing_fields_attribute(self):
with warnings.catch_warnings(record=True) as w: with warnings.catch_warnings(record=True) as w:
warnings.simplefilter("always", PendingDeprecationWarning) warnings.simplefilter("always", DeprecationWarning)
class MissingFieldsForm(forms.ModelForm): class MissingFieldsForm(forms.ModelForm):
class Meta: class Meta:
@ -276,7 +276,7 @@ class ModelFormBaseTest(TestCase):
# if a warning has been seen already, the catch_warnings won't # if a warning has been seen already, the catch_warnings won't
# have recorded it. The following line therefore will not work reliably: # have recorded it. The following line therefore will not work reliably:
# self.assertEqual(w[0].category, PendingDeprecationWarning) # self.assertEqual(w[0].category, DeprecationWarning)
# Until end of the deprecation cycle, should still create the # Until end of the deprecation cycle, should still create the
# form as before: # form as before:

View File

@ -566,10 +566,10 @@ class CustomMetaclassTestCase(TestCase):
class TestTicket19733(TestCase): class TestTicket19733(TestCase):
def test_modelform_factory_without_fields(self): def test_modelform_factory_without_fields(self):
with warnings.catch_warnings(record=True) as w: with warnings.catch_warnings(record=True) as w:
warnings.simplefilter("always", PendingDeprecationWarning) warnings.simplefilter("always", DeprecationWarning)
# This should become an error once deprecation cycle is complete. # This should become an error once deprecation cycle is complete.
form = modelform_factory(Person) form = modelform_factory(Person)
self.assertEqual(w[0].category, PendingDeprecationWarning) self.assertEqual(w[0].category, DeprecationWarning)
def test_modelform_factory_with_all_fields(self): def test_modelform_factory_with_all_fields(self):
form = modelform_factory(Person, fields="__all__") form = modelform_factory(Person, fields="__all__")

View File

@ -109,7 +109,7 @@ def setup(verbosity, test_labels):
# Load all the ALWAYS_INSTALLED_APPS. # Load all the ALWAYS_INSTALLED_APPS.
with warnings.catch_warnings(): with warnings.catch_warnings():
warnings.filterwarnings('ignore', 'django.contrib.comments is deprecated and will be removed before Django 1.8.', PendingDeprecationWarning) warnings.filterwarnings('ignore', 'django.contrib.comments is deprecated and will be removed before Django 1.8.', DeprecationWarning)
get_apps() get_apps()
# Load all the test model apps. # Load all the test model apps.

View File

@ -534,7 +534,7 @@ class TemplateTests(TransRealMixin, TestCase):
try: try:
with warnings.catch_warnings(): with warnings.catch_warnings():
# Ignore pending deprecations of the old syntax of the 'cycle' and 'firstof' tags. # Ignore pending deprecations of the old syntax of the 'cycle' and 'firstof' tags.
warnings.filterwarnings("ignore", category=PendingDeprecationWarning, module='django.template.base') warnings.filterwarnings("ignore", category=DeprecationWarning, module='django.template.base')
test_template = loader.get_template(name) test_template = loader.get_template(name)
except ShouldNotExecuteException: except ShouldNotExecuteException:
failures.append("Template test (Cached='%s', TEMPLATE_STRING_IF_INVALID='%s', TEMPLATE_DEBUG=%s): %s -- FAILED. Template loading invoked method that shouldn't have been invoked." % (is_cached, invalid_str, template_debug, name)) failures.append("Template test (Cached='%s', TEMPLATE_STRING_IF_INVALID='%s', TEMPLATE_DEBUG=%s): %s -- FAILED. Template loading invoked method that shouldn't have been invoked." % (is_cached, invalid_str, template_debug, name))

View File

@ -11,7 +11,7 @@ from django.core.management import call_command
from django import db from django import db
from django.test import runner, TestCase, TransactionTestCase, skipUnlessDBFeature from django.test import runner, TestCase, TransactionTestCase, skipUnlessDBFeature
from django.test.testcases import connections_support_transactions from django.test.testcases import connections_support_transactions
from django.test.utils import IgnorePendingDeprecationWarningsMixin from django.test.utils import IgnoreDeprecationWarningsMixin
from django.utils import unittest from django.utils import unittest
from django.utils.importlib import import_module from django.utils.importlib import import_module
@ -225,7 +225,7 @@ class Ticket17477RegressionTests(AdminScriptTestCase):
self.assertNoOutput(err) self.assertNoOutput(err)
class ModulesTestsPackages(IgnorePendingDeprecationWarningsMixin, unittest.TestCase): class ModulesTestsPackages(IgnoreDeprecationWarningsMixin, unittest.TestCase):
def test_get_tests(self): def test_get_tests(self):
"Check that the get_tests helper function can find tests in a directory" "Check that the get_tests helper function can find tests in a directory"
from django.test.simple import get_tests from django.test.simple import get_tests

View File

@ -1,5 +1,5 @@
from django.db.models import get_app from django.db.models import get_app
from django.test.utils import IgnorePendingDeprecationWarningsMixin from django.test.utils import IgnoreDeprecationWarningsMixin
from django.utils import unittest from django.utils import unittest
@ -9,7 +9,7 @@ def suite():
return testSuite return testSuite
class SuiteOverrideTest(IgnorePendingDeprecationWarningsMixin, unittest.TestCase): class SuiteOverrideTest(IgnoreDeprecationWarningsMixin, unittest.TestCase):
def test_suite_override(self): def test_suite_override(self):
""" """
Validate that you can define a custom suite when running tests with Validate that you can define a custom suite when running tests with

View File

@ -7,7 +7,7 @@ from django.http import HttpResponse
from django.template.loader import render_to_string from django.template.loader import render_to_string
from django.test import SimpleTestCase, TestCase, skipUnlessDBFeature from django.test import SimpleTestCase, TestCase, skipUnlessDBFeature
from django.test.html import HTMLParseError, parse_html from django.test.html import HTMLParseError, parse_html
from django.test.utils import CaptureQueriesContext, IgnorePendingDeprecationWarningsMixin from django.test.utils import CaptureQueriesContext, IgnoreDeprecationWarningsMixin
from django.utils import six from django.utils import six
from django.utils import unittest from django.utils import unittest
from django.utils.unittest import skip from django.utils.unittest import skip
@ -591,7 +591,7 @@ class AssertFieldOutputTests(SimpleTestCase):
self.assertFieldOutput(MyCustomField, {}, {}, empty_value=None) self.assertFieldOutput(MyCustomField, {}, {}, empty_value=None)
class DoctestNormalizerTest(IgnorePendingDeprecationWarningsMixin, SimpleTestCase): class DoctestNormalizerTest(IgnoreDeprecationWarningsMixin, SimpleTestCase):
def test_normalizer(self): def test_normalizer(self):
from django.test.simple import make_doctest from django.test.simple import make_doctest

View File

@ -4,7 +4,7 @@ import sys
from django.db import connection, transaction, DatabaseError, IntegrityError from django.db import connection, transaction, DatabaseError, IntegrityError
from django.test import TransactionTestCase, skipUnlessDBFeature from django.test import TransactionTestCase, skipUnlessDBFeature
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.unittest import skipIf, skipUnless from django.utils.unittest import skipIf, skipUnless
@ -350,7 +350,7 @@ class AtomicMiscTests(TransactionTestCase):
transaction.atomic(Callable()) transaction.atomic(Callable())
class TransactionTests(IgnorePendingDeprecationWarningsMixin, TransactionTestCase): class TransactionTests(IgnoreDeprecationWarningsMixin, TransactionTestCase):
available_apps = ['transactions'] available_apps = ['transactions']
@ -508,7 +508,7 @@ class TransactionTests(IgnorePendingDeprecationWarningsMixin, TransactionTestCas
) )
class TransactionRollbackTests(IgnorePendingDeprecationWarningsMixin, TransactionTestCase): class TransactionRollbackTests(IgnoreDeprecationWarningsMixin, TransactionTestCase):
available_apps = ['transactions'] available_apps = ['transactions']
@ -528,7 +528,7 @@ class TransactionRollbackTests(IgnorePendingDeprecationWarningsMixin, Transactio
self.assertRaises(IntegrityError, execute_bad_sql) self.assertRaises(IntegrityError, execute_bad_sql)
transaction.rollback() transaction.rollback()
class TransactionContextManagerTests(IgnorePendingDeprecationWarningsMixin, TransactionTestCase): class TransactionContextManagerTests(IgnoreDeprecationWarningsMixin, TransactionTestCase):
available_apps = ['transactions'] available_apps = ['transactions']

View File

@ -4,7 +4,7 @@ from django.db import (connection, connections, transaction, DEFAULT_DB_ALIAS, D
IntegrityError) IntegrityError)
from django.db.transaction import commit_on_success, commit_manually, TransactionManagementError from django.db.transaction import commit_on_success, commit_manually, TransactionManagementError
from django.test import TransactionTestCase, skipUnlessDBFeature from django.test import TransactionTestCase, skipUnlessDBFeature
from django.test.utils import override_settings, IgnorePendingDeprecationWarningsMixin from django.test.utils import override_settings, IgnoreDeprecationWarningsMixin
from django.utils.unittest import skipIf, skipUnless from django.utils.unittest import skipIf, skipUnless
from .models import Mod, M2mA, M2mB, SubMod from .models import Mod, M2mA, M2mB, SubMod
@ -30,7 +30,7 @@ class ModelInheritanceTests(TransactionTestCase):
self.assertEqual(SubMod.objects.count(), 1) self.assertEqual(SubMod.objects.count(), 1)
self.assertEqual(Mod.objects.count(), 1) self.assertEqual(Mod.objects.count(), 1)
class TestTransactionClosing(IgnorePendingDeprecationWarningsMixin, TransactionTestCase): class TestTransactionClosing(IgnoreDeprecationWarningsMixin, TransactionTestCase):
""" """
Tests to make sure that transactions are properly closed Tests to make sure that transactions are properly closed
when they should be, and aren't left pending after operations when they should be, and aren't left pending after operations
@ -194,7 +194,7 @@ class TestTransactionClosing(IgnorePendingDeprecationWarningsMixin, TransactionT
(connection.settings_dict['NAME'] == ':memory:' or (connection.settings_dict['NAME'] == ':memory:' or
not connection.settings_dict['NAME']), not connection.settings_dict['NAME']),
'Test uses multiple connections, but in-memory sqlite does not support this') 'Test uses multiple connections, but in-memory sqlite does not support this')
class TestNewConnection(IgnorePendingDeprecationWarningsMixin, TransactionTestCase): class TestNewConnection(IgnoreDeprecationWarningsMixin, TransactionTestCase):
""" """
Check that new connections don't have special behaviour. Check that new connections don't have special behaviour.
""" """
@ -242,7 +242,7 @@ class TestNewConnection(IgnorePendingDeprecationWarningsMixin, TransactionTestCa
@skipUnless(connection.vendor == 'postgresql', @skipUnless(connection.vendor == 'postgresql',
"This test only valid for PostgreSQL") "This test only valid for PostgreSQL")
class TestPostgresAutocommitAndIsolation(IgnorePendingDeprecationWarningsMixin, TransactionTestCase): class TestPostgresAutocommitAndIsolation(IgnoreDeprecationWarningsMixin, TransactionTestCase):
""" """
Tests to make sure psycopg2's autocommit mode and isolation level Tests to make sure psycopg2's autocommit mode and isolation level
is restored after entering and leaving transaction management. is restored after entering and leaving transaction management.
@ -326,7 +326,7 @@ class TestPostgresAutocommitAndIsolation(IgnorePendingDeprecationWarningsMixin,
self.assertTrue(connection.autocommit) self.assertTrue(connection.autocommit)
class TestManyToManyAddTransaction(IgnorePendingDeprecationWarningsMixin, TransactionTestCase): class TestManyToManyAddTransaction(IgnoreDeprecationWarningsMixin, TransactionTestCase):
available_apps = ['transactions_regress'] available_apps = ['transactions_regress']
@ -344,7 +344,7 @@ class TestManyToManyAddTransaction(IgnorePendingDeprecationWarningsMixin, Transa
self.assertEqual(a.others.count(), 1) self.assertEqual(a.others.count(), 1)
class SavepointTest(IgnorePendingDeprecationWarningsMixin, TransactionTestCase): class SavepointTest(IgnoreDeprecationWarningsMixin, TransactionTestCase):
available_apps = ['transactions_regress'] available_apps = ['transactions_regress']