Fixed #21188 -- Introduced subclasses for to-be-removed-in-django-XX warnings

Thanks Anssi Kääriäinen for the idea and Simon Charette for the
review.
This commit is contained in:
Claude Paroz 2014-02-26 22:48:20 +01:00
parent 70ec4d776e
commit 210d0489c5
84 changed files with 287 additions and 189 deletions

View File

@ -6,6 +6,7 @@ import warnings
from django.core.exceptions import ImproperlyConfigured
from django.utils import lru_cache
from django.utils.deprecation import RemovedInDjango19Warning
from django.utils._os import upath
from .config import AppConfig
@ -156,7 +157,7 @@ class Apps(object):
if app_mod:
warnings.warn(
"The app_mod argument of get_models is deprecated.",
PendingDeprecationWarning, stacklevel=2)
RemovedInDjango19Warning, stacklevel=2)
app_label = app_mod.__name__.split('.')[-2]
try:
return list(self.get_app_config(app_label).get_models(
@ -328,7 +329,7 @@ class Apps(object):
"""
warnings.warn(
"load_app(app_name) is deprecated.",
PendingDeprecationWarning, stacklevel=2)
RemovedInDjango19Warning, stacklevel=2)
app_config = AppConfig.create(app_name)
app_config.import_models(self.all_models[app_config.label])
self.app_configs[app_config.label] = app_config
@ -338,7 +339,7 @@ class Apps(object):
def app_cache_ready(self):
warnings.warn(
"app_cache_ready() is deprecated in favor of the ready property.",
PendingDeprecationWarning, stacklevel=2)
RemovedInDjango19Warning, stacklevel=2)
return self.ready
def get_app(self, app_label):
@ -347,7 +348,7 @@ class Apps(object):
"""
warnings.warn(
"get_app_config(app_label).models_module supersedes get_app(app_label).",
PendingDeprecationWarning, stacklevel=2)
RemovedInDjango19Warning, stacklevel=2)
try:
models_module = self.get_app_config(app_label).models_module
except LookupError as exc:
@ -364,7 +365,7 @@ class Apps(object):
"""
warnings.warn(
"[a.models_module for a in get_app_configs()] supersedes get_apps().",
PendingDeprecationWarning, stacklevel=2)
RemovedInDjango19Warning, stacklevel=2)
app_configs = self.get_app_configs()
return [app_config.models_module for app_config in app_configs
if app_config.models_module is not None]
@ -375,7 +376,7 @@ class Apps(object):
def get_app_package(self, app_label):
warnings.warn(
"get_app_config(label).name supersedes get_app_package(label).",
PendingDeprecationWarning, stacklevel=2)
RemovedInDjango19Warning, stacklevel=2)
return self._get_app_package(self.get_app(app_label))
def _get_app_path(self, app):
@ -388,7 +389,7 @@ class Apps(object):
def get_app_path(self, app_label):
warnings.warn(
"get_app_config(label).path supersedes get_app_path(label).",
PendingDeprecationWarning, stacklevel=2)
RemovedInDjango19Warning, stacklevel=2)
return self._get_app_path(self.get_app(app_label))
def get_app_paths(self):
@ -400,7 +401,7 @@ class Apps(object):
"""
warnings.warn(
"[a.path for a in get_app_configs()] supersedes get_app_paths().",
PendingDeprecationWarning, stacklevel=2)
RemovedInDjango19Warning, stacklevel=2)
self.check_ready()
app_paths = []
for app in self.get_apps():
@ -413,7 +414,7 @@ class Apps(object):
"""
warnings.warn(
"register_models(app_label, *models) is deprecated.",
PendingDeprecationWarning, stacklevel=2)
RemovedInDjango19Warning, stacklevel=2)
for model in models:
self.register_model(app_label, model)

View File

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

View File

@ -18,7 +18,8 @@ from django.contrib.admin.templatetags.admin_static import static
from django.contrib.admin.templatetags.admin_urls import add_preserved_filters
from django.contrib.auth import get_permission_codename
from django.core import checks
from django.core.exceptions import PermissionDenied, ValidationError, FieldError, ImproperlyConfigured
from django.core.exceptions import (PermissionDenied, ValidationError,
FieldError, ImproperlyConfigured)
from django.core.paginator import Paginator
from django.core.urlresolvers import reverse
from django.db import models, transaction, router
@ -35,9 +36,9 @@ from django.shortcuts import get_object_or_404
from django.template.response import SimpleTemplateResponse, TemplateResponse
from django.utils import six
from django.utils.decorators import method_decorator
from django.utils.deprecation import RenameMethodsBase
from django.utils.encoding import force_text
from django.utils.encoding import python_2_unicode_compatible
from django.utils.deprecation import (RenameMethodsBase,
RemovedInDjango18Warning, RemovedInDjango19Warning)
from django.utils.encoding import force_text, python_2_unicode_compatible
from django.utils.html import escape, escapejs
from django.utils.http import urlencode
from django.utils.text import capfirst, get_text_list
@ -93,7 +94,7 @@ csrf_protect_m = method_decorator(csrf_protect)
class RenameBaseModelAdminMethods(forms.MediaDefiningClass, RenameMethodsBase):
renamed_methods = (
('queryset', 'get_queryset', DeprecationWarning),
('queryset', 'get_queryset', RemovedInDjango18Warning),
)
@ -125,7 +126,7 @@ class BaseModelAdmin(six.with_metaclass(RenameBaseModelAdminMethods)):
def validate(cls, model):
warnings.warn(
'ModelAdmin.validate() is deprecated. Use "check()" instead.',
PendingDeprecationWarning)
RemovedInDjango19Warning)
if cls.validator_class:
validator = cls.validator_class()
else:
@ -139,7 +140,7 @@ class BaseModelAdmin(six.with_metaclass(RenameBaseModelAdminMethods)):
'ModelAdmin.validator_class is deprecated. '
'ModeAdmin validators must be converted to use '
'the system check framework.',
PendingDeprecationWarning)
RemovedInDjango19Warning)
validator = cls.validator_class()
try:
validator.validate(cls, model)
@ -306,7 +307,7 @@ class BaseModelAdmin(six.with_metaclass(RenameBaseModelAdminMethods)):
warnings.warn(
"ModelAdmin.declared_fieldsets is deprecated and "
"will be removed in Django 1.9.",
PendingDeprecationWarning, stacklevel=2
RemovedInDjango19Warning, stacklevel=2
)
if self.fieldsets:
@ -332,11 +333,11 @@ class BaseModelAdmin(six.with_metaclass(RenameBaseModelAdminMethods)):
with warnings.catch_warnings(record=True) as w:
warnings.simplefilter("always")
declared_fieldsets = self.declared_fieldsets
if len(w) != 1 or not issubclass(w[0].category, PendingDeprecationWarning):
if len(w) != 1 or not issubclass(w[0].category, RemovedInDjango19Warning):
warnings.warn(
"ModelAdmin.declared_fieldsets is deprecated and "
"will be removed in Django 1.9.",
PendingDeprecationWarning
RemovedInDjango19Warning
)
if declared_fieldsets:
return declared_fieldsets
@ -695,7 +696,7 @@ class ModelAdmin(BaseModelAdmin):
warnings.warn(
"ModelAdmin.get_formsets() is deprecated and will be removed in "
"Django 1.9. Use ModelAdmin.get_formsets_with_inlines() instead.",
PendingDeprecationWarning, stacklevel=2
RemovedInDjango19Warning, stacklevel=2
)
return self._get_formsets(request, obj)
@ -711,11 +712,11 @@ class ModelAdmin(BaseModelAdmin):
warnings.simplefilter("always")
formsets = self.get_formsets(request, obj)
if len(w) != 1 or not issubclass(w[0].category, PendingDeprecationWarning):
if len(w) != 1 or not issubclass(w[0].category, RemovedInDjango19Warning):
warnings.warn(
"ModelAdmin.get_formsets() is deprecated and will be removed in "
"Django 1.9. Use ModelAdmin.get_formsets_with_inlines() instead.",
PendingDeprecationWarning
RemovedInDjango19Warning
)
if formsets:
zipped = zip(formsets, self.get_inline_instances(request, None))

View File

@ -1,7 +1,9 @@
import warnings
from django.utils.deprecation import RemovedInDjango19Warning
warnings.warn(
"The django.contrib.admin.util module has been renamed. "
"Use django.contrib.admin.utils instead.", PendingDeprecationWarning)
"Use django.contrib.admin.utils instead.", RemovedInDjango19Warning)
from django.contrib.admin.utils import * # NOQA

View File

@ -8,7 +8,7 @@ from django.core.urlresolvers import reverse
from django.db import models
from django.db.models.fields import FieldDoesNotExist
from django.utils import six
from django.utils.deprecation import RenameMethodsBase
from django.utils.deprecation import RenameMethodsBase, RemovedInDjango18Warning
from django.utils.encoding import force_text
from django.utils.translation import ugettext, ugettext_lazy
from django.utils.http import urlencode
@ -51,7 +51,7 @@ def _is_changelist_popup(request):
warnings.warn(
"The `%s` GET parameter has been renamed to `%s`." %
(IS_LEGACY_POPUP_VAR, IS_POPUP_VAR),
DeprecationWarning, 2)
RemovedInDjango18Warning, 2)
return True
return False
@ -59,7 +59,7 @@ def _is_changelist_popup(request):
class RenameChangeListMethods(RenameMethodsBase):
renamed_methods = (
('get_query_set', 'get_queryset', DeprecationWarning),
('get_query_set', 'get_queryset', RemovedInDjango18Warning),
)
@ -114,14 +114,14 @@ class ChangeList(six.with_metaclass(RenameChangeListMethods)):
def root_query_set(self):
warnings.warn("`ChangeList.root_query_set` is deprecated, "
"use `root_queryset` instead.",
DeprecationWarning, 2)
RemovedInDjango18Warning, 2)
return self.root_queryset
@property
def query_set(self):
warnings.warn("`ChangeList.query_set` is deprecated, "
"use `queryset` instead.",
DeprecationWarning, 2)
RemovedInDjango18Warning, 2)
return self.queryset
def get_filters_params(self, params=None):

View File

@ -15,6 +15,7 @@ from django.http import Http404
from django.core import urlresolvers
from django.contrib.admindocs import utils
from django.utils.decorators import method_decorator
from django.utils.deprecation import RemovedInDjango18Warning
from django.utils._os import upath
from django.utils import six
from django.utils.translation import ugettext as _
@ -25,7 +26,7 @@ MODEL_METHODS_EXCLUDE = ('_', 'add_', 'delete', 'save', 'set_')
if getattr(settings, 'ADMIN_FOR', None):
warnings.warn('The ADMIN_FOR setting has been removed, you can remove '
'this setting from your configuration.', DeprecationWarning,
'this setting from your configuration.', RemovedInDjango18Warning,
stacklevel=2)

View File

@ -1,13 +1,16 @@
from importlib import import_module
import warnings
from django.apps import apps as django_apps
from django.conf import settings
from django.core import urlresolvers
from django.core.exceptions import ImproperlyConfigured
from django.contrib.comments.models import Comment
from django.contrib.comments.forms import CommentForm
from django.utils.deprecation import RemovedInDjango18Warning
warnings.warn("django.contrib.comments is deprecated and will be removed before Django 1.8.", DeprecationWarning)
warnings.warn("django.contrib.comments is deprecated and will be removed before Django 1.8.", RemovedInDjango18Warning)
DEFAULT_COMMENTS_APP = 'django.contrib.comments'

View File

@ -4,7 +4,7 @@ from django.conf import settings
from django.contrib.contenttypes.models import ContentType
from django.contrib import comments
from django.utils import six
from django.utils.deprecation import RenameMethodsBase
from django.utils.deprecation import RenameMethodsBase, RemovedInDjango18Warning
from django.utils.encoding import smart_text
register = template.Library()
@ -12,7 +12,7 @@ register = template.Library()
class RenameBaseCommentNodeMethods(RenameMethodsBase):
renamed_methods = (
('get_query_set', 'get_queryset', DeprecationWarning),
('get_query_set', 'get_queryset', RemovedInDjango18Warning),
)

View File

@ -13,13 +13,13 @@ from django.db.models.related import PathInfo
from django.db.models.sql.datastructures import Col
from django.contrib.contenttypes.models import ContentType
from django.utils import six
from django.utils.deprecation import RenameMethodsBase
from django.utils.deprecation import RenameMethodsBase, RemovedInDjango18Warning
from django.utils.encoding import smart_text, python_2_unicode_compatible
class RenameGenericForeignKeyMethods(RenameMethodsBase):
renamed_methods = (
('get_prefetch_query_set', 'get_prefetch_queryset', DeprecationWarning),
('get_prefetch_query_set', 'get_prefetch_queryset', RemovedInDjango18Warning),
)

View File

@ -2,11 +2,12 @@ from __future__ import unicode_literals
import warnings
from django.utils.deprecation import RemovedInDjango19Warning
warnings.warn(
('django.contrib.contenttypes.generic is deprecated and will be removed in '
'Django 1.9. Its contents have been moved to the fields, forms, and admin '
'submodules of django.contrib.contenttypes.'), PendingDeprecationWarning, stacklevel=2
'submodules of django.contrib.contenttypes.'), RemovedInDjango19Warning, stacklevel=2
)
from django.contrib.contenttypes.admin import ( # NOQA

View File

@ -1,7 +1,9 @@
import warnings
from django.utils.deprecation import RemovedInDjango19Warning
warnings.warn(
"The django.contrib.gis.db.backends.util module has been renamed. "
"Use django.contrib.gis.db.backends.utils instead.", PendingDeprecationWarning)
"Use django.contrib.gis.db.backends.utils instead.", RemovedInDjango19Warning)
from django.contrib.gis.db.backends.utils import * # NOQA

View File

@ -12,6 +12,7 @@ from django.contrib.gis.db.models.fields import GeometryField
from django.db import connections, DEFAULT_DB_ALIAS
from django.db.models.fields import FieldDoesNotExist
from django.utils import six
from django.utils.deprecation import RemovedInDjango18Warning
from django.utils.translation import ugettext as _
from django.contrib.gis.shortcuts import render_to_kml, render_to_kmz
@ -23,7 +24,7 @@ def index(request, sitemaps):
for resolving geographic section sitemap URLs.
"""
warnings.warn("Geo Sitemaps are deprecated. Use plain sitemaps from "
"django.contrib.sitemaps instead", DeprecationWarning, stacklevel=2)
"django.contrib.sitemaps instead", RemovedInDjango18Warning, stacklevel=2)
current_site = get_current_site(request)
sites = []
protocol = request.scheme
@ -48,7 +49,7 @@ def sitemap(request, sitemaps, section=None):
elements defined by Google.
"""
warnings.warn("Geo Sitemaps are deprecated. Use plain sitemaps from "
"django.contrib.sitemaps instead", DeprecationWarning, stacklevel=2)
"django.contrib.sitemaps instead", RemovedInDjango18Warning, stacklevel=2)
maps, urls = [], []
if section is not None:
if section not in sitemaps:

View File

@ -6,8 +6,9 @@ import warnings
from django.core.exceptions import ImproperlyConfigured, ValidationError
from django.db import models
from django.db.models.signals import pre_save, pre_delete
from django.utils.translation import ugettext_lazy as _
from django.utils.deprecation import RemovedInDjango19Warning
from django.utils.encoding import python_2_unicode_compatible
from django.utils.translation import ugettext_lazy as _
from .requests import RequestSite as RealRequestSite
from .shortcuts import get_current_site as real_get_current_site
@ -82,14 +83,14 @@ class RequestSite(RealRequestSite):
def __init__(self, *args, **kwargs):
warnings.warn(
"Please import RequestSite from django.contrib.sites.requests.",
PendingDeprecationWarning, stacklevel=2)
RemovedInDjango19Warning, stacklevel=2)
super(RequestSite, self).__init__(*args, **kwargs)
def get_current_site(request):
warnings.warn(
"Please import get_current_site from django.contrib.sites.shortcuts.",
PendingDeprecationWarning, stacklevel=2)
RemovedInDjango19Warning, stacklevel=2)
return real_get_current_site(request)

View File

@ -20,6 +20,7 @@ from django.core import signals
from django.core.cache.backends.base import (
InvalidCacheBackendError, CacheKeyWarning, BaseCache)
from django.core.exceptions import ImproperlyConfigured
from django.utils.deprecation import RemovedInDjango19Warning
from django.utils.module_loading import import_string
@ -52,7 +53,7 @@ def get_cache(backend, **kwargs):
"""
warnings.warn("'get_cache' is deprecated in favor of 'caches'.",
PendingDeprecationWarning, stacklevel=2)
RemovedInDjango19Warning, stacklevel=2)
cache = _create_cache(backend, **kwargs)
# Some caches -- python-memcached in particular -- need to do a cleanup at the
# end of a request cycle. If not implemented in a particular backend

