Fixed #14436 -- Escalated 1.2 PendingDeprecationWarnings to DeprecationWarnings, and removed 1.1 deprecated code.

git-svn-id: http://code.djangoproject.com/svn/django/trunk@14138 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
Russell Keith-Magee 2010-10-11 12:20:07 +00:00
parent 5e5be2c44c
commit 1070c57b83
36 changed files with 98 additions and 146 deletions

View File

@ -456,81 +456,6 @@ class AdminSite(object):
context_instance=context_instance context_instance=context_instance
) )
def root(self, request, url):
"""
DEPRECATED. This function is the old way of handling URL resolution, and
is deprecated in favor of real URL resolution -- see ``get_urls()``.
This function still exists for backwards-compatibility; it will be
removed in Django 1.3.
"""
import warnings
warnings.warn(
"AdminSite.root() is deprecated; use include(admin.site.urls) instead.",
DeprecationWarning
)
#
# Again, remember that the following only exists for
# backwards-compatibility. Any new URLs, changes to existing URLs, or
# whatever need to be done up in get_urls(), above!
#
if request.method == 'GET' and not request.path.endswith('/'):
return http.HttpResponseRedirect(request.path + '/')
if settings.DEBUG:
self.check_dependencies()
# Figure out the admin base URL path and stash it for later use
self.root_path = re.sub(re.escape(url) + '$', '', request.path)
url = url.rstrip('/') # Trim trailing slash, if it exists.
# The 'logout' view doesn't require that the person is logged in.
if url == 'logout':
return self.logout(request)
# Check permission to continue or display login form.
if not self.has_permission(request):
return self.login(request)
if url == '':
return self.index(request)
elif url == 'password_change':
return self.password_change(request)
elif url == 'password_change/done':
return self.password_change_done(request)
elif url == 'jsi18n':
return self.i18n_javascript(request)
# URLs starting with 'r/' are for the "View on site" links.
elif url.startswith('r/'):
from django.contrib.contenttypes.views import shortcut
return shortcut(request, *url.split('/')[1:])
else:
if '/' in url:
return self.model_page(request, *url.split('/', 2))
else:
return self.app_index(request, url)
raise http.Http404('The requested admin page does not exist.')
def model_page(self, request, app_label, model_name, rest_of_url=None):
"""
DEPRECATED. This is the old way of handling a model view on the admin
site; the new views should use get_urls(), above.
"""
from django.db import models
model = models.get_model(app_label, model_name)
if model is None:
raise http.Http404("App %r, model %r, not found." % (app_label, model_name))
try:
admin_obj = self._registry[model]
except KeyError:
raise http.Http404("This model exists but has not been registered with the admin site.")
return admin_obj(request, rest_of_url)
model_page = never_cache(model_page)
# This global object represents the default admin site, for the common case. # This global object represents the default admin site, for the common case.
# You can instantiate AdminSite in your own code to create a custom admin site. # You can instantiate AdminSite in your own code to create a custom admin site.
site = AdminSite() site = AdminSite()

View File

@ -22,12 +22,12 @@ def load_backend(path):
raise ImproperlyConfigured('Module "%s" does not define a "%s" authentication backend' % (module, attr)) raise ImproperlyConfigured('Module "%s" does not define a "%s" authentication backend' % (module, attr))
if not hasattr(cls, "supports_object_permissions"): if not hasattr(cls, "supports_object_permissions"):
warn("Authentication backends without a `supports_object_permissions` attribute are deprecated. Please define it in %s." % cls, warn("Authentication backends without a `supports_object_permissions` attribute are deprecated. Please define it in %s." % cls,
PendingDeprecationWarning) DeprecationWarning)
cls.supports_object_permissions = False cls.supports_object_permissions = False
if not hasattr(cls, 'supports_anonymous_user'): if not hasattr(cls, 'supports_anonymous_user'):
warn("Authentication backends without a `supports_anonymous_user` attribute are deprecated. Please define it in %s." % cls, warn("Authentication backends without a `supports_anonymous_user` attribute are deprecated. Please define it in %s." % cls,
PendingDeprecationWarning) DeprecationWarning)
cls.supports_anonymous_user = False cls.supports_anonymous_user = False
return cls() return cls()

