mirror of https://github.com/django/django.git
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:
parent
5e5be2c44c
commit
1070c57b83
|
@ -456,81 +456,6 @@ class AdminSite(object):
|
|||
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.
|
||||
# You can instantiate AdminSite in your own code to create a custom admin site.
|
||||
site = AdminSite()
|
||||
|
|
|
@ -22,12 +22,12 @@ def load_backend(path):
|
|||
raise ImproperlyConfigured('Module "%s" does not define a "%s" authentication backend' % (module, attr))
|
||||
if not hasattr(cls, "supports_object_permissions"):
|
||||
warn("Authentication backends without a `supports_object_permissions` attribute are deprecated. Please define it in %s." % cls,
|
||||
PendingDeprecationWarning)
|
||||
DeprecationWarning)
|
||||
cls.supports_object_permissions = False
|
||||
|
||||
if not hasattr(cls, 'supports_anonymous_user'):
|
||||
warn("Authentication backends without a `supports_anonymous_user` attribute are deprecated. Please define it in %s." % cls,
|
||||
PendingDeprecationWarning)
|
||||
DeprecationWarning)
|
||||
cls.supports_anonymous_user = False
|
||||
return cls()
|
||||
|
||||
|
|
|
@ -107,7 +107,7 @@ class UserManager(models.Manager):
|
|||
Creates and saves a User with the given username, e-mail and password.
|
||||
"""
|
||||
now = datetime.datetime.now()
|
||||
|
||||
|
||||
# Normalize the address by lowercasing the domain part of the email
|
||||
# address.
|
||||
try:
|
||||
|
@ -380,7 +380,7 @@ class User(models.Model):
|
|||
import warnings
|
||||
warnings.warn('The user messaging API is deprecated. Please update'
|
||||
' your code to use the new messages framework.',
|
||||
category=PendingDeprecationWarning)
|
||||
category=DeprecationWarning)
|
||||
return self._message_set
|
||||
message_set = property(_get_message_set)
|
||||
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
import warnings
|
||||
|
||||
from django.conf import settings
|
||||
from django.contrib.auth.models import User, Group, Permission, AnonymousUser
|
||||
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.user2 = User.objects.create_user('test2', 'test2@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):
|
||||
settings.AUTHENTICATION_BACKENDS = self.curr_auth
|
||||
warnings.resetwarnings()
|
||||
warnings.simplefilter('ignore', PendingDeprecationWarning)
|
||||
|
||||
def test_has_perm(self):
|
||||
self.assertEqual(self.user1.has_perm('perm', TestObj()), False)
|
||||
|
|
|
@ -3,5 +3,5 @@ from django.views.decorators.csrf import csrf_exempt, csrf_view_exempt, csrf_res
|
|||
|
||||
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.",
|
||||
PendingDeprecationWarning
|
||||
DeprecationWarning
|
||||
)
|
||||
|
|
|
@ -13,7 +13,7 @@ def run_gis_tests(test_labels, verbosity=1, interactive=True, failfast=False, ex
|
|||
import warnings
|
||||
warnings.warn(
|
||||
'The run_gis_tests() test runner has been deprecated in favor of GeoDjangoTestSuiteRunner.',
|
||||
PendingDeprecationWarning
|
||||
DeprecationWarning
|
||||
)
|
||||
test_runner = GeoDjangoTestSuiteRunner(verbosity=verbosity, interactive=interactive, failfast=failfast)
|
||||
return test_runner.run_tests(test_labels, extra_tests=extra_tests)
|
||||
|
@ -22,7 +22,7 @@ class GeoDjangoTestSuiteRunner(DjangoTestSuiteRunner):
|
|||
|
||||
def setup_test_environment(self, **kwargs):
|
||||
super(GeoDjangoTestSuiteRunner, self).setup_test_environment(**kwargs)
|
||||
|
||||
|
||||
from django.db import connection
|
||||
from django.contrib.gis.geos import GEOS_PREPARE
|
||||
from django.contrib.gis.gdal import HAS_GDAL
|
||||
|
@ -49,7 +49,7 @@ class GeoDjangoTestSuiteRunner(DjangoTestSuiteRunner):
|
|||
|
||||
self.geo_apps.append('layermap')
|
||||
|
||||
# Constructing the new INSTALLED_APPS, and including applications
|
||||
# Constructing the new INSTALLED_APPS, and including applications
|
||||
# within the GeoDjango test namespace (`self.geo_apps`).
|
||||
new_installed = ['django.contrib.sites',
|
||||
'django.contrib.sitemaps',
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
import warnings
|
||||
|
||||
from django import http
|
||||
from django.test import TestCase
|
||||
from django.conf import settings
|
||||
|
@ -49,6 +51,8 @@ class BaseTest(TestCase):
|
|||
self._message_storage = settings.MESSAGE_STORAGE
|
||||
settings.MESSAGE_STORAGE = '%s.%s' % (self.storage_class.__module__,
|
||||
self.storage_class.__name__)
|
||||
warnings.filterwarnings('ignore', category=DeprecationWarning,
|
||||
module='django.contrib.auth.models')
|
||||
|
||||
def tearDown(self):
|
||||
for setting in self.restore_settings:
|
||||
|
@ -59,6 +63,8 @@ class BaseTest(TestCase):
|
|||
self._template_context_processors
|
||||
settings.INSTALLED_APPS = self._installed_apps
|
||||
settings.MESSAGE_STORAGE = self._message_storage
|
||||
warnings.resetwarnings()
|
||||
warnings.simplefilter('ignore', PendingDeprecationWarning)
|
||||
|
||||
def restore_setting(self, setting):
|
||||
if setting in self._remembered_settings:
|
||||
|
|
|
@ -10,7 +10,7 @@ class Feed(views.Feed):
|
|||
def __init__(self, slug, request):
|
||||
warnings.warn('The syndication feeds.Feed class is deprecated. Please '
|
||||
'use the new class based view API.',
|
||||
category=PendingDeprecationWarning)
|
||||
category=DeprecationWarning)
|
||||
|
||||
self.slug = slug
|
||||
self.request = request
|
||||
|
|
|
@ -191,7 +191,7 @@ def feed(request, url, feed_dict=None):
|
|||
import warnings
|
||||
warnings.warn('The syndication feed() view is deprecated. Please use the '
|
||||
'new class based view API.',
|
||||
category=PendingDeprecationWarning)
|
||||
category=DeprecationWarning)
|
||||
|
||||
if not feed_dict:
|
||||
raise Http404("No feeds are registered.")
|
||||
|
|
|
@ -10,7 +10,7 @@ try:
|
|||
import warnings
|
||||
warnings.warn(
|
||||
"Support for the 'cmemcache' library has been deprecated. Please use python-memcached instead.",
|
||||
PendingDeprecationWarning
|
||||
DeprecationWarning
|
||||
)
|
||||
except ImportError:
|
||||
try:
|
||||
|
|
|
@ -24,7 +24,7 @@ def auth(request):
|
|||
"The context processor at `django.core.context_processors.auth` is " \
|
||||
"deprecated; use the path `django.contrib.auth.context_processors.auth` " \
|
||||
"instead.",
|
||||
PendingDeprecationWarning
|
||||
DeprecationWarning
|
||||
)
|
||||
from django.contrib.auth.context_processors import auth as auth_context_processor
|
||||
return auth_context_processor(request)
|
||||
|
|
|
@ -106,6 +106,6 @@ class SMTPConnection(_SMTPConnection):
|
|||
import warnings
|
||||
warnings.warn(
|
||||
'mail.SMTPConnection is deprecated; use mail.get_connection() instead.',
|
||||
PendingDeprecationWarning
|
||||
DeprecationWarning
|
||||
)
|
||||
super(SMTPConnection, self).__init__(*args, **kwds)
|
||||
|
|
|
@ -29,7 +29,7 @@ class Command(BaseCommand):
|
|||
import warnings
|
||||
warnings.warn(
|
||||
'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)
|
||||
else:
|
||||
|
|
|
@ -15,7 +15,7 @@ if not settings.DATABASES:
|
|||
import warnings
|
||||
warnings.warn(
|
||||
"settings.DATABASE_* is deprecated; use settings.DATABASES instead.",
|
||||
PendingDeprecationWarning
|
||||
DeprecationWarning
|
||||
)
|
||||
|
||||
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. "
|
||||
"Modify ENGINE in the %s database configuration to select "
|
||||
"a backend from 'django.contrib.gis.db.backends'" % alias,
|
||||
PendingDeprecationWarning
|
||||
DeprecationWarning
|
||||
)
|
||||
if database['ENGINE'] == 'postgresql_psycopg2':
|
||||
full_engine = 'django.contrib.gis.db.backends.postgis'
|
||||
|
@ -56,7 +56,7 @@ for alias, database in settings.DATABASES.items():
|
|||
warnings.warn(
|
||||
"Short names for ENGINE in database configurations are deprecated. "
|
||||
"Prepend %s.ENGINE with 'django.db.backends.'" % alias,
|
||||
PendingDeprecationWarning
|
||||
DeprecationWarning
|
||||
)
|
||||
full_engine = "django.db.backends.%s" % database['ENGINE']
|
||||
database['ENGINE'] = full_engine
|
||||
|
|
|
@ -140,7 +140,7 @@ class BaseDatabaseCreation(object):
|
|||
import warnings
|
||||
warnings.warn(
|
||||
'Database creation API for m2m tables has been deprecated. M2M models are now automatically generated',
|
||||
PendingDeprecationWarning
|
||||
DeprecationWarning
|
||||
)
|
||||
|
||||
output = []
|
||||
|
@ -154,7 +154,7 @@ class BaseDatabaseCreation(object):
|
|||
import warnings
|
||||
warnings.warn(
|
||||
'Database creation API for m2m tables has been deprecated. M2M models are now automatically generated',
|
||||
PendingDeprecationWarning
|
||||
DeprecationWarning
|
||||
)
|
||||
|
||||
from django.db import models
|
||||
|
@ -217,7 +217,7 @@ class BaseDatabaseCreation(object):
|
|||
import warnings
|
||||
warnings.warn(
|
||||
'Database creation API for m2m tables has been deprecated. M2M models are now automatically generated',
|
||||
PendingDeprecationWarning
|
||||
DeprecationWarning
|
||||
)
|
||||
|
||||
from django.db import models
|
||||
|
@ -322,7 +322,7 @@ class BaseDatabaseCreation(object):
|
|||
import warnings
|
||||
warnings.warn(
|
||||
'Database creation API for m2m tables has been deprecated. M2M models are now automatically generated',
|
||||
PendingDeprecationWarning
|
||||
DeprecationWarning
|
||||
)
|
||||
|
||||
qn = self.connection.ops.quote_name
|
||||
|
|
|
@ -105,7 +105,7 @@ class DatabaseWrapper(BaseDatabaseWrapper):
|
|||
import warnings
|
||||
warnings.warn(
|
||||
'The "postgresql" backend has been deprecated. Use "postgresql_psycopg2" instead.',
|
||||
PendingDeprecationWarning
|
||||
DeprecationWarning
|
||||
)
|
||||
|
||||
self.features = DatabaseFeatures()
|
||||
|
|
|
@ -15,14 +15,14 @@ def call_with_connection(func):
|
|||
if not updated:
|
||||
warn("A Field class whose %s method hasn't been updated to take a "
|
||||
"`connection` argument." % func.__name__,
|
||||
PendingDeprecationWarning, stacklevel=2)
|
||||
DeprecationWarning, stacklevel=2)
|
||||
|
||||
def inner(*args, **kwargs):
|
||||
if 'connection' not in kwargs:
|
||||
from django.db import connection
|
||||
kwargs['connection'] = connection
|
||||
warn("%s has been called without providing a connection argument. " %
|
||||
func.__name__, PendingDeprecationWarning,
|
||||
func.__name__, DeprecationWarning,
|
||||
stacklevel=1)
|
||||
if updated:
|
||||
return func(*args, **kwargs)
|
||||
|
@ -40,14 +40,14 @@ def call_with_connection_and_prepared(func):
|
|||
if not updated:
|
||||
warn("A Field class whose %s method hasn't been updated to take "
|
||||
"`connection` and `prepared` arguments." % func.__name__,
|
||||
PendingDeprecationWarning, stacklevel=2)
|
||||
DeprecationWarning, stacklevel=2)
|
||||
|
||||
def inner(*args, **kwargs):
|
||||
if 'connection' not in kwargs:
|
||||
from django.db import connection
|
||||
kwargs['connection'] = connection
|
||||
warn("%s has been called without providing a connection argument. " %
|
||||
func.__name__, PendingDeprecationWarning,
|
||||
func.__name__, DeprecationWarning,
|
||||
stacklevel=1)
|
||||
if updated:
|
||||
return func(*args, **kwargs)
|
||||
|
|
|
@ -23,7 +23,7 @@ def load_backend(backend_name):
|
|||
import warnings
|
||||
warnings.warn(
|
||||
"Short names for DATABASE_ENGINE are deprecated; prepend with 'django.db.backends.'",
|
||||
PendingDeprecationWarning
|
||||
DeprecationWarning
|
||||
)
|
||||
return module
|
||||
except ImportError, e:
|
||||
|
|
|
@ -50,7 +50,7 @@ def en_format(name):
|
|||
from django.conf.locale.en import formats
|
||||
warnings.warn(
|
||||
"`django.forms.fields.DEFAULT_%s` is deprecated; use `django.utils.formats.get_format('%s')` instead." % (name, name),
|
||||
PendingDeprecationWarning
|
||||
DeprecationWarning
|
||||
)
|
||||
return getattr(formats, name)
|
||||
|
||||
|
|
|
@ -274,7 +274,7 @@ class CsrfResponseMiddleware(object):
|
|||
import warnings
|
||||
warnings.warn(
|
||||
"CsrfResponseMiddleware and CsrfMiddleware are deprecated; use CsrfViewMiddleware and the template tag instead (see CSRF documentation).",
|
||||
PendingDeprecationWarning
|
||||
DeprecationWarning
|
||||
)
|
||||
|
||||
def process_response(self, request, response):
|
||||
|
|
|
@ -30,22 +30,3 @@ class ConditionalGetMiddleware(object):
|
|||
response.status_code = 304
|
||||
|
||||
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()
|
|
@ -142,7 +142,7 @@ def find_template_source(name, dirs=None):
|
|||
import warnings
|
||||
warnings.warn(
|
||||
"`django.template.loaders.find_template_source` is deprecated; use `django.template.loaders.find_template` instead.",
|
||||
PendingDeprecationWarning
|
||||
DeprecationWarning
|
||||
)
|
||||
template, origin = find_template(name, dirs)
|
||||
if hasattr(template, 'render'):
|
||||
|
|
|
@ -68,7 +68,7 @@ def load_template_source(template_name, template_dirs=None):
|
|||
import warnings
|
||||
warnings.warn(
|
||||
"'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)
|
||||
load_template_source.is_usable = True
|
||||
|
|
|
@ -33,7 +33,7 @@ def load_template_source(template_name, template_dirs=None):
|
|||
import warnings
|
||||
warnings.warn(
|
||||
"'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)
|
||||
load_template_source.is_usable = resource_string is not None
|
||||
|
|
|
@ -55,7 +55,7 @@ def load_template_source(template_name, template_dirs=None):
|
|||
import warnings
|
||||
warnings.warn(
|
||||
"'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)
|
||||
load_template_source.is_usable = True
|
||||
|
|
|
@ -320,7 +320,7 @@ def run_tests(test_labels, verbosity=1, interactive=True, failfast=False, extra_
|
|||
import warnings
|
||||
warnings.warn(
|
||||
'The run_tests() test runner has been deprecated in favor of DjangoTestSuiteRunner.',
|
||||
PendingDeprecationWarning
|
||||
DeprecationWarning
|
||||
)
|
||||
test_runner = DjangoTestSuiteRunner(verbosity=verbosity, interactive=interactive, failfast=failfast)
|
||||
return test_runner.run_tests(test_labels, extra_tests=extra_tests)
|
||||
|
|
|
@ -59,7 +59,7 @@ def get_date_formats():
|
|||
warnings.warn(
|
||||
'`django.utils.translation.get_date_formats` is deprecated. '
|
||||
'Please update your code to use the new i18n aware formatting.',
|
||||
PendingDeprecationWarning
|
||||
DeprecationWarning
|
||||
)
|
||||
return settings.DATE_FORMAT, settings.DATETIME_FORMAT, settings.TIME_FORMAT
|
||||
|
||||
|
@ -67,6 +67,6 @@ def get_partial_date_formats():
|
|||
warnings.warn(
|
||||
'`django.utils.translation.get_partial_date_formats` is deprecated. '
|
||||
'Please update your code to use the new i18n aware formatting.',
|
||||
PendingDeprecationWarning
|
||||
DeprecationWarning
|
||||
)
|
||||
return settings.YEAR_MONTH_FORMAT, settings.MONTH_DAY_FORMAT
|
||||
|
|
|
@ -192,7 +192,7 @@ def activate(language):
|
|||
warnings.warn(
|
||||
"The use of the language code 'no' is deprecated. "
|
||||
"Please use the 'nb' translation instead.",
|
||||
PendingDeprecationWarning
|
||||
DeprecationWarning
|
||||
)
|
||||
_active[currentThread()] = translation(language)
|
||||
|
||||
|
@ -228,12 +228,12 @@ def get_language():
|
|||
def get_language_bidi():
|
||||
"""
|
||||
Returns selected language's BiDi layout.
|
||||
|
||||
|
||||
* False = left-to-right layout
|
||||
* True = right-to-left layout
|
||||
"""
|
||||
from django.conf import settings
|
||||
|
||||
|
||||
base_lang = get_language().split('-')[0]
|
||||
return base_lang in settings.LANGUAGES_BIDI
|
||||
|
||||
|
@ -517,7 +517,7 @@ def get_date_formats():
|
|||
warnings.warn(
|
||||
"'django.utils.translation.get_date_formats' is deprecated. "
|
||||
"Please update your code to use the new i18n aware formatting.",
|
||||
PendingDeprecationWarning
|
||||
DeprecationWarning
|
||||
)
|
||||
from django.conf import settings
|
||||
date_format = ugettext('DATE_FORMAT')
|
||||
|
@ -540,7 +540,7 @@ def get_partial_date_formats():
|
|||
warnings.warn(
|
||||
"'django.utils.translation.get_partial_date_formats' is deprecated. "
|
||||
"Please update your code to use the new i18n aware formatting.",
|
||||
PendingDeprecationWarning
|
||||
DeprecationWarning
|
||||
)
|
||||
from django.conf import settings
|
||||
year_month_format = ugettext('YEAR_MONTH_FORMAT')
|
||||
|
|
|
@ -40,14 +40,14 @@ class MyAutoField(models.CharField):
|
|||
value = MyWrapper(value)
|
||||
return value
|
||||
|
||||
def get_db_prep_save(self, value):
|
||||
def get_db_prep_save(self, value, connection):
|
||||
if not value:
|
||||
return
|
||||
if isinstance(value, MyWrapper):
|
||||
return unicode(value)
|
||||
return value
|
||||
|
||||
def get_db_prep_value(self, value):
|
||||
def get_db_prep_value(self, value, connection, prepared=False):
|
||||
if not value:
|
||||
return
|
||||
if isinstance(value, MyWrapper):
|
||||
|
|
|
@ -3,6 +3,8 @@ from django.db import models
|
|||
from django.utils import simplejson as json
|
||||
from django.utils.encoding import force_unicode
|
||||
|
||||
import warnings
|
||||
warnings.filterwarnings("ignore", category=DeprecationWarning, module='django.db.models.fields.subclassing')
|
||||
|
||||
class Small(object):
|
||||
"""
|
||||
|
|
|
@ -9,6 +9,7 @@
|
|||
from decimal import Decimal
|
||||
from django.db import models
|
||||
|
||||
|
||||
class Category(models.Model):
|
||||
name = models.CharField(max_length=20)
|
||||
|
||||
|
@ -96,7 +97,7 @@ class TeamField(models.CharField):
|
|||
def __init__(self):
|
||||
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)
|
||||
|
||||
def to_python(self, value):
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
"""
|
||||
Tests for Django's bundled context processors.
|
||||
"""
|
||||
import warnings
|
||||
|
||||
from django.conf import settings
|
||||
from django.contrib.auth import authenticate
|
||||
|
@ -46,6 +47,16 @@ class AuthContextProcessorTests(TestCase):
|
|||
urls = 'regressiontests.context_processors.urls'
|
||||
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):
|
||||
"""
|
||||
Tests that the session is not accessed simply by including
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
import warnings
|
||||
|
||||
from django.test import TestCase
|
||||
from django.http import HttpRequest, HttpResponse
|
||||
|
@ -69,6 +70,14 @@ class CsrfMiddlewareTest(TestCase):
|
|||
_session_id = "1"
|
||||
_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):
|
||||
return TestingHttpRequest()
|
||||
|
||||
|
|
|
@ -1,16 +1,15 @@
|
|||
import datetime
|
||||
import warnings
|
||||
from xml.dom import minidom
|
||||
|
||||
from django.contrib.syndication import feeds, views
|
||||
from django.core.exceptions import ImproperlyConfigured
|
||||
from django.test import TestCase
|
||||
from django.utils import tzinfo
|
||||
from django.utils.feedgenerator import rfc2822_date, rfc3339_date
|
||||
from models import Entry
|
||||
from xml.dom import minidom
|
||||
|
||||
try:
|
||||
set
|
||||
except NameError:
|
||||
from sets import Set as set
|
||||
from models import Entry
|
||||
|
||||
|
||||
class FeedTestCase(TestCase):
|
||||
fixtures = ['feeddata.json']
|
||||
|
@ -315,6 +314,15 @@ class DeprecatedSyndicationFeedTest(FeedTestCase):
|
|||
"""
|
||||
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):
|
||||
"""
|
||||
|
|
|
@ -67,7 +67,8 @@ class DeprecatedEggLoaderTest(unittest.TestCase):
|
|||
})
|
||||
self._old_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):
|
||||
settings.INSTALLED_APPS = self._old_installed_apps
|
||||
|
@ -79,6 +80,8 @@ class DeprecatedEggLoaderTest(unittest.TestCase):
|
|||
contents, template_name = lts_egg("y.html")
|
||||
self.assertEqual(contents, "y")
|
||||
self.assertEqual(template_name, "egg:egg_1:templates/y.html")
|
||||
warnings.resetwarnings()
|
||||
warnings.simplefilter("ignore", PendingDeprecationWarning)
|
||||
|
||||
|
||||
class EggLoaderTest(unittest.TestCase):
|
||||
|
|
|
@ -174,7 +174,7 @@ def django_tests(verbosity, interactive, failfast, test_labels):
|
|||
import warnings
|
||||
warnings.warn(
|
||||
'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,
|
||||
extra_tests=extra_tests)
|
||||
|
|
Loading…
Reference in New Issue