View File

@ -4,16 +4,15 @@ import time
import pickle
from django.core.cache.backends.base import BaseCache, DEFAULT_TIMEOUT
from django.utils import six
from django.utils.deprecation import RenameMethodsBase
from django.utils.deprecation import RenameMethodsBase, RemovedInDjango19Warning
from django.utils.encoding import force_str
from django.utils.functional import cached_property
class BaseMemcachedCacheMethods(RenameMethodsBase):
renamed_methods = (
('_get_memcache_timeout', 'get_backend_timeout', PendingDeprecationWarning),
('_get_memcache_timeout', 'get_backend_timeout', RemovedInDjango19Warning),
)

View File

@ -14,6 +14,7 @@ from django.core import signals
from django.core.handlers import base
from django.core.urlresolvers import set_script_prefix
from django.utils import datastructures
from django.utils.deprecation import RemovedInDjango19Warning
from django.utils.encoding import force_str, force_text
from django.utils.functional import cached_property
from django.utils import six
@ -118,7 +119,7 @@ class WSGIRequest(http.HttpRequest):
def _get_request(self):
warnings.warn('`request.REQUEST` is deprecated, use `request.GET` or '
'`request.POST` instead.', PendingDeprecationWarning, 2)
'`request.POST` instead.', RemovedInDjango19Warning, 2)
if not hasattr(self, '_request'):
self._request = datastructures.MergeDict(self.POST, self.GET)
return self._request

View File

@ -17,6 +17,7 @@ import django
from django.core import checks
from django.core.exceptions import ImproperlyConfigured
from django.core.management.color import color_style, no_style
from django.utils.deprecation import RemovedInDjango19Warning
from django.utils.encoding import force_str
@ -219,7 +220,7 @@ class BaseCommand(object):
warnings.warn(
'"requires_model_validation" is deprecated '
'in favor of "requires_system_checks".',
PendingDeprecationWarning)
RemovedInDjango19Warning)
if has_old_option and has_new_option:
raise ImproperlyConfigured(
'Command %s defines both "requires_model_validation" '
@ -467,7 +468,7 @@ class AppCommand(BaseCommand):
warnings.warn(
"AppCommand.handle_app() is superseded by "
"AppCommand.handle_app_config().",
PendingDeprecationWarning, stacklevel=2)
RemovedInDjango19Warning, stacklevel=2)
if app_config.models_module is None:
raise CommandError(
"AppCommand cannot handle app '%s' in legacy mode "

View File

@ -7,6 +7,7 @@ from django.apps import apps
from django.core.management.base import BaseCommand, CommandError
from django.core import serializers
from django.db import router, DEFAULT_DB_ALIAS
from django.utils.deprecation import RemovedInDjango19Warning
class Command(BaseCommand):
@ -50,7 +51,7 @@ class Command(BaseCommand):
use_natural_keys = options.get('use_natural_keys')
if use_natural_keys:
warnings.warn("``--natural`` is deprecated; use ``--natural-foreign`` instead.",
PendingDeprecationWarning)
RemovedInDjango19Warning)
use_natural_foreign_keys = options.get('use_natural_foreign_keys') or use_natural_keys
use_natural_primary_keys = options.get('use_natural_primary_keys')
use_base_manager = options.get('use_base_manager')