View File

@ -380,7 +380,7 @@ class User(models.Model):
import warnings import warnings
warnings.warn('The user messaging API is deprecated. Please update' warnings.warn('The user messaging API is deprecated. Please update'
' your code to use the new messages framework.', ' your code to use the new messages framework.',
category=PendingDeprecationWarning) category=DeprecationWarning)
return self._message_set return self._message_set
message_set = property(_get_message_set) message_set = property(_get_message_set)

View File

@ -1,3 +1,5 @@
import warnings
from django.conf import settings from django.conf import settings
from django.contrib.auth.models import User, Group, Permission, AnonymousUser from django.contrib.auth.models import User, Group, Permission, AnonymousUser
from django.contrib.contenttypes.models import ContentType from django.contrib.contenttypes.models import ContentType
@ -152,9 +154,13 @@ class RowlevelBackendTest(TestCase):
self.user1 = User.objects.create_user('test', 'test@example.com', 'test') self.user1 = User.objects.create_user('test', 'test@example.com', 'test')
self.user2 = User.objects.create_user('test2', 'test2@example.com', 'test') self.user2 = User.objects.create_user('test2', 'test2@example.com', 'test')
self.user3 = User.objects.create_user('test3', 'test3@example.com', 'test') self.user3 = User.objects.create_user('test3', 'test3@example.com', 'test')
warnings.filterwarnings('ignore', category=DeprecationWarning,
module='django.contrib.auth')
def tearDown(self): def tearDown(self):
settings.AUTHENTICATION_BACKENDS = self.curr_auth settings.AUTHENTICATION_BACKENDS = self.curr_auth
warnings.resetwarnings()
warnings.simplefilter('ignore', PendingDeprecationWarning)
def test_has_perm(self): def test_has_perm(self):
self.assertEqual(self.user1.has_perm('perm', TestObj()), False) self.assertEqual(self.user1.has_perm('perm', TestObj()), False)

View File

@ -3,5 +3,5 @@ from django.views.decorators.csrf import csrf_exempt, csrf_view_exempt, csrf_res
import warnings import warnings
warnings.warn("This import for CSRF functionality is deprecated. Please use django.middleware.csrf for the middleware and django.views.decorators.csrf for decorators.", warnings.warn("This import for CSRF functionality is deprecated. Please use django.middleware.csrf for the middleware and django.views.decorators.csrf for decorators.",
PendingDeprecationWarning DeprecationWarning
) )

View File

