diff --git a/django/contrib/admin/sites.py b/django/contrib/admin/sites.py index d0d6473a34fa8..45de459631468 100644 --- a/django/contrib/admin/sites.py +++ b/django/contrib/admin/sites.py @@ -456,81 +456,6 @@ def app_index(self, request, app_label, extra_context=None): 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() diff --git a/django/contrib/auth/__init__.py b/django/contrib/auth/__init__.py index a184aeada872d..3d76a425a4e24 100644 --- a/django/contrib/auth/__init__.py +++ b/django/contrib/auth/__init__.py @@ -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() diff --git a/django/contrib/auth/models.py b/django/contrib/auth/models.py index 3d927d813e346..16a8b99d6ccc2 100644 --- a/django/contrib/auth/models.py +++ b/django/contrib/auth/models.py @@ -107,7 +107,7 @@ def create_user(self, username, email, password=None): 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 @@ def _get_message_set(self): 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) diff --git a/django/contrib/auth/tests/auth_backends.py b/django/contrib/auth/tests/auth_backends.py index 8eaf2cb3e7dc6..1d2d3a3884b93 100644 --- a/django/contrib/auth/tests/auth_backends.py +++ b/django/contrib/auth/tests/auth_backends.py @@ -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 @@ def setUp(self): 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) diff --git a/django/contrib/csrf/middleware.py b/django/contrib/csrf/middleware.py index 4885cfcc3e500..f67a4da897664 100644 --- a/django/contrib/csrf/middleware.py +++ b/django/contrib/csrf/middleware.py @@ -3,5 +3,5 @@ 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 ) diff --git a/django/contrib/gis/tests/__init__.py b/django/contrib/gis/tests/__init__.py index 44d62c2a98889..6841d8133354b 100644 --- a/django/contrib/gis/tests/__init__.py +++ b/django/contrib/gis/tests/__init__.py @@ -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 @@ def setup_test_environment(self, **kwargs): 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', diff --git a/django/contrib/messages/tests/base.py b/django/contrib/messages/tests/base.py index 2dea5a46d0b62..1c42c1d0a3507 100644 --- a/django/contrib/messages/tests/base.py +++ b/django/contrib/messages/tests/base.py @@ -1,3 +1,5 @@ +import warnings + from django import http from django.test import TestCase from django.conf import settings @@ -49,6 +51,8 @@ def setUp(self): 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 @@ def tearDown(self): 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: diff --git a/django/contrib/syndication/feeds.py b/django/contrib/syndication/feeds.py index e4e99da7dda45..f61b30a740a64 100644 --- a/django/contrib/syndication/feeds.py +++ b/django/contrib/syndication/feeds.py @@ -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 diff --git a/django/contrib/syndication/views.py b/django/contrib/syndication/views.py index d942b2f9dcf05..ee692e2c0c25c 100644 --- a/django/contrib/syndication/views.py +++ b/django/contrib/syndication/views.py @@ -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.") diff --git a/django/core/cache/backends/memcached.py b/django/core/cache/backends/memcached.py index 7d6b5b362b7c3..cd14fdaf95c55 100644 --- a/django/core/cache/backends/memcached.py +++ b/django/core/cache/backends/memcached.py @@ -10,7 +10,7 @@ import warnings warnings.warn( "Support for the 'cmemcache' library has been deprecated. Please use python-memcached instead.", - PendingDeprecationWarning + DeprecationWarning ) except ImportError: try: diff --git a/django/core/context_processors.py b/django/core/context_processors.py index a5f29dfb2dab3..7a59728bfcf85 100644 --- a/django/core/context_processors.py +++ b/django/core/context_processors.py @@ -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) diff --git a/django/core/mail/__init__.py b/django/core/mail/__init__.py index f9d1210791a62..d7a868dfc2b10 100644 --- a/django/core/mail/__init__.py +++ b/django/core/mail/__init__.py @@ -106,6 +106,6 @@ def __init__(self, *args, **kwds): import warnings warnings.warn( 'mail.SMTPConnection is deprecated; use mail.get_connection() instead.', - PendingDeprecationWarning + DeprecationWarning ) super(SMTPConnection, self).__init__(*args, **kwds) diff --git a/django/core/management/commands/test.py b/django/core/management/commands/test.py index 6d0a5d8e2e50e..1431f0059fe1b 100644 --- a/django/core/management/commands/test.py +++ b/django/core/management/commands/test.py @@ -29,7 +29,7 @@ def handle(self, *test_labels, **options): 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: diff --git a/django/db/__init__.py b/django/db/__init__.py index 7136b2f258327..025025c8eb1fd 100644 --- a/django/db/__init__.py +++ b/django/db/__init__.py @@ -15,7 +15,7 @@ import warnings warnings.warn( "settings.DATABASE_* is deprecated; use settings.DATABASES instead.", - PendingDeprecationWarning + DeprecationWarning ) settings.DATABASES[DEFAULT_DB_ALIAS] = { @@ -44,7 +44,7 @@ "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 @@ 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 diff --git a/django/db/backends/creation.py b/django/db/backends/creation.py index 6cdf415f7af81..407bf5cbbbe38 100644 --- a/django/db/backends/creation.py +++ b/django/db/backends/creation.py @@ -140,7 +140,7 @@ def sql_for_many_to_many(self, model, style): 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 @@ def sql_for_many_to_many_field(self, model, f, style): 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 @@ def sql_for_inline_many_to_many_references(self, model, field, style): 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 @@ def sql_destroy_many_to_many(self, model, f, style): 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 diff --git a/django/db/backends/postgresql/base.py b/django/db/backends/postgresql/base.py index f84ad1da61051..84b4c7f5f31aa 100644 --- a/django/db/backends/postgresql/base.py +++ b/django/db/backends/postgresql/base.py @@ -105,7 +105,7 @@ def __init__(self, *args, **kwargs): import warnings warnings.warn( 'The "postgresql" backend has been deprecated. Use "postgresql_psycopg2" instead.', - PendingDeprecationWarning + DeprecationWarning ) self.features = DatabaseFeatures() diff --git a/django/db/models/fields/subclassing.py b/django/db/models/fields/subclassing.py index bd11675ad3a0b..3d04511dc28e6 100644 --- a/django/db/models/fields/subclassing.py +++ b/django/db/models/fields/subclassing.py @@ -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) diff --git a/django/db/utils.py b/django/db/utils.py index 7c3e4137266a9..c5b0bb8be6008 100644 --- a/django/db/utils.py +++ b/django/db/utils.py @@ -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: diff --git a/django/forms/fields.py b/django/forms/fields.py index 51551ded47927..e2e712f0c1bc1 100644 --- a/django/forms/fields.py +++ b/django/forms/fields.py @@ -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) diff --git a/django/middleware/csrf.py b/django/middleware/csrf.py index b88dd55a3d409..483510a1aef36 100644 --- a/django/middleware/csrf.py +++ b/django/middleware/csrf.py @@ -274,7 +274,7 @@ def __init__(self): 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): diff --git a/django/middleware/http.py b/django/middleware/http.py index 75af664447f5b..13c1b89c418b0 100644 --- a/django/middleware/http.py +++ b/django/middleware/http.py @@ -30,22 +30,3 @@ def process_response(self, request, response): 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() \ No newline at end of file diff --git a/django/template/loader.py b/django/template/loader.py index b8077522fc576..9ba0f2c052432 100644 --- a/django/template/loader.py +++ b/django/template/loader.py @@ -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'): diff --git a/django/template/loaders/app_directories.py b/django/template/loaders/app_directories.py index 3e05bf87f64d2..f2e7687650b8b 100644 --- a/django/template/loaders/app_directories.py +++ b/django/template/loaders/app_directories.py @@ -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 diff --git a/django/template/loaders/eggs.py b/django/template/loaders/eggs.py index 998693e4e6831..258194973531c 100644 --- a/django/template/loaders/eggs.py +++ b/django/template/loaders/eggs.py @@ -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 diff --git a/django/template/loaders/filesystem.py b/django/template/loaders/filesystem.py index 7efadec938c4b..970923b35b354 100644 --- a/django/template/loaders/filesystem.py +++ b/django/template/loaders/filesystem.py @@ -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 diff --git a/django/test/simple.py b/django/test/simple.py index be5550f9bfa87..7ec273c75a493 100644 --- a/django/test/simple.py +++ b/django/test/simple.py @@ -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) diff --git a/django/utils/translation/trans_null.py b/django/utils/translation/trans_null.py index 50f41a2c23d81..8a075806ecee5 100644 --- a/django/utils/translation/trans_null.py +++ b/django/utils/translation/trans_null.py @@ -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 diff --git a/django/utils/translation/trans_real.py b/django/utils/translation/trans_real.py index 75f6e202faa17..fe34b6ab0f892 100644 --- a/django/utils/translation/trans_real.py +++ b/django/utils/translation/trans_real.py @@ -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') diff --git a/tests/modeltests/custom_pk/fields.py b/tests/modeltests/custom_pk/fields.py index 2eeb80e6ace85..40551a363c5e5 100644 --- a/tests/modeltests/custom_pk/fields.py +++ b/tests/modeltests/custom_pk/fields.py @@ -40,14 +40,14 @@ def to_python(self, value): 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): diff --git a/tests/modeltests/field_subclassing/fields.py b/tests/modeltests/field_subclassing/fields.py index 1f9bdf5e0a085..f667310c58cb9 100644 --- a/tests/modeltests/field_subclassing/fields.py +++ b/tests/modeltests/field_subclassing/fields.py @@ -3,6 +3,8 @@ 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): """ diff --git a/tests/modeltests/serializers/models.py b/tests/modeltests/serializers/models.py index c12e73fd6e73c..7f0019fbcd9f9 100644 --- a/tests/modeltests/serializers/models.py +++ b/tests/modeltests/serializers/models.py @@ -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): diff --git a/tests/regressiontests/context_processors/tests.py b/tests/regressiontests/context_processors/tests.py index 0d19bef7ffb99..2b5ddbe94c068 100644 --- a/tests/regressiontests/context_processors/tests.py +++ b/tests/regressiontests/context_processors/tests.py @@ -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 diff --git a/tests/regressiontests/csrf_tests/tests.py b/tests/regressiontests/csrf_tests/tests.py index 9030d397ab656..0b7a0bb932628 100644 --- a/tests/regressiontests/csrf_tests/tests.py +++ b/tests/regressiontests/csrf_tests/tests.py @@ -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() diff --git a/tests/regressiontests/syndication/tests.py b/tests/regressiontests/syndication/tests.py index 76a6c88bc13c0..a69a454921ada 100644 --- a/tests/regressiontests/syndication/tests.py +++ b/tests/regressiontests/syndication/tests.py @@ -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 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): """ diff --git a/tests/regressiontests/templates/loaders.py b/tests/regressiontests/templates/loaders.py index caa3faa6bcd22..40beb2997a610 100644 --- a/tests/regressiontests/templates/loaders.py +++ b/tests/regressiontests/templates/loaders.py @@ -67,7 +67,8 @@ def setUp(self): }) 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 @@ def test_existing(self): 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): diff --git a/tests/runtests.py b/tests/runtests.py index 516ec012cd27c..64adc80041dea 100755 --- a/tests/runtests.py +++ b/tests/runtests.py @@ -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)