View File

@ -1,6 +1,7 @@
import warnings
from django.core.management.base import BaseCommand
from django.utils.deprecation import RemovedInDjango19Warning
class Command(BaseCommand):
@ -10,7 +11,7 @@ class Command(BaseCommand):
def handle(self, *args, **options):
warnings.warn(
"FastCGI support has been deprecated and will be removed in Django 1.9.",
PendingDeprecationWarning)
RemovedInDjango19Warning)
from django.conf import settings
from django.utils import translation

View File

@ -1,8 +1,10 @@
import warnings
from optparse import make_option
from django.db import DEFAULT_DB_ALIAS
from django.core.management import call_command
from django.core.management.base import NoArgsCommand
from django.utils.deprecation import RemovedInDjango19Warning
class Command(NoArgsCommand):
@ -18,5 +20,5 @@ class Command(NoArgsCommand):
help = "Deprecated - use 'migrate' instead."
def handle_noargs(self, **options):
warnings.warn("The syncdb command will be removed in Django 1.9", PendingDeprecationWarning)
warnings.warn("The syncdb command will be removed in Django 1.9", RemovedInDjango19Warning)
call_command("migrate", **options)

View File

@ -4,6 +4,7 @@ from __future__ import unicode_literals
import warnings
from django.core.management.commands.check import Command as CheckCommand
from django.utils.deprecation import RemovedInDjango19Warning
class Command(CheckCommand):
@ -11,5 +12,5 @@ class Command(CheckCommand):
def handle_noargs(self, **options):
warnings.warn('"validate" has been deprecated in favor of "check".',
PendingDeprecationWarning)
RemovedInDjango19Warning)
super(Command, self).handle_noargs(**options)

View File

@ -10,6 +10,7 @@ from django.conf import settings
from django.core.management.base import CommandError
from django.db import models, router
from django.utils import six
from django.utils.deprecation import RemovedInDjango19Warning
def sql_create(app_config, style, connection):
@ -179,7 +180,7 @@ def custom_sql_for_model(model, style, connection):
if os.path.exists(old_app_dir):
warnings.warn("Custom SQL location '<app_label>/models/sql' is "
"deprecated, use '<app_label>/sql' instead.",
PendingDeprecationWarning)
RemovedInDjango19Warning)
app_dirs.append(old_app_dir)
output = []

View File

@ -5,6 +5,7 @@ import warnings
from django.db import models
from django.utils import six
from django.utils.deprecation import RemovedInDjango19Warning
class SerializerDoesNotExist(KeyError):
@ -42,7 +43,7 @@ class Serializer(object):
self.use_natural_keys = options.pop("use_natural_keys", False)
if self.use_natural_keys:
warnings.warn("``use_natural_keys`` is deprecated; use ``use_natural_foreign_keys`` instead.",
PendingDeprecationWarning)
RemovedInDjango19Warning)
self.use_natural_foreign_keys = options.pop('use_natural_foreign_keys', False) or self.use_natural_keys
self.use_natural_primary_keys = options.pop('use_natural_primary_keys', False)

View File

@ -5,6 +5,7 @@ from django.db.utils import (DEFAULT_DB_ALIAS, DataError, OperationalError,
IntegrityError, InternalError, ProgrammingError, NotSupportedError,
DatabaseError, InterfaceError, Error, load_backend,
ConnectionHandler, ConnectionRouter)
from django.utils.deprecation import RemovedInDjango18Warning
from django.utils.functional import cached_property
@ -61,7 +62,7 @@ class DefaultBackendProxy(object):
@cached_property
def _backend(self):
warnings.warn("Accessing django.db.backend is deprecated.",
DeprecationWarning, stacklevel=2)
RemovedInDjango18Warning, stacklevel=2)
return load_backend(connections[DEFAULT_DB_ALIAS].settings_dict['ENGINE'])
def __getattr__(self, item):
@ -79,7 +80,7 @@ backend = DefaultBackendProxy()
def close_connection(**kwargs):
warnings.warn(
"close_connection is superseded by close_old_connections.",
DeprecationWarning, stacklevel=2)
RemovedInDjango18Warning, stacklevel=2)
# Avoid circular imports
from django.db import transaction
for conn in connections:

View File

@ -1402,7 +1402,7 @@ class BaseDatabaseValidation(object):
# This is deliberately commented out. It exists as a marker to
# remind us to remove this method, and the check_field() shim,
# when the time comes.
# warnings.warn('"validate_field" has been deprecated", PendingDeprecationWarning)
# warnings.warn('"validate_field" has been deprecated", RemovedInDjango19Warning)
pass
def check_field(self, field, **kwargs):

View File

@ -5,6 +5,7 @@ import warnings
from django.conf import settings
from django.db.utils import load_backend
from django.utils.deprecation import RemovedInDjango18Warning
from django.utils.encoding import force_bytes
from django.utils.functional import cached_property
from django.utils.six.moves import input
@ -474,7 +475,7 @@ class BaseDatabaseCreation(object):
"""
warnings.warn(
"set_autocommit was moved from BaseDatabaseCreation to "
"BaseDatabaseWrapper.", DeprecationWarning, stacklevel=2)
"BaseDatabaseWrapper.", RemovedInDjango18Warning, stacklevel=2)
return self.connection.set_autocommit(True)
def sql_table_creation_suffix(self):

View File

@ -1,7 +1,9 @@
import warnings
from django.utils.deprecation import RemovedInDjango19Warning
warnings.warn(
"The django.db.backends.util module has been renamed. "
"Use django.db.backends.utils instead.", PendingDeprecationWarning)
"Use django.db.backends.utils instead.", RemovedInDjango19Warning)
from django.db.backends.utils import * # NOQA

View File

@ -19,6 +19,7 @@ from django.db.models.deletion import ( # NOQA
CASCADE, PROTECT, SET, SET_NULL, SET_DEFAULT, DO_NOTHING, ProtectedError)
from django.db.models.lookups import Lookup, Transform # NOQA
from django.db.models import signals # NOQA
from django.utils.deprecation import RemovedInDjango19Warning
def permalink(func):
@ -47,7 +48,7 @@ def make_alias(function_name):
def alias(*args, **kwargs):
warnings.warn(
"django.db.models.%s is deprecated." % function_name,
PendingDeprecationWarning, stacklevel=2)
RemovedInDjango19Warning, stacklevel=2)
# This raises a second warning.
from . import loading
return getattr(loading, function_name)(*args, **kwargs)

View File

@ -22,12 +22,13 @@ from django.db.models.query_utils import DeferredAttribute, deferred_class_facto
from django.db.models.deletion import Collector
from django.db.models.options import Options
from django.db.models import signals
from django.utils.translation import ugettext_lazy as _
from django.utils.functional import curry
from django.utils.encoding import force_str, force_text
from django.utils import six
from django.utils.deprecation import RemovedInDjango19Warning
from django.utils.encoding import force_str, force_text
from django.utils.functional import curry
from django.utils.six.moves import zip
from django.utils.text import get_text_list, capfirst
from django.utils.translation import ugettext_lazy as _
def subclass_exception(name, parents, module, attached_to=None):
@ -114,7 +115,7 @@ class ModelBase(type):
msg += "Its app_label will be set to None in Django 1.9."
else:
msg += "This will no longer be supported in Django 1.9."
warnings.warn(msg, PendingDeprecationWarning, stacklevel=2)
warnings.warn(msg, RemovedInDjango19Warning, stacklevel=2)
model_module = sys.modules[new_class.__module__]
package_components = model_module.__name__.split('.')

View File

@ -19,6 +19,7 @@ from django import forms
from django.core import exceptions, validators, checks
from django.utils.datastructures import DictWrapper
from django.utils.dateparse import parse_date, parse_datetime, parse_time
from django.utils.deprecation import RemovedInDjango19Warning
from django.utils.functional import curry, total_ordering, Promise
from django.utils.text import capfirst
from django.utils import timezone
@ -1618,7 +1619,7 @@ class IPAddressField(Field):
def __init__(self, *args, **kwargs):
warnings.warn("IPAddressField has been deprecated. Use GenericIPAddressField instead.",
PendingDeprecationWarning)
RemovedInDjango19Warning)
kwargs['max_length'] = 15
super(IPAddressField, self).__init__(*args, **kwargs)

View File

@ -14,7 +14,7 @@ from django.db.models.query import QuerySet
from django.db.models.sql.datastructures import Col
from django.utils.encoding import smart_text
from django.utils import six
from django.utils.deprecation import RenameMethodsBase
from django.utils.deprecation import RenameMethodsBase, RemovedInDjango18Warning
from django.utils.translation import ugettext_lazy as _
from django.utils.functional import curry, cached_property
from django.core import exceptions
@ -346,8 +346,8 @@ class RelatedField(Field):
class RenameRelatedObjectDescriptorMethods(RenameMethodsBase):
renamed_methods = (
('get_query_set', 'get_queryset', DeprecationWarning),
('get_prefetch_query_set', 'get_prefetch_queryset', DeprecationWarning),
('get_query_set', 'get_queryset', RemovedInDjango18Warning),
('get_prefetch_query_set', 'get_prefetch_queryset', RemovedInDjango18Warning),
)

View File

@ -1,11 +1,13 @@
import warnings
from django.apps import apps
from django.utils.deprecation import RemovedInDjango19Warning
warnings.warn(
"The utilities in django.db.models.loading are deprecated "
"in favor of the new application loading system.",
PendingDeprecationWarning, stacklevel=2)
RemovedInDjango19Warning, stacklevel=2)
__all__ = ('get_apps', 'get_app', 'get_models', 'get_model', 'register_models',
'load_app', 'app_cache_ready')

View File

@ -6,7 +6,7 @@ from django.db.models.query import QuerySet
from django.db.models import signals
from django.db.models.fields import FieldDoesNotExist
from django.utils import six
from django.utils.deprecation import RenameMethodsBase
from django.utils.deprecation import RenameMethodsBase, RemovedInDjango18Warning
from django.utils.encoding import python_2_unicode_compatible
@ -54,8 +54,8 @@ signals.class_prepared.connect(ensure_default_manager)
class RenameManagerMethods(RenameMethodsBase):
renamed_methods = (
('get_query_set', 'get_queryset', DeprecationWarning),
('get_prefetch_query_set', 'get_prefetch_queryset', DeprecationWarning),
('get_query_set', 'get_queryset', RemovedInDjango18Warning),
('get_prefetch_query_set', 'get_prefetch_queryset', RemovedInDjango18Warning),
)

View File

@ -10,8 +10,9 @@ from django.db.models.fields.related import ManyToManyRel
from django.db.models.fields import AutoField, FieldDoesNotExist
from django.db.models.fields.proxy import OrderWrt
from django.utils import six
from django.utils.functional import cached_property
from django.utils.deprecation import RemovedInDjango18Warning
from django.utils.encoding import force_text, smart_text, python_2_unicode_compatible
from django.utils.functional import cached_property
from django.utils.text import camel_case_to_spaces
from django.utils.translation import activate, deactivate_all, get_language, string_concat
@ -171,7 +172,7 @@ class Options(object):
"""
warnings.warn(
"Options.module_name has been deprecated in favor of model_name",
DeprecationWarning, stacklevel=2)
RemovedInDjango18Warning, stacklevel=2)
return self.model_name
def _prepare(self, model):
@ -462,7 +463,7 @@ class Options(object):
warnings.warn(
"`Options.get_add_permission` has been deprecated in favor "
"of `django.contrib.auth.get_permission_codename`.",
DeprecationWarning, stacklevel=2)
RemovedInDjango18Warning, stacklevel=2)
return 'add_%s' % self.model_name
def get_change_permission(self):
@ -473,7 +474,7 @@ class Options(object):
warnings.warn(
"`Options.get_change_permission` has been deprecated in favor "
"of `django.contrib.auth.get_permission_codename`.",
DeprecationWarning, stacklevel=2)
RemovedInDjango18Warning, stacklevel=2)
return 'change_%s' % self.model_name
def get_delete_permission(self):
@ -484,7 +485,7 @@ class Options(object):
warnings.warn(
"`Options.get_delete_permission` has been deprecated in favor "
"of `django.contrib.auth.get_permission_codename`.",
DeprecationWarning, stacklevel=2)
RemovedInDjango18Warning, stacklevel=2)
return 'delete_%s' % self.model_name
def get_all_related_objects(self, local_only=False, include_hidden=False,

View File

@ -11,9 +11,7 @@ from collections import OrderedDict
import copy
import warnings
from django.utils.encoding import force_text
from django.utils.tree import Node
from django.utils import six
from django.core.exceptions import FieldError
from django.db import connections, DEFAULT_DB_ALIAS
from django.db.models.constants import LOOKUP_SEP
from django.db.models.aggregates import refs_aggregate
@ -29,7 +27,10 @@ from django.db.models.sql.datastructures import EmptyResultSet, Empty, MultiJoin
from django.db.models.sql.expressions import SQLEvaluator
from django.db.models.sql.where import (WhereNode, Constraint, EverythingNode,
ExtraWhere, AND, OR, EmptyWhere)
from django.core.exceptions import FieldError
from django.utils import six
from django.utils.deprecation import RemovedInDjango19Warning
from django.utils.encoding import force_text
from django.utils.tree import Node
__all__ = ['Query', 'RawQuery']
@ -1043,7 +1044,7 @@ class Query(object):
elif callable(value):
warnings.warn(
"Passing callable arguments to queryset is deprecated.",
PendingDeprecationWarning, stacklevel=2)
RemovedInDjango19Warning, stacklevel=2)
value = value()
elif isinstance(value, ExpressionNode):
# If value is a query expression, evaluate it