@ -13,7 +13,7 @@ def run_gis_tests(test_labels, verbosity=1, interactive=True, failfast=False, ex
import warnings import warnings
warnings.warn( warnings.warn(
'The run_gis_tests() test runner has been deprecated in favor of GeoDjangoTestSuiteRunner.', 'The run_gis_tests() test runner has been deprecated in favor of GeoDjangoTestSuiteRunner.',
PendingDeprecationWarning DeprecationWarning
) )
test_runner = GeoDjangoTestSuiteRunner(verbosity=verbosity, interactive=interactive, failfast=failfast) test_runner = GeoDjangoTestSuiteRunner(verbosity=verbosity, interactive=interactive, failfast=failfast)
return test_runner.run_tests(test_labels, extra_tests=extra_tests) return test_runner.run_tests(test_labels, extra_tests=extra_tests)

View File

@ -1,3 +1,5 @@
import warnings
from django import http from django import http
from django.test import TestCase from django.test import TestCase
from django.conf import settings from django.conf import settings
@ -49,6 +51,8 @@ class BaseTest(TestCase):
self._message_storage = settings.MESSAGE_STORAGE self._message_storage = settings.MESSAGE_STORAGE
settings.MESSAGE_STORAGE = '%s.%s' % (self.storage_class.__module__, settings.MESSAGE_STORAGE = '%s.%s' % (self.storage_class.__module__,
self.storage_class.__name__) self.storage_class.__name__)
warnings.filterwarnings('ignore', category=DeprecationWarning,
module='django.contrib.auth.models')
def tearDown(self): def tearDown(self):
for setting in self.restore_settings: for setting in self.restore_settings:
@ -59,6 +63,8 @@ class BaseTest(TestCase):
self._template_context_processors self._template_context_processors
settings.INSTALLED_APPS = self._installed_apps settings.INSTALLED_APPS = self._installed_apps
settings.MESSAGE_STORAGE = self._message_storage settings.MESSAGE_STORAGE = self._message_storage
warnings.resetwarnings()
warnings.simplefilter('ignore', PendingDeprecationWarning)
def restore_setting(self, setting): def restore_setting(self, setting):
if setting in self._remembered_settings: if setting in self._remembered_settings:

View File

@ -10,7 +10,7 @@ class Feed(views.Feed):
def __init__(self, slug, request): def __init__(self, slug, request):
warnings.warn('The syndication feeds.Feed class is deprecated. Please ' warnings.warn('The syndication feeds.Feed class is deprecated. Please '
'use the new class based view API.', 'use the new class based view API.',
category=PendingDeprecationWarning) category=DeprecationWarning)
self.slug = slug self.slug = slug
self.request = request self.request = request

View File

@ -191,7 +191,7 @@ def feed(request, url, feed_dict=None):
import warnings import warnings
warnings.warn('The syndication feed() view is deprecated. Please use the ' warnings.warn('The syndication feed() view is deprecated. Please use the '
'new class based view API.', 'new class based view API.',
category=PendingDeprecationWarning) category=DeprecationWarning)
if not feed_dict: if not feed_dict:
raise Http404("No feeds are registered.") raise Http404("No feeds are registered.")

View File

@ -10,7 +10,7 @@ try:
import warnings import warnings
warnings.warn( warnings.warn(
"Support for the 'cmemcache' library has been deprecated. Please use python-memcached instead.", "Support for the 'cmemcache' library has been deprecated. Please use python-memcached instead.",
PendingDeprecationWarning DeprecationWarning
) )
except ImportError: except ImportError:
try: try:

View File

@ -24,7 +24,7 @@ def auth(request):
"The context processor at `django.core.context_processors.auth` is " \ "The context processor at `django.core.context_processors.auth` is " \
"deprecated; use the path `django.contrib.auth.context_processors.auth` " \ "deprecated; use the path `django.contrib.auth.context_processors.auth` " \
"instead.", "instead.",
PendingDeprecationWarning DeprecationWarning
) )
from django.contrib.auth.context_processors import auth as auth_context_processor from django.contrib.auth.context_processors import auth as auth_context_processor
return auth_context_processor(request) return auth_context_processor(request)

View File

@ -106,6 +106,6 @@ class SMTPConnection(_SMTPConnection):
import warnings import warnings
warnings.warn( warnings.warn(
'mail.SMTPConnection is deprecated; use mail.get_connection() instead.', 'mail.SMTPConnection is deprecated; use mail.get_connection() instead.',
PendingDeprecationWarning DeprecationWarning
) )
super(SMTPConnection, self).__init__(*args, **kwds) super(SMTPConnection, self).__init__(*args, **kwds)

View File

@ -29,7 +29,7 @@ class Command(BaseCommand):
import warnings import warnings
warnings.warn( warnings.warn(
'Function-based test runners are deprecated. Test runners should be classes with a run_tests() method.', 'Function-based test runners are deprecated. Test runners should be classes with a run_tests() method.',
PendingDeprecationWarning DeprecationWarning
) )
failures = TestRunner(test_labels, verbosity=verbosity, interactive=interactive) failures = TestRunner(test_labels, verbosity=verbosity, interactive=interactive)
else: else:

View File