View File

@ -11,6 +11,7 @@ from django.conf import settings
from django.db.models.fields import DateTimeField, Field
from django.db.models.sql.datastructures import EmptyResultSet, Empty
from django.db.models.sql.aggregates import Aggregate
from django.utils.deprecation import RemovedInDjango19Warning
from django.utils.six.moves import xrange
from django.utils import timezone
from django.utils import tree
@ -177,7 +178,7 @@ class WhereNode(tree.Node):
"""
warnings.warn(
"The make_atom() method will be removed in Django 1.9. Use Lookup class instead.",
PendingDeprecationWarning)
RemovedInDjango19Warning)
lvalue, lookup_type, value_annotation, params_or_value = child
field_internal_type = lvalue.field.get_internal_type() if lvalue.field else None
@ -355,7 +356,7 @@ class Constraint(object):
def __init__(self, alias, col, field):
warnings.warn(
"The Constraint class will be removed in Django 1.9. Use Lookup class instead.",
PendingDeprecationWarning)
RemovedInDjango19Warning)
self.alias, self.col, self.field = alias, col, field
def prepare(self, lookup_type, value):

View File

@ -20,6 +20,7 @@ from django.db import (
connections, DEFAULT_DB_ALIAS,
DatabaseError, ProgrammingError)
from django.utils.decorators import available_attrs
from django.utils.deprecation import RemovedInDjango18Warning
class TransactionManagementError(ProgrammingError):
@ -110,22 +111,22 @@ def set_clean(using=None):
def is_managed(using=None):
warnings.warn("'is_managed' is deprecated.",
DeprecationWarning, stacklevel=2)
RemovedInDjango18Warning, stacklevel=2)
def managed(flag=True, using=None):
warnings.warn("'managed' no longer serves a purpose.",
DeprecationWarning, stacklevel=2)
RemovedInDjango18Warning, stacklevel=2)
def commit_unless_managed(using=None):
warnings.warn("'commit_unless_managed' is now a no-op.",
DeprecationWarning, stacklevel=2)
RemovedInDjango18Warning, stacklevel=2)
def rollback_unless_managed(using=None):
warnings.warn("'rollback_unless_managed' is now a no-op.",
DeprecationWarning, stacklevel=2)
RemovedInDjango18Warning, stacklevel=2)
###############
@ -450,7 +451,7 @@ def autocommit(using=None):
your settings file and want the default behavior in some view functions.
"""
warnings.warn("autocommit is deprecated in favor of set_autocommit.",
DeprecationWarning, stacklevel=2)
RemovedInDjango18Warning, stacklevel=2)
def entering(using):
enter_transaction_management(managed=False, using=using)
@ -469,7 +470,7 @@ def commit_on_success(using=None):
control in Web apps.
"""
warnings.warn("commit_on_success is deprecated in favor of atomic.",
DeprecationWarning, stacklevel=2)
RemovedInDjango18Warning, stacklevel=2)
def entering(using):
enter_transaction_management(using=using)
@ -500,7 +501,7 @@ def commit_manually(using=None):
themselves.
"""
warnings.warn("commit_manually is deprecated in favor of set_autocommit.",
DeprecationWarning, stacklevel=2)
RemovedInDjango18Warning, stacklevel=2)
def entering(using):
enter_transaction_management(using=using)

View File

@ -6,6 +6,7 @@ import warnings
from django.conf import settings
from django.core.exceptions import ImproperlyConfigured
from django.utils.deprecation import RemovedInDjango18Warning, RemovedInDjango19Warning
from django.utils.functional import cached_property
from django.utils.module_loading import import_string
from django.utils._os import upath
@ -169,7 +170,7 @@ class ConnectionHandler(object):
if settings.TRANSACTIONS_MANAGED:
warnings.warn(
"TRANSACTIONS_MANAGED is deprecated. Use AUTOCOMMIT instead.",
DeprecationWarning, stacklevel=2)
RemovedInDjango18Warning, stacklevel=2)
conn.setdefault('AUTOCOMMIT', False)
conn.setdefault('AUTOCOMMIT', True)
conn.setdefault('ENGINE', 'django.db.backends.dummy')
@ -272,7 +273,7 @@ class ConnectionRouter(object):
warnings.warn(
'Router.allow_syncdb has been deprecated and will stop working in Django 1.9. '
'Rename the method to allow_migrate.',
PendingDeprecationWarning, stacklevel=2)
RemovedInDjango19Warning, stacklevel=2)
except AttributeError:
# If the router doesn't have a method, skip to the next one.
pass

View File

@ -25,6 +25,7 @@ from django.forms.widgets import (
from django.utils import formats
from django.utils.encoding import smart_text, force_str, force_text
from django.utils.ipv6 import clean_ipv6_address
from django.utils.deprecation import RemovedInDjango19Warning
from django.utils import six
from django.utils.six.moves.urllib.parse import urlsplit, urlunsplit
from django.utils.translation import ugettext_lazy as _, ungettext_lazy
@ -502,7 +503,7 @@ class DateTimeField(BaseTemporalField):
warnings.warn(
'Using SplitDateTimeWidget with DateTimeField is deprecated. '
'Use SplitDateTimeField instead.',
PendingDeprecationWarning, stacklevel=2)
RemovedInDjango19Warning, stacklevel=2)
if len(value) != 2:
raise ValidationError(self.error_messages['invalid'], code='invalid')
if value[0] in self.empty_values and value[1] in self.empty_values:
@ -1169,7 +1170,7 @@ class IPAddressField(CharField):
def __init__(self, *args, **kwargs):
warnings.warn("IPAddressField has been deprecated. Use GenericIPAddressField instead.",
PendingDeprecationWarning)
RemovedInDjango19Warning)
super(IPAddressField, self).__init__(*args, **kwargs)
def to_python(self, value):

View File

@ -12,8 +12,9 @@ from django.core.exceptions import ValidationError, NON_FIELD_ERRORS
from django.forms.fields import Field, FileField
from django.forms.utils import flatatt, ErrorDict, ErrorList
from django.forms.widgets import Media, MediaDefiningClass, TextInput, Textarea
from django.utils.html import conditional_escape, format_html
from django.utils.deprecation import RemovedInDjango18Warning, RemovedInDjango19Warning
from django.utils.encoding import smart_text, force_text, python_2_unicode_compatible
from django.utils.html import conditional_escape, format_html
from django.utils.safestring import mark_safe
from django.utils.translation import ugettext as _
from django.utils import six
@ -43,7 +44,7 @@ def get_declared_fields(bases, attrs, with_base_fields=True):
warnings.warn(
"get_declared_fields is deprecated and will be removed in Django 1.9.",
PendingDeprecationWarning,
RemovedInDjango19Warning,
stacklevel=2,
)
@ -431,7 +432,7 @@ class BaseForm(object):
if hasattr(field.widget, '_has_changed'):
warnings.warn("The _has_changed method on widgets is deprecated,"
" define it at field level instead.",
DeprecationWarning, stacklevel=2)
RemovedInDjango18Warning, stacklevel=2)
if field.widget._has_changed(initial_value, data_value):
self._changed_data.append(name)
elif field._has_changed(initial_value, data_value):

View File

@ -8,15 +8,17 @@ from __future__ import unicode_literals
from collections import OrderedDict
import warnings
from django.core.exceptions import ValidationError, NON_FIELD_ERRORS, FieldError
from django.core.exceptions import (
ValidationError, NON_FIELD_ERRORS, FieldError)
from django.forms.fields import Field, ChoiceField
from django.forms.forms import DeclarativeFieldsMetaclass, BaseForm
from django.forms.formsets import BaseFormSet, formset_factory
from django.forms.utils import ErrorList
from django.forms.widgets import (SelectMultiple, HiddenInput,
MultipleHiddenInput, CheckboxSelectMultiple)
from django.utils.encoding import smart_text, force_text
from django.utils import six
from django.utils.deprecation import RemovedInDjango18Warning
from django.utils.encoding import smart_text, force_text
from django.utils.text import get_text_list, capfirst
from django.utils.translation import ugettext_lazy as _, ugettext, string_concat
@ -269,7 +271,7 @@ class ModelFormMetaclass(DeclarativeFieldsMetaclass):
warnings.warn("Creating a ModelForm without either the 'fields' attribute "
"or the 'exclude' attribute is deprecated - form %s "
"needs updating" % name,
DeprecationWarning, stacklevel=2)
RemovedInDjango18Warning, stacklevel=2)
if opts.fields == ALL_FIELDS:
# Sentinel for fields_for_model to indicate "get the list of
@ -533,7 +535,7 @@ def modelform_factory(model, form=ModelForm, fields=None, exclude=None,
getattr(Meta, 'exclude', None) is None):
warnings.warn("Calling modelform_factory without defining 'fields' or "
"'exclude' explicitly is deprecated",
DeprecationWarning, stacklevel=2)
RemovedInDjango18Warning, stacklevel=2)
# Instatiate type(form) in order to use the same metaclass as form.
return type(form)(class_name, (form,), form_class_attrs)
@ -825,7 +827,7 @@ def modelformset_factory(model, form=ModelForm, formfield_callback=None,
getattr(meta, 'exclude', exclude) is None):
warnings.warn("Calling modelformset_factory without defining 'fields' or "
"'exclude' explicitly is deprecated",
DeprecationWarning, stacklevel=2)
RemovedInDjango18Warning, stacklevel=2)
form = modelform_factory(model, form=form, fields=fields, exclude=exclude,
formfield_callback=formfield_callback,

View File

@ -1,7 +1,9 @@
import warnings
from django.utils.deprecation import RemovedInDjango19Warning
warnings.warn(
"The django.forms.util module has been renamed. "
"Use django.forms.utils instead.", PendingDeprecationWarning)
"Use django.forms.utils instead.", RemovedInDjango19Warning)
from django.forms.utils import * # NOQA

View File

@ -10,8 +10,9 @@ except ImportError: # Python 2
from UserList import UserList
from django.conf import settings
from django.utils.html import format_html, format_html_join, escape
from django.utils.deprecation import RemovedInDjango18Warning
from django.utils.encoding import force_text, python_2_unicode_compatible
from django.utils.html import format_html, format_html_join, escape
from django.utils import timezone
from django.utils.translation import ugettext_lazy as _
from django.utils import six
@ -40,7 +41,7 @@ def flatatt(attrs):
'action': "be rendered as '%s'" % attr_name if value else "not be rendered",
'bool_value': value,
},
DeprecationWarning
RemovedInDjango18Warning
)
return format_html_join('', ' {0}="{1}"', sorted(attrs.items()))

View File

@ -11,9 +11,10 @@ import warnings
from django.conf import settings
from django.forms.utils import flatatt, to_current_timezone
from django.utils.datastructures import MultiValueDict, MergeDict
from django.utils.deprecation import RemovedInDjango18Warning
from django.utils.encoding import force_text, python_2_unicode_compatible
from django.utils.html import conditional_escape, format_html
from django.utils.translation import ugettext_lazy
from django.utils.encoding import force_text, python_2_unicode_compatible
from django.utils.safestring import mark_safe
from django.utils import formats, six
from django.utils.six.moves.urllib.parse import urljoin
@ -191,7 +192,7 @@ class Widget(six.with_metaclass(MediaDefiningClass)):
warnings.warn(
"`is_hidden` property is now read-only (and checks `input_type`). "
"Please update your code.",
DeprecationWarning, stacklevel=2
RemovedInDjango18Warning, stacklevel=2
)
def subwidgets(self, name, value, attrs=None, choices=()):
@ -636,7 +637,7 @@ class RadioChoiceInput(ChoiceInput):
class RadioInput(RadioChoiceInput):
def __init__(self, *args, **kwargs):
msg = "RadioInput has been deprecated. Use RadioChoiceInput instead."
warnings.warn(msg, DeprecationWarning, stacklevel=2)
warnings.warn(msg, RemovedInDjango18Warning, stacklevel=2)
super(RadioInput, self).__init__(*args, **kwargs)

View File

@ -48,6 +48,7 @@ import warnings
from django.conf import settings
from django.core.cache import caches, DEFAULT_CACHE_ALIAS
from django.utils.cache import get_cache_key, learn_cache_key, patch_response_headers, get_max_age
from django.utils.deprecation import RemovedInDjango18Warning
class UpdateCacheMiddleware(object):
@ -194,6 +195,6 @@ class CacheMiddleware(UpdateCacheMiddleware, FetchFromCacheMiddleware):
if self.cache_anonymous_only:
msg = "CACHE_MIDDLEWARE_ANONYMOUS_ONLY has been deprecated and will be removed in Django 1.8."
warnings.warn(msg, DeprecationWarning, stacklevel=1)
warnings.warn(msg, RemovedInDjango18Warning, stacklevel=1)
self.cache = caches[self.cache_alias]

View File

@ -7,6 +7,7 @@ from django.conf import settings
from django.core.mail import mail_managers
from django.core import urlresolvers
from django import http
from django.utils.deprecation import RemovedInDjango18Warning
from django.utils.encoding import force_text
from django.utils.http import urlquote
from django.utils import six
@ -110,7 +111,7 @@ class CommonMiddleware(object):
if settings.SEND_BROKEN_LINK_EMAILS:
warnings.warn("SEND_BROKEN_LINK_EMAILS is deprecated. "
"Use BrokenLinkEmailsMiddleware instead.",
DeprecationWarning, stacklevel=2)
RemovedInDjango18Warning, stacklevel=2)
BrokenLinkEmailsMiddleware().process_response(request, response)
if settings.USE_ETAGS:

View File

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

View File

@ -2,6 +2,7 @@ import warnings
from django.core.exceptions import MiddlewareNotUsed
from django.db import connection, transaction
from django.utils.deprecation import RemovedInDjango18Warning
class TransactionMiddleware(object):
@ -15,7 +16,7 @@ class TransactionMiddleware(object):
def __init__(self):
warnings.warn(
"TransactionMiddleware is deprecated in favor of ATOMIC_REQUESTS.",
DeprecationWarning, stacklevel=2)
RemovedInDjango18Warning, stacklevel=2)
if connection.settings_dict['ATOMIC_REQUESTS']:
raise MiddlewareNotUsed

View File

@ -17,6 +17,7 @@ from django.template.base import (Node, NodeList, Template, Context, Library,
render_value_in_context)
from django.template.smartif import IfParser, Literal
from django.template.defaultfilters import date
from django.utils.deprecation import RemovedInDjango18Warning
from django.utils.encoding import force_text, smart_text
from django.utils.safestring import mark_safe
from django.utils.html import format_html
@ -591,7 +592,7 @@ def cycle(parser, token, escape=False):
"'The `cycle` template tag is changing to escape its arguments; "
"the non-autoescaping version is deprecated. Load it "
"from the `future` tag library to start using the new behavior.",
DeprecationWarning, stacklevel=2)
RemovedInDjango18Warning, stacklevel=2)
# 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
@ -739,7 +740,7 @@ def firstof(parser, token, escape=False):
"'The `firstof` template tag is changing to escape its arguments; "
"the non-autoescaping version is deprecated. Load it "
"from the `future` tag library to start using the new behavior.",
DeprecationWarning, stacklevel=2)
RemovedInDjango18Warning, stacklevel=2)
bits = token.split_contents()[1:]
if len(bits) < 1:

View File

@ -2,6 +2,7 @@ import warnings
from django.template import Library
from django.template import defaulttags
from django.utils.deprecation import RemovedInDjango19Warning
register = Library()
@ -11,7 +12,7 @@ def ssi(parser, token):
warnings.warn(
"Loading the `ssi` tag from the `future` library is deprecated and "
"will be removed in Django 1.9. Use the default `ssi` tag instead.",
PendingDeprecationWarning)
RemovedInDjango19Warning)
return defaulttags.ssi(parser, token)
@ -20,7 +21,7 @@ def url(parser, token):
warnings.warn(
"Loading the `url` tag from the `future` library is deprecated and "
"will be removed in Django 1.9. Use the default `url` tag instead.",
PendingDeprecationWarning)
RemovedInDjango19Warning)
return defaulttags.url(parser, token)

View File