@ -15,7 +15,7 @@ if not settings.DATABASES:
import warnings import warnings
warnings.warn( warnings.warn(
"settings.DATABASE_* is deprecated; use settings.DATABASES instead.", "settings.DATABASE_* is deprecated; use settings.DATABASES instead.",
PendingDeprecationWarning DeprecationWarning
) )
settings.DATABASES[DEFAULT_DB_ALIAS] = { settings.DATABASES[DEFAULT_DB_ALIAS] = {
@ -44,7 +44,7 @@ for alias, database in settings.DATABASES.items():
"django.contrib.gis is now implemented as a full database backend. " "django.contrib.gis is now implemented as a full database backend. "
"Modify ENGINE in the %s database configuration to select " "Modify ENGINE in the %s database configuration to select "
"a backend from 'django.contrib.gis.db.backends'" % alias, "a backend from 'django.contrib.gis.db.backends'" % alias,
PendingDeprecationWarning DeprecationWarning
) )
if database['ENGINE'] == 'postgresql_psycopg2': if database['ENGINE'] == 'postgresql_psycopg2':
full_engine = 'django.contrib.gis.db.backends.postgis' full_engine = 'django.contrib.gis.db.backends.postgis'
@ -56,7 +56,7 @@ for alias, database in settings.DATABASES.items():
warnings.warn( warnings.warn(
"Short names for ENGINE in database configurations are deprecated. " "Short names for ENGINE in database configurations are deprecated. "
"Prepend %s.ENGINE with 'django.db.backends.'" % alias, "Prepend %s.ENGINE with 'django.db.backends.'" % alias,
PendingDeprecationWarning DeprecationWarning
) )
full_engine = "django.db.backends.%s" % database['ENGINE'] full_engine = "django.db.backends.%s" % database['ENGINE']
database['ENGINE'] = full_engine database['ENGINE'] = full_engine

View File

@ -140,7 +140,7 @@ class BaseDatabaseCreation(object):
import warnings import warnings
warnings.warn( warnings.warn(
'Database creation API for m2m tables has been deprecated. M2M models are now automatically generated', 'Database creation API for m2m tables has been deprecated. M2M models are now automatically generated',
PendingDeprecationWarning DeprecationWarning
) )
output = [] output = []
@ -154,7 +154,7 @@ class BaseDatabaseCreation(object):
import warnings import warnings
warnings.warn( warnings.warn(
'Database creation API for m2m tables has been deprecated. M2M models are now automatically generated', 'Database creation API for m2m tables has been deprecated. M2M models are now automatically generated',
PendingDeprecationWarning DeprecationWarning
) )
from django.db import models from django.db import models
@ -217,7 +217,7 @@ class BaseDatabaseCreation(object):
import warnings import warnings
warnings.warn( warnings.warn(
'Database creation API for m2m tables has been deprecated. M2M models are now automatically generated', 'Database creation API for m2m tables has been deprecated. M2M models are now automatically generated',
PendingDeprecationWarning DeprecationWarning
) )
from django.db import models from django.db import models
@ -322,7 +322,7 @@ class BaseDatabaseCreation(object):
import warnings import warnings
warnings.warn( warnings.warn(
'Database creation API for m2m tables has been deprecated. M2M models are now automatically generated', 'Database creation API for m2m tables has been deprecated. M2M models are now automatically generated',
PendingDeprecationWarning DeprecationWarning
) )
qn = self.connection.ops.quote_name qn = self.connection.ops.quote_name

View File

@ -105,7 +105,7 @@ class DatabaseWrapper(BaseDatabaseWrapper):
import warnings import warnings
warnings.warn( warnings.warn(
'The "postgresql" backend has been deprecated. Use "postgresql_psycopg2" instead.', 'The "postgresql" backend has been deprecated. Use "postgresql_psycopg2" instead.',
PendingDeprecationWarning DeprecationWarning
) )
self.features = DatabaseFeatures() self.features = DatabaseFeatures()

View File

@ -15,14 +15,14 @@ def call_with_connection(func):
if not updated: if not updated:
warn("A Field class whose %s method hasn't been updated to take a " warn("A Field class whose %s method hasn't been updated to take a "
"`connection` argument." % func.__name__, "`connection` argument." % func.__name__,
PendingDeprecationWarning, stacklevel=2) DeprecationWarning, stacklevel=2)
def inner(*args, **kwargs): def inner(*args, **kwargs):
if 'connection' not in kwargs: if 'connection' not in kwargs:
from django.db import connection from django.db import connection
kwargs['connection'] = connection kwargs['connection'] = connection
warn("%s has been called without providing a connection argument. " % warn("%s has been called without providing a connection argument. " %
func.__name__, PendingDeprecationWarning, func.__name__, DeprecationWarning,
stacklevel=1) stacklevel=1)
if updated: if updated:
return func(*args, **kwargs) return func(*args, **kwargs)
@ -40,14 +40,14 @@ def call_with_connection_and_prepared(func):
if not updated: if not updated:
warn("A Field class whose %s method hasn't been updated to take " warn("A Field class whose %s method hasn't been updated to take "
"`connection` and `prepared` arguments." % func.__name__, "`connection` and `prepared` arguments." % func.__name__,
PendingDeprecationWarning, stacklevel=2) DeprecationWarning, stacklevel=2)
def inner(*args, **kwargs): def inner(*args, **kwargs):
if 'connection' not in kwargs: if 'connection' not in kwargs:
from django.db import connection from django.db import connection
kwargs['connection'] = connection kwargs['connection'] = connection
warn("%s has been called without providing a connection argument. " % warn("%s has been called without providing a connection argument. " %
func.__name__, PendingDeprecationWarning, func.__name__, DeprecationWarning,
stacklevel=1) stacklevel=1)
if updated: if updated:
return func(*args, **kwargs) return func(*args, **kwargs)

View File

@ -23,7 +23,7 @@ def load_backend(backend_name):
import warnings import warnings
warnings.warn( warnings.warn(
"Short names for DATABASE_ENGINE are deprecated; prepend with 'django.db.backends.'", "Short names for DATABASE_ENGINE are deprecated; prepend with 'django.db.backends.'",
PendingDeprecationWarning DeprecationWarning
) )
return module return module
except ImportError, e: except ImportError, e:

View File

@ -50,7 +50,7 @@ def en_format(name):
from django.conf.locale.en import formats from django.conf.locale.en import formats
warnings.warn( warnings.warn(
"`django.forms.fields.DEFAULT_%s` is deprecated; use `django.utils.formats.get_format('%s')` instead." % (name, name), "`django.forms.fields.DEFAULT_%s` is deprecated; use `django.utils.formats.get_format('%s')` instead." % (name, name),
PendingDeprecationWarning DeprecationWarning
) )
return getattr(formats, name) return getattr(formats, name)

View File

@ -274,7 +274,7 @@ class CsrfResponseMiddleware(object):
import warnings import warnings
warnings.warn( warnings.warn(
"CsrfResponseMiddleware and CsrfMiddleware are deprecated; use CsrfViewMiddleware and the template tag instead (see CSRF documentation).", "CsrfResponseMiddleware and CsrfMiddleware are deprecated; use CsrfViewMiddleware and the template tag instead (see CSRF documentation).",
PendingDeprecationWarning DeprecationWarning
) )
def process_response(self, request, response): def process_response(self, request, response):

View File

@ -30,22 +30,3 @@ class ConditionalGetMiddleware(object):
response.status_code = 304 response.status_code = 304
return response return response
class SetRemoteAddrFromForwardedFor(object):
"""
This middleware has been removed; see the Django 1.1 release notes for
details.
It previously set REMOTE_ADDR based on HTTP_X_FORWARDED_FOR. However, after
investiagtion, it turns out this is impossible to do in a general manner:
different proxies treat the X-Forwarded-For header differently. Thus, a
built-in middleware can lead to application-level security problems, and so
this was removed in Django 1.1
"""
def __init__(self):
import warnings
warnings.warn("SetRemoteAddrFromForwardedFor has been removed. "
"See the Django 1.1 release notes for details.",
category=DeprecationWarning)
raise MiddlewareNotUsed()

View File

@ -142,7 +142,7 @@ def find_template_source(name, dirs=None):
import warnings import warnings
warnings.warn( warnings.warn(
"`django.template.loaders.find_template_source` is deprecated; use `django.template.loaders.find_template` instead.", "`django.template.loaders.find_template_source` is deprecated; use `django.template.loaders.find_template` instead.",
PendingDeprecationWarning DeprecationWarning
) )
template, origin = find_template(name, dirs) template, origin = find_template(name, dirs)
if hasattr(template, 'render'): if hasattr(template, 'render'):