@ -51,10 +51,12 @@ details.
"""
import warnings
from django.utils.deprecation import RemovedInDjango18Warning
warnings.warn(
"The django.test._doctest module is deprecated; "
"use the doctest module from the Python standard library instead.",
DeprecationWarning)
RemovedInDjango18Warning)
__docformat__ = 'reStructuredText en'
@ -2085,7 +2087,7 @@ class Tester:
warnings.warn("class Tester is deprecated; "
"use class doctest.DocTestRunner instead",
DeprecationWarning, stacklevel=2)
RemovedInDjango18Warning, stacklevel=2)
if mod is None and globs is None:
raise TypeError("Tester.__init__: must specify mod or globs")
if mod is not None and not inspect.ismodule(mod):

View File

@ -16,6 +16,7 @@ from django.test.utils import compare_xml, strip_quotes
# django.utils.unittest is deprecated, but so is django.test.simple,
# and the latter will be removed before the former.
from django.utils import unittest
from django.utils.deprecation import RemovedInDjango18Warning
from django.utils.module_loading import module_has_submodule
__all__ = ('DjangoTestSuiteRunner',)
@ -23,7 +24,7 @@ __all__ = ('DjangoTestSuiteRunner',)
warnings.warn(
"The django.test.simple module and DjangoTestSuiteRunner are deprecated; "
"use django.test.runner.DiscoverRunner instead.",
DeprecationWarning)
RemovedInDjango18Warning)
# The module name for tests outside models.py
TEST_MODULE = 'tests'

View File

@ -17,8 +17,9 @@ from django.http import request
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.encoding import force_str
from django.utils import six
from django.utils.deprecation import RemovedInDjango18Warning, RemovedInDjango19Warning
from django.utils.encoding import force_str
from django.utils.translation import deactivate
@ -457,8 +458,7 @@ class CaptureQueriesContext(object):
class IgnoreDeprecationWarningsMixin(object):
warning_classes = [DeprecationWarning]
warning_classes = [RemovedInDjango18Warning]
def setUp(self):
super(IgnoreDeprecationWarningsMixin, self).setUp()
@ -473,13 +473,11 @@ class IgnoreDeprecationWarningsMixin(object):
class IgnorePendingDeprecationWarningsMixin(IgnoreDeprecationWarningsMixin):
warning_classes = [PendingDeprecationWarning]
warning_classes = [RemovedInDjango19Warning]
class IgnoreAllDeprecationWarningsMixin(IgnoreDeprecationWarningsMixin):
warning_classes = [PendingDeprecationWarning, DeprecationWarning]
warning_classes = [RemovedInDjango19Warning, RemovedInDjango18Warning]
@contextmanager

View File

@ -1,7 +1,9 @@
import copy
import warnings
from collections import OrderedDict
from django.utils import six
from django.utils.deprecation import RemovedInDjango19Warning
class MergeDict(object):
@ -14,7 +16,7 @@ class MergeDict(object):
"""
def __init__(self, *dicts):
warnings.warn('`MergeDict` is deprecated, use `dict.update()` '
'instead.', PendingDeprecationWarning, 2)
'instead.', RemovedInDjango19Warning, 2)
self.dicts = dicts
def __bool__(self):
@ -131,7 +133,7 @@ class SortedDict(dict):
def __init__(self, data=None):
warnings.warn(
"SortedDict is deprecated and will be removed in Django 1.9.",
PendingDeprecationWarning, stacklevel=2
RemovedInDjango19Warning, stacklevel=2
)
if data is None or isinstance(data, dict):
data = data or []

View File

@ -2,6 +2,14 @@ import inspect
import warnings
class RemovedInDjango19Warning(PendingDeprecationWarning):
pass
class RemovedInDjango18Warning(DeprecationWarning):
pass
class warn_about_renamed_method(object):
def __init__(self, class_name, old_method_name, new_method_name, deprecation_warning):
self.class_name = class_name

View File

@ -1,7 +1,9 @@
import warnings
from django.utils.deprecation import RemovedInDjango19Warning
warnings.warn("django.utils.dictconfig will be removed in Django 1.9.",
PendingDeprecationWarning, stacklevel=2)
RemovedInDjango19Warning, stacklevel=2)
# This is a copy of the Python logging.config.dictconfig module,
# reproduced with permission. It is provided here for backwards

View File

@ -5,6 +5,7 @@ import sys
import warnings
from django.utils import six
from django.utils.deprecation import RemovedInDjango19Warning
from django.utils.six.moves import copyreg
@ -27,7 +28,7 @@ def memoize(func, cache, num_args):
"""
warnings.warn("memoize wrapper is deprecated and will be removed in "
"Django 1.9. Use django.utils.lru_cache instead.",
PendingDeprecationWarning, stacklevel=2)
RemovedInDjango19Warning, stacklevel=2)
@wraps(func)
def wrapper(*args):

View File

@ -5,9 +5,10 @@ from __future__ import unicode_literals
import re
import warnings
from django.utils.safestring import SafeData, mark_safe
from django.utils.deprecation import RemovedInDjango18Warning
from django.utils.encoding import force_text, force_str
from django.utils.functional import allow_lazy
from django.utils.safestring import SafeData, mark_safe
from django.utils import six
from django.utils.six.moves.urllib.parse import quote, unquote, urlsplit, urlunsplit
from django.utils.text import normalize_newlines
@ -177,7 +178,7 @@ def fix_ampersands(value):
"""Returns the given HTML with all unencoded ampersands encoded correctly."""
# As fix_ampersands is wrapped in allow_lazy, stacklevel 3 is more useful than 2.
warnings.warn("The fix_ampersands function is deprecated and will be removed in Django 1.8.",
DeprecationWarning, stacklevel=3)
RemovedInDjango18Warning, stacklevel=3)
return unencoded_ampersands_re.sub('&amp;', force_text(value))
fix_ampersands = allow_lazy(fix_ampersands, six.text_type)
@ -296,7 +297,7 @@ def clean_html(text):
"""
# As clean_html is wrapped in allow_lazy, stacklevel 3 is more useful than 2.
warnings.warn("The clean_html function is deprecated and will be removed in Django 1.8.",
DeprecationWarning, stacklevel=3)
RemovedInDjango18Warning, stacklevel=3)
text = normalize_newlines(text)
text = re.sub(r'<(/?)\s*b\s*>', '<\\1strong>', text)
text = re.sub(r'<(/?)\s*i\s*>', '<\\1em>', text)

View File

@ -75,6 +75,7 @@ from __future__ import unicode_literals
import warnings
from django.core.exceptions import ImproperlyConfigured
from django.utils.deprecation import RemovedInDjango18Warning
from django.utils.translation import ugettext_lazy as _
@ -147,7 +148,7 @@ def _detect_image_library():
warnings.warn(
"Support for the PIL will be removed in Django 1.8. Please " +
"uninstall it & install Pillow instead.",
DeprecationWarning
RemovedInDjango18Warning
)
return PILImage, PIL_imaging, PILImageFile

View File

@ -3,9 +3,11 @@ import warnings
import sys
from django.utils import six
from django.utils.deprecation import RemovedInDjango19Warning
warnings.warn("django.utils.importlib will be removed in Django 1.9.",
PendingDeprecationWarning, stacklevel=2)
RemovedInDjango19Warning, stacklevel=2)
def _resolve_name(name, package, level):

View File