View File

@ -68,7 +68,7 @@ def load_template_source(template_name, template_dirs=None):
import warnings import warnings
warnings.warn( warnings.warn(
"'django.template.loaders.app_directories.load_template_source' is deprecated; use 'django.template.loaders.app_directories.Loader' instead.", "'django.template.loaders.app_directories.load_template_source' is deprecated; use 'django.template.loaders.app_directories.Loader' instead.",
PendingDeprecationWarning DeprecationWarning
) )
return _loader.load_template_source(template_name, template_dirs) return _loader.load_template_source(template_name, template_dirs)
load_template_source.is_usable = True load_template_source.is_usable = True

View File

@ -33,7 +33,7 @@ def load_template_source(template_name, template_dirs=None):
import warnings import warnings
warnings.warn( warnings.warn(
"'django.template.loaders.eggs.load_template_source' is deprecated; use 'django.template.loaders.eggs.Loader' instead.", "'django.template.loaders.eggs.load_template_source' is deprecated; use 'django.template.loaders.eggs.Loader' instead.",
PendingDeprecationWarning DeprecationWarning
) )
return _loader.load_template_source(template_name, template_dirs) return _loader.load_template_source(template_name, template_dirs)
load_template_source.is_usable = resource_string is not None load_template_source.is_usable = resource_string is not None

View File

@ -55,7 +55,7 @@ def load_template_source(template_name, template_dirs=None):
import warnings import warnings
warnings.warn( warnings.warn(
"'django.template.loaders.filesystem.load_template_source' is deprecated; use 'django.template.loaders.filesystem.Loader' instead.", "'django.template.loaders.filesystem.load_template_source' is deprecated; use 'django.template.loaders.filesystem.Loader' instead.",
PendingDeprecationWarning DeprecationWarning
) )
return _loader.load_template_source(template_name, template_dirs) return _loader.load_template_source(template_name, template_dirs)
load_template_source.is_usable = True load_template_source.is_usable = True

View File

@ -320,7 +320,7 @@ def run_tests(test_labels, verbosity=1, interactive=True, failfast=False, extra_
import warnings import warnings
warnings.warn( warnings.warn(
'The run_tests() test runner has been deprecated in favor of DjangoTestSuiteRunner.', 'The run_tests() test runner has been deprecated in favor of DjangoTestSuiteRunner.',
PendingDeprecationWarning DeprecationWarning
) )
test_runner = DjangoTestSuiteRunner(verbosity=verbosity, interactive=interactive, failfast=failfast) test_runner = DjangoTestSuiteRunner(verbosity=verbosity, interactive=interactive, failfast=failfast)
return test_runner.run_tests(test_labels, extra_tests=extra_tests) return test_runner.run_tests(test_labels, extra_tests=extra_tests)

View File

@ -59,7 +59,7 @@ def get_date_formats():
warnings.warn( warnings.warn(
'`django.utils.translation.get_date_formats` is deprecated. ' '`django.utils.translation.get_date_formats` is deprecated. '
'Please update your code to use the new i18n aware formatting.', 'Please update your code to use the new i18n aware formatting.',
PendingDeprecationWarning DeprecationWarning
) )
return settings.DATE_FORMAT, settings.DATETIME_FORMAT, settings.TIME_FORMAT return settings.DATE_FORMAT, settings.DATETIME_FORMAT, settings.TIME_FORMAT
@ -67,6 +67,6 @@ def get_partial_date_formats():
warnings.warn( warnings.warn(
'`django.utils.translation.get_partial_date_formats` is deprecated. ' '`django.utils.translation.get_partial_date_formats` is deprecated. '
'Please update your code to use the new i18n aware formatting.', 'Please update your code to use the new i18n aware formatting.',
PendingDeprecationWarning DeprecationWarning
) )
return settings.YEAR_MONTH_FORMAT, settings.MONTH_DAY_FORMAT return settings.YEAR_MONTH_FORMAT, settings.MONTH_DAY_FORMAT

View File

@ -192,7 +192,7 @@ def activate(language):
warnings.warn( warnings.warn(
"The use of the language code 'no' is deprecated. " "The use of the language code 'no' is deprecated. "
"Please use the 'nb' translation instead.", "Please use the 'nb' translation instead.",
PendingDeprecationWarning DeprecationWarning
) )
_active[currentThread()] = translation(language) _active[currentThread()] = translation(language)
@ -517,7 +517,7 @@ def get_date_formats():
warnings.warn( warnings.warn(
"'django.utils.translation.get_date_formats' is deprecated. " "'django.utils.translation.get_date_formats' is deprecated. "
"Please update your code to use the new i18n aware formatting.", "Please update your code to use the new i18n aware formatting.",
PendingDeprecationWarning DeprecationWarning
) )
from django.conf import settings from django.conf import settings
date_format = ugettext('DATE_FORMAT') date_format = ugettext('DATE_FORMAT')
@ -540,7 +540,7 @@ def get_partial_date_formats():
warnings.warn( warnings.warn(
"'django.utils.translation.get_partial_date_formats' is deprecated. " "'django.utils.translation.get_partial_date_formats' is deprecated. "
"Please update your code to use the new i18n aware formatting.", "Please update your code to use the new i18n aware formatting.",
PendingDeprecationWarning DeprecationWarning
) )
from django.conf import settings from django.conf import settings
year_month_format = ugettext('YEAR_MONTH_FORMAT') year_month_format = ugettext('YEAR_MONTH_FORMAT')

View File

@ -40,14 +40,14 @@ class MyAutoField(models.CharField):
value = MyWrapper(value) value = MyWrapper(value)
return value return value
def get_db_prep_save(self, value): def get_db_prep_save(self, value, connection):
if not value: if not value:
return return
if isinstance(value, MyWrapper): if isinstance(value, MyWrapper):
return unicode(value) return unicode(value)
return value return value
def get_db_prep_value(self, value): def get_db_prep_value(self, value, connection, prepared=False):
if not value: if not value:
return return
if isinstance(value, MyWrapper): if isinstance(value, MyWrapper):

View File

@ -3,6 +3,8 @@ from django.db import models
from django.utils import simplejson as json from django.utils import simplejson as json
from django.utils.encoding import force_unicode from django.utils.encoding import force_unicode
import warnings
warnings.filterwarnings("ignore", category=DeprecationWarning, module='django.db.models.fields.subclassing')
class Small(object): class Small(object):
""" """

View File

@ -9,6 +9,7 @@
from decimal import Decimal from decimal import Decimal
from django.db import models from django.db import models
class Category(models.Model): class Category(models.Model):
name = models.CharField(max_length=20) name = models.CharField(max_length=20)
@ -96,7 +97,7 @@ class TeamField(models.CharField):
def __init__(self): def __init__(self):
super(TeamField, self).__init__(max_length=100) super(TeamField, self).__init__(max_length=100)
def get_db_prep_save(self, value): def get_db_prep_save(self, value, connection):
return unicode(value.title) return unicode(value.title)
def to_python(self, value): def to_python(self, value):

View File

@ -1,6 +1,7 @@
""" """
Tests for Django's bundled context processors. Tests for Django's bundled context processors.
""" """
import warnings
from django.conf import settings from django.conf import settings
from django.contrib.auth import authenticate from django.contrib.auth import authenticate
@ -46,6 +47,16 @@ class AuthContextProcessorTests(TestCase):
urls = 'regressiontests.context_processors.urls' urls = 'regressiontests.context_processors.urls'
fixtures = ['context-processors-users.xml'] fixtures = ['context-processors-users.xml']
def setUp(self):
warnings.filterwarnings('ignore', category=DeprecationWarning,
module='django.contrib.auth.models')
warnings.filterwarnings('ignore', category=DeprecationWarning,
module='django.core.context_processors')
def tearDown(self):
warnings.resetwarnings()
warnings.simplefilter('ignore', PendingDeprecationWarning)
def test_session_not_accessed(self): def test_session_not_accessed(self):
""" """
Tests that the session is not accessed simply by including Tests that the session is not accessed simply by including

View File

@ -1,4 +1,5 @@
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
import warnings
from django.test import TestCase from django.test import TestCase
from django.http import HttpRequest, HttpResponse from django.http import HttpRequest, HttpResponse
@ -69,6 +70,14 @@ class CsrfMiddlewareTest(TestCase):
_session_id = "1" _session_id = "1"
_secret_key_for_session_test= "test" _secret_key_for_session_test= "test"
def setUp(self):
warnings.filterwarnings('ignore', category=DeprecationWarning,
module='django.middleware.csrf')
def tearDown(self):
warnings.resetwarnings()
warnings.simplefilter('ignore', PendingDeprecationWarning)
def _get_GET_no_csrf_cookie_request(self): def _get_GET_no_csrf_cookie_request(self):
return TestingHttpRequest() return TestingHttpRequest()

View File

@ -1,16 +1,15 @@
import datetime import datetime
import warnings
from xml.dom import minidom
from django.contrib.syndication import feeds, views from django.contrib.syndication import feeds, views
from django.core.exceptions import ImproperlyConfigured from django.core.exceptions import ImproperlyConfigured
from django.test import TestCase from django.test import TestCase
from django.utils import tzinfo from django.utils import tzinfo
from django.utils.feedgenerator import rfc2822_date, rfc3339_date from django.utils.feedgenerator import rfc2822_date, rfc3339_date
from models import Entry
from xml.dom import minidom
try: from models import Entry
set
except NameError:
from sets import Set as set
class FeedTestCase(TestCase): class FeedTestCase(TestCase):
fixtures = ['feeddata.json'] fixtures = ['feeddata.json']
@ -315,6 +314,15 @@ class DeprecatedSyndicationFeedTest(FeedTestCase):
""" """
Tests for the deprecated API (feed() view and the feed_dict etc). Tests for the deprecated API (feed() view and the feed_dict etc).
""" """
def setUp(self):
warnings.filterwarnings('ignore', category=DeprecationWarning,
module='django.contrib.syndication.feeds')
warnings.filterwarnings('ignore', category=DeprecationWarning,
module='django.contrib.syndication.views')
def tearDown(self):
warnings.resetwarnings()
warnings.simplefilter('ignore', PendingDeprecationWarning)
def test_empty_feed_dict(self): def test_empty_feed_dict(self):
""" """

View File

@ -67,7 +67,8 @@ class DeprecatedEggLoaderTest(unittest.TestCase):
}) })
self._old_installed_apps = settings.INSTALLED_APPS self._old_installed_apps = settings.INSTALLED_APPS
settings.INSTALLED_APPS = [] settings.INSTALLED_APPS = []
warnings.simplefilter("ignore", PendingDeprecationWarning) warnings.filterwarnings("ignore", category=DeprecationWarning,
module='django.template.loaders.eggs')
def tearDown(self): def tearDown(self):
settings.INSTALLED_APPS = self._old_installed_apps settings.INSTALLED_APPS = self._old_installed_apps
@ -79,6 +80,8 @@ class DeprecatedEggLoaderTest(unittest.TestCase):
contents, template_name = lts_egg("y.html") contents, template_name = lts_egg("y.html")
self.assertEqual(contents, "y") self.assertEqual(contents, "y")
self.assertEqual(template_name, "egg:egg_1:templates/y.html") self.assertEqual(template_name, "egg:egg_1:templates/y.html")
warnings.resetwarnings()
warnings.simplefilter("ignore", PendingDeprecationWarning)
class EggLoaderTest(unittest.TestCase): class EggLoaderTest(unittest.TestCase):

View File

@ -174,7 +174,7 @@ def django_tests(verbosity, interactive, failfast, test_labels):
import warnings import warnings
warnings.warn( warnings.warn(
'Function-based test runners are deprecated. Test runners should be classes with a run_tests() method.', 'Function-based test runners are deprecated. Test runners should be classes with a run_tests() method.',
PendingDeprecationWarning DeprecationWarning
) )
failures = TestRunner(test_labels, verbosity=verbosity, interactive=interactive, failures = TestRunner(test_labels, verbosity=verbosity, interactive=interactive,
extra_tests=extra_tests) extra_tests=extra_tests)