@ -9,6 +9,7 @@ import warnings
from django.core.exceptions import ImproperlyConfigured
from django.utils import six
from django.utils.deprecation import RemovedInDjango19Warning
def import_string(dotted_path):
@ -39,7 +40,7 @@ def import_by_path(dotted_path, error_prefix=''):
"""
warnings.warn(
'import_by_path() has been deprecated. Use import_string() instead.',
PendingDeprecationWarning, stacklevel=2)
RemovedInDjango19Warning, stacklevel=2)
try:
attr = import_string(dotted_path)
except ImportError as e:

View File

@ -6,6 +6,7 @@ from gzip import GzipFile
from io import BytesIO
import warnings
from django.utils.deprecation import RemovedInDjango19Warning
from django.utils.encoding import force_text
from django.utils.functional import allow_lazy, SimpleLazyObject
from django.utils import six
@ -332,7 +333,7 @@ def javascript_quote(s, quote_double_quotes=False):
"django.utils.text.javascript_quote() is deprecated. "
"Use django.utils.html.escapejs() instead."
)
warnings.warn(msg, PendingDeprecationWarning, stacklevel=2)
warnings.warn(msg, RemovedInDjango19Warning, stacklevel=2)
def fix(match):
return "\\u%04x" % ord(match.group(1))

View File

@ -12,6 +12,7 @@ import warnings
from django.apps import apps
from django.dispatch import receiver
from django.test.signals import setting_changed
from django.utils.deprecation import RemovedInDjango19Warning
from django.utils.encoding import force_str, force_text
from django.utils._os import upath
from django.utils.safestring import mark_safe, SafeData
@ -213,7 +214,7 @@ def activate(language):
msg = ("The use of the language code '%s' is deprecated. "
"Please use the '%s' translation instead.")
warnings.warn(msg % (language, _DJANGO_DEPRECATED_LOCALES[language]),
PendingDeprecationWarning, stacklevel=2)
RemovedInDjango19Warning, stacklevel=2)
_active.value = translation(language)

View File

@ -6,12 +6,13 @@ from datetime import timedelta, tzinfo
import time
import warnings
from django.utils.deprecation import RemovedInDjango19Warning
from django.utils.encoding import force_str, force_text, DEFAULT_LOCALE_ENCODING
warnings.warn(
"django.utils.tzinfo will be removed in Django 1.9. "
"Use django.utils.timezone instead.",
PendingDeprecationWarning)
RemovedInDjango19Warning)
# Python's doc say: "A tzinfo subclass must have an __init__() method that can
@ -25,7 +26,7 @@ class FixedOffset(tzinfo):
warnings.warn(
"django.utils.tzinfo.FixedOffset will be removed in Django 1.9. "
"Use django.utils.timezone.get_fixed_timezone instead.",
PendingDeprecationWarning)
RemovedInDjango19Warning)
if isinstance(offset, timedelta):
self.__offset = offset
offset = self.__offset.seconds // 60
@ -63,7 +64,7 @@ class LocalTimezone(tzinfo):
warnings.warn(
"django.utils.tzinfo.LocalTimezone will be removed in Django 1.9. "
"Use django.utils.timezone.get_default_timezone instead.",
PendingDeprecationWarning)
RemovedInDjango19Warning)
tzinfo.__init__(self)
self.__dt = dt
self._tzname = self.tzname(dt)

View File

@ -2,8 +2,10 @@ from __future__ import absolute_import
import warnings
from django.utils.deprecation import RemovedInDjango19Warning
warnings.warn("django.utils.unittest will be removed in Django 1.9.",
PendingDeprecationWarning, stacklevel=2)
RemovedInDjango19Warning, stacklevel=2)
try:
from unittest2 import *

View File

@ -3,6 +3,7 @@ import warnings
from django import http
from django.template import (Context, RequestContext,
loader, Template, TemplateDoesNotExist)
from django.utils.deprecation import RemovedInDjango18Warning
from django.views.decorators.csrf import requires_csrf_token
@ -86,6 +87,6 @@ def shortcut(request, content_type_id, object_id):
warnings.warn(
"django.views.defaults.shortcut will be removed in Django 1.8. "
"Import it from django.contrib.contenttypes.views instead.",
DeprecationWarning, stacklevel=2)
RemovedInDjango18Warning, stacklevel=2)
from django.contrib.contenttypes.views import shortcut as real_shortcut
return real_shortcut(request, content_type_id, object_id)

View File

@ -1,8 +1,9 @@
import warnings
from django.forms import models as model_forms
from django.core.exceptions import ImproperlyConfigured
from django.forms import models as model_forms
from django.http import HttpResponseRedirect
from django.utils.deprecation import RemovedInDjango18Warning
from django.utils.encoding import force_text
from django.views.generic.base import TemplateResponseMixin, ContextMixin, View
from django.views.generic.detail import (SingleObjectMixin,
@ -113,7 +114,7 @@ class ModelFormMixin(FormMixin, SingleObjectMixin):
if self.fields is None:
warnings.warn("Using ModelFormMixin (base class of %s) without "
"the 'fields' attribute is deprecated." % self.__class__.__name__,
DeprecationWarning)
RemovedInDjango18Warning)
return model_forms.modelform_factory(model, fields=self.fields)

View File

@ -173,11 +173,12 @@ There are a couple reasons that code in Django might be deprecated:
As the :ref:`deprecation policy<internal-release-deprecation-policy>` describes,
the first release of Django that deprecates a feature (``A.B``) should raise a
``PendingDeprecationWarning`` when the deprecated feature is invoked. Assuming
``RemovedInDjangoXXWarning`` (where XX is the Django version where the feature
will be removed) when the deprecated feature is invoked. Assuming
we have a good test coverage, these warnings will be shown by the test suite
when :ref:`running it <running-unit-tests>` with warnings enabled:
``python -Wall runtests.py``. This is annoying and the output of the test suite
should remain clean. Thus, when adding a ``PendingDeprecationWarning`` you need
should remain clean. Thus, when adding a ``RemovedInDjangoXXWarning`` you need
to eliminate or silence any warnings generated when running the tests.
The first step is to remove any use of the deprecated behavior by Django itself.
@ -218,9 +219,8 @@ Finally, there are a couple of updates to Django's documentation to make:
under the ``A.B+2`` version describing what code will be removed.
Once you have completed these steps, you are finished with the deprecation.
In each minor release, all ``PendingDeprecationWarning``\s are promoted to
``DeprecationWarning``\s and any features marked with ``DeprecationWarning``
are removed.
In each minor release, all ``RemovedInDjangoXXWarning``\s matching the new
version are removed.
Javascript patches
------------------

View File

@ -58,18 +58,17 @@ security purposes, please see :doc:`our security policies <security>`.
``A.B+2``.
So, for example, if we decided to start the deprecation of a function in
Django 1.5:
Django 1.7:
* Django 1.5 will contain a backwards-compatible replica of the function which
will raise a ``PendingDeprecationWarning``. This warning is silent by
* Django 1.7 will contain a backwards-compatible replica of the function which
will raise a ``RemovedInDjango19Warning``. This warning is silent by
default; you can turn on display of these warnings with the ``-Wd`` option
of Python.
* Django 1.6 will contain the backwards-compatible replica, but the warning
will be promoted to a full-fledged ``DeprecationWarning``. This warning is
*loud* by default, and will likely be quite annoying.
* Django 1.8 will still contain the backwards-compatible replica. This
warning becomes *loud* by default, and will likely be quite annoying.
* Django 1.7 will remove the feature outright.
* Django 1.9 will remove the feature outright.
Micro release
Micro releases (1.5.1, 1.6.2, 1.6.1, etc.) will be issued as needed, often to

View File

@ -20,8 +20,9 @@ from django.template.defaultfilters import (
from django.test import TestCase
from django.utils import six
from django.utils import translation
from django.utils.safestring import SafeData
from django.utils.deprecation import RemovedInDjango18Warning
from django.utils.encoding import python_2_unicode_compatible
from django.utils.safestring import SafeData
class DefaultFiltersTests(TestCase):
@ -126,7 +127,7 @@ class DefaultFiltersTests(TestCase):
def test_fix_ampersands(self):
with warnings.catch_warnings():
warnings.simplefilter("ignore", DeprecationWarning)
warnings.simplefilter("ignore", RemovedInDjango18Warning)
self.assertEqual(fix_ampersands_filter('Jack & Jill & Jeroboam'),
'Jack &amp; Jill &amp; Jeroboam')

View File

@ -1,4 +1,5 @@
from __future__ import unicode_literals
import warnings
from django.test import SimpleTestCase, RequestFactory, override_settings

View File

@ -16,6 +16,7 @@ from django.forms import (
Textarea, TextInput, TimeInput,
)
from django.forms.widgets import RadioFieldRenderer
from django.utils.deprecation import RemovedInDjango19Warning
from django.utils.safestring import mark_safe
from django.utils import six
from django.utils.translation import activate, deactivate, override
@ -1094,7 +1095,7 @@ class WidgetTests(TestCase):
field = DateTimeField(widget=SplitDateTimeWidget, required=False)
with warnings.catch_warnings():
warnings.filterwarnings("ignore", category=PendingDeprecationWarning)
warnings.filterwarnings("ignore", category=RemovedInDjango19Warning)
form = SplitDateForm({'field': ''})
self.assertTrue(form.is_valid())
form = SplitDateForm({'field': ['', '']})
@ -1104,7 +1105,7 @@ class WidgetTests(TestCase):
field = DateTimeField(widget=SplitDateTimeWidget, required=True)
with warnings.catch_warnings():
warnings.filterwarnings("ignore", category=PendingDeprecationWarning)
warnings.filterwarnings("ignore", category=RemovedInDjango19Warning)
form = SplitDateRequiredForm({'field': ''})
self.assertFalse(form.is_valid())
form = SplitDateRequiredForm({'field': ['', '']})

View File

@ -8,6 +8,7 @@ from django.core.urlresolvers import reverse
from django import forms
from django.test import TestCase
from django.test.client import RequestFactory
from django.utils.deprecation import RemovedInDjango18Warning
from django.views.generic.base import View
from django.views.generic.edit import FormMixin, ModelFormMixin, CreateView
@ -152,7 +153,7 @@ class CreateViewTests(TestCase):
def test_create_view_all_fields(self):
with warnings.catch_warnings(record=True) as w:
warnings.simplefilter("always", DeprecationWarning)
warnings.simplefilter("always", RemovedInDjango18Warning)
class MyCreateView(CreateView):
model = Author
@ -165,7 +166,7 @@ class CreateViewTests(TestCase):
def test_create_view_without_explicit_fields(self):
with warnings.catch_warnings(record=True) as w:
warnings.simplefilter("always", DeprecationWarning)
warnings.simplefilter("always", RemovedInDjango18Warning)
class MyCreateView(CreateView):
model = Author
@ -176,7 +177,7 @@ class CreateViewTests(TestCase):
['name', 'slug'])
# but with a warning:
self.assertEqual(w[0].category, DeprecationWarning)
self.assertEqual(w[0].category, RemovedInDjango18Warning)
class UpdateViewTests(TestCase):

View File

@ -18,6 +18,7 @@ from django.http import (QueryDict, HttpResponse, HttpResponseRedirect,
SimpleCookie, BadHeaderError, JsonResponse,
parse_cookie)
from django.test import TestCase
from django.utils.deprecation import RemovedInDjango18Warning
from django.utils.encoding import smart_str, force_text
from django.utils.functional import lazy
from django.utils._os import upath
@ -561,7 +562,7 @@ class FileCloseTests(TestCase):
r = HttpResponse(file1)
self.assertFalse(file1.closed)
with warnings.catch_warnings():
warnings.simplefilter("ignore", DeprecationWarning)
warnings.simplefilter("ignore", RemovedInDjango18Warning)
list(r)
self.assertFalse(file1.closed)
r.close()

View File

@ -21,6 +21,7 @@ from django.middleware.transaction import TransactionMiddleware
from django.test import TransactionTestCase, TestCase, RequestFactory, override_settings
from django.test.utils import IgnoreDeprecationWarningsMixin
from django.utils import six
from django.utils.deprecation import RemovedInDjango18Warning
from django.utils.encoding import force_str
from django.utils.six.moves import xrange
@ -249,7 +250,7 @@ class CommonMiddlewareTest(TestCase):
request = self._get_request('regular_url/that/does/not/exist')
request.META['HTTP_REFERER'] = '/another/url/'
with warnings.catch_warnings():
warnings.simplefilter("ignore", DeprecationWarning)
warnings.simplefilter("ignore", RemovedInDjango18Warning)
response = self.client.get(request.path)
CommonMiddleware().process_response(request, response)
self.assertEqual(len(mail.outbox), 1)
@ -261,7 +262,7 @@ class CommonMiddlewareTest(TestCase):
def test_404_error_reporting_no_referer(self):
request = self._get_request('regular_url/that/does/not/exist')
with warnings.catch_warnings():
warnings.simplefilter("ignore", DeprecationWarning)
warnings.simplefilter("ignore", RemovedInDjango18Warning)
response = self.client.get(request.path)
CommonMiddleware().process_response(request, response)
self.assertEqual(len(mail.outbox), 0)
@ -273,7 +274,7 @@ class CommonMiddlewareTest(TestCase):
request = self._get_request('foo_url/that/does/not/exist/either')
request.META['HTTP_REFERER'] = '/another/url/'
with warnings.catch_warnings():
warnings.simplefilter("ignore", DeprecationWarning)
warnings.simplefilter("ignore", RemovedInDjango18Warning)
response = self.client.get(request.path)
CommonMiddleware().process_response(request, response)
self.assertEqual(len(mail.outbox), 0)

View File

@ -13,8 +13,9 @@ from django.core.validators import ValidationError
from django.db import connection
from django.db.models.query import EmptyQuerySet
from django.forms.models import model_to_dict
from django.utils._os import upath
from django.test import TestCase, skipUnlessDBFeature
from django.utils.deprecation import RemovedInDjango18Warning
from django.utils._os import upath
from django.utils import six
from .models import (Article, ArticleStatus, BetterWriter, BigInt, Book,
@ -265,7 +266,7 @@ class ModelFormBaseTest(TestCase):
def test_missing_fields_attribute(self):
with warnings.catch_warnings(record=True):
warnings.simplefilter("always", DeprecationWarning)
warnings.simplefilter("always", RemovedInDjango18Warning)
class MissingFieldsForm(forms.ModelForm):
class Meta:
@ -275,7 +276,7 @@ class ModelFormBaseTest(TestCase):
# if a warning has been seen already, the catch_warnings won't
# have recorded it. The following line therefore will not work reliably:
# self.assertEqual(w[0].category, DeprecationWarning)
# self.assertEqual(w[0].category, RemovedInDjango18Warning)
# Until end of the deprecation cycle, should still create the
# form as before:

View File

@ -9,8 +9,9 @@ from django.core.exceptions import FieldError, ValidationError
from django.core.files.uploadedfile import SimpleUploadedFile
from django.forms.models import (modelform_factory, ModelChoiceField,
fields_for_model, construct_instance, ModelFormMetaclass)
from django.utils import six
from django.test import TestCase
from django.utils import six
from django.utils.deprecation import RemovedInDjango18Warning
from .models import (Person, RealPerson, Triple, FilePathModel, Article,
Publication, CustomFF, Author, Author1, Homepage, Document, Edition)
@ -593,10 +594,10 @@ class CustomMetaclassTestCase(TestCase):
class TestTicket19733(TestCase):
def test_modelform_factory_without_fields(self):
with warnings.catch_warnings(record=True) as w:
warnings.simplefilter("always", DeprecationWarning)
warnings.simplefilter("always", RemovedInDjango18Warning)
# This should become an error once deprecation cycle is complete.
modelform_factory(Person)
self.assertEqual(w[0].category, DeprecationWarning)
self.assertEqual(w[0].category, RemovedInDjango18Warning)
def test_modelform_factory_with_all_fields(self):
form = modelform_factory(Person, fields="__all__")

View File

@ -16,6 +16,7 @@ from django.core.exceptions import ImproperlyConfigured
from django.forms.models import BaseModelFormSet
from django.forms.widgets import Select
from django.test import TestCase
from django.utils.deprecation import RemovedInDjango19Warning
from .models import Band, Concert, ValidationTestModel, ValidationTestInlineModel
@ -1479,7 +1480,7 @@ class CustomModelAdminTests(CheckTestCase):
def test_deprecation(self):
"Deprecated Custom Validator definitions still work with the check framework."
with warnings.catch_warnings():
warnings.simplefilter("ignore", category=PendingDeprecationWarning)
warnings.simplefilter("ignore", category=RemovedInDjango19Warning)
class CustomValidator(ModelAdminValidator):
def validate_me(self, model_admin, model):

View File

@ -11,9 +11,14 @@ import warnings
import django
from django import contrib
from django.utils.deprecation import RemovedInDjango18Warning, RemovedInDjango19Warning
from django.utils._os import upath
from django.utils import six
warnings.simplefilter("default", RemovedInDjango19Warning)
warnings.simplefilter("default", RemovedInDjango18Warning)
CONTRIB_MODULE_PATH = 'django.contrib'
TEST_TEMPLATE_DIR = 'templates'
@ -124,12 +129,12 @@ def setup(verbosity, test_labels):
warnings.filterwarnings(
'ignore',
'django.contrib.comments is deprecated and will be removed before Django 1.8.',
DeprecationWarning
RemovedInDjango18Warning
)
warnings.filterwarnings(
'ignore',
'Model class django.contrib.comments.models.* Django 1.9.',
PendingDeprecationWarning
RemovedInDjango19Warning
)
# Load all the ALWAYS_INSTALLED_APPS.
django.setup()
@ -216,7 +221,7 @@ def django_tests(verbosity, interactive, failfast, test_labels):
'ignore',
"Custom SQL location '<app_label>/models/sql' is deprecated, "
"use '<app_label>/sql' instead.",
PendingDeprecationWarning
RemovedInDjango19Warning
)
failures = test_runner.run_tests(
test_labels or get_installed(), extra_tests=extra_tests)

View File

@ -23,6 +23,7 @@ from django.template.loaders import app_directories, filesystem, cached
from django.test import RequestFactory, TestCase
from django.test.utils import (setup_test_template_loader,
restore_template_loaders, override_settings, extend_sys_path)
from django.utils.deprecation import RemovedInDjango18Warning, RemovedInDjango19Warning
from django.utils.encoding import python_2_unicode_compatible
from django.utils.formats import date_format
from django.utils._os import upath
@ -599,9 +600,9 @@ class TemplateTests(TestCase):
try:
with warnings.catch_warnings():
# Ignore deprecations of the old syntax of the 'cycle' and 'firstof' tags.
warnings.filterwarnings("ignore", category=DeprecationWarning, module='django.template.base')
warnings.filterwarnings("ignore", category=RemovedInDjango18Warning, module='django.template.base')
# Ignore pending deprecations of loading 'ssi' and 'url' tags from future.
warnings.filterwarnings("ignore", category=PendingDeprecationWarning, module='django.templatetags.future')
warnings.filterwarnings("ignore", category=RemovedInDjango19Warning, module='django.templatetags.future')
test_template = loader.get_template(name)
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))

View File

@ -8,6 +8,7 @@ import warnings
from django.utils import html, safestring
from django.utils._os import upath
from django.utils.deprecation import RemovedInDjango18Warning
from django.utils.encoding import force_text
@ -132,7 +133,7 @@ class TestUtilsHtml(TestCase):
def test_fix_ampersands(self):
with warnings.catch_warnings():
warnings.simplefilter("ignore", DeprecationWarning)
warnings.simplefilter("ignore", RemovedInDjango18Warning)
f = html.fix_ampersands
# Strings without ampersands or with ampersands already encoded.
values = ("a&#1;", "b", "&a;", "&amp; &x; ", "asdf")
@ -177,7 +178,7 @@ class TestUtilsHtml(TestCase):
('<p>* foo</p><p>* bar</p>', '<ul>\n<li> foo</li><li> bar</li>\n</ul>'),
)
with warnings.catch_warnings():
warnings.simplefilter("ignore", DeprecationWarning)
warnings.simplefilter("ignore", RemovedInDjango18Warning)
for value, output in items:
self.check_output(f, value, output)

View File

@ -10,6 +10,7 @@ from django.core.exceptions import ImproperlyConfigured
from django.test import SimpleTestCase, modify_settings
from django.test.utils import IgnorePendingDeprecationWarningsMixin, 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,
module_has_submodule)
from django.utils._os import upath
@ -134,11 +135,11 @@ class ModuleImportTestCase(IgnorePendingDeprecationWarningsMixin, unittest.TestC
def test_import_by_path_pending_deprecation_warning(self):
with warnings.catch_warnings(record=True) as w:
warnings.simplefilter('always', category=PendingDeprecationWarning)
warnings.simplefilter('always', category=RemovedInDjango19Warning)
cls = import_by_path('django.utils.module_loading.import_by_path')
self.assertEqual(cls, import_by_path)
self.assertEqual(len(w), 1)
self.assertTrue(issubclass(w[-1].category, PendingDeprecationWarning))
self.assertTrue(issubclass(w[-1].category, RemovedInDjango19Warning))
self.assertIn('deprecated', str(w[-1].message))
def test_import_string(self):

View File

@ -6,6 +6,7 @@ import warnings
from django.test import SimpleTestCase
from django.utils import six, text
from django.utils.deprecation import RemovedInDjango19Warning
IS_WIDE_BUILD = (len('\U0001F4A9') == 1)
@ -154,7 +155,7 @@ class TestUtilsText(SimpleTestCase):
input = "<script>alert('Hello \\xff.\n Welcome\there\r');</script>"
output = r"<script>alert(\'Hello \\xff.\n Welcome\there\r\');<\/script>"
with warnings.catch_warnings():
warnings.simplefilter("ignore", PendingDeprecationWarning)
warnings.simplefilter("ignore", RemovedInDjango19Warning)
self.assertEqual(text.javascript_quote(input), output)
# Exercising quote_double_quotes keyword argument
@ -168,7 +169,7 @@ class TestUtilsText(SimpleTestCase):
input = "<script>alert('Hello \\xff.\n Wel𝕃come\there\r');</script>"
output = r"<script>alert(\'Hello \\xff.\n Wel𝕃come\there\r\');<\/script>"
with warnings.catch_warnings():
warnings.simplefilter("ignore", PendingDeprecationWarning)
warnings.simplefilter("ignore", RemovedInDjango19Warning)
self.assertEqual(text.javascript_quote(input), output)
def test_deprecation(self):

View File

@ -7,10 +7,12 @@ import unittest
import warnings
from django.test.utils import IgnorePendingDeprecationWarningsMixin
from django.utils.deprecation import RemovedInDjango19Warning
# Swallow the import-time warning to test the deprecated implementation.
with warnings.catch_warnings():
warnings.filterwarnings("ignore", category=PendingDeprecationWarning)
warnings.filterwarnings("ignore", category=RemovedInDjango19Warning)
from django.utils.tzinfo import FixedOffset, LocalTimezone