1
0
mirror of https://github.com/django/django.git synced 2025-10-31 09:41:08 +00:00

Advanced deprecation warnings for Django 1.7.

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

View File

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

View File

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

View File

@@ -28,7 +28,7 @@ from django.middleware.cache import (FetchFromCacheMiddleware,
from django.template import Template
from django.template.response import TemplateResponse
from django.test import TestCase, TransactionTestCase, RequestFactory
from django.test.utils import override_settings, IgnorePendingDeprecationWarningsMixin
from django.test.utils import override_settings, IgnoreDeprecationWarningsMixin
from django.utils import six, timezone, translation, unittest
from django.utils.cache import (patch_vary_headers, get_cache_key,
learn_cache_key, patch_cache_control, patch_response_headers)
@@ -1594,7 +1594,7 @@ def hello_world_view(request, value):
},
},
)
class CacheMiddlewareTest(IgnorePendingDeprecationWarningsMixin, TestCase):
class CacheMiddlewareTest(IgnoreDeprecationWarningsMixin, TestCase):
def setUp(self):
super(CacheMiddlewareTest, self).setUp()

View File

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

View File

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

View File

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

View File

@@ -266,7 +266,7 @@ class ModelFormBaseTest(TestCase):
def test_missing_fields_attribute(self):
with warnings.catch_warnings(record=True) as w:
warnings.simplefilter("always", PendingDeprecationWarning)
warnings.simplefilter("always", DeprecationWarning)
class MissingFieldsForm(forms.ModelForm):
class Meta:
@@ -276,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, PendingDeprecationWarning)
# self.assertEqual(w[0].category, DeprecationWarning)
# Until end of the deprecation cycle, should still create the
# form as before:

View File

@@ -566,10 +566,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", PendingDeprecationWarning)
warnings.simplefilter("always", DeprecationWarning)
# This should become an error once deprecation cycle is complete.
form = modelform_factory(Person)
self.assertEqual(w[0].category, PendingDeprecationWarning)
self.assertEqual(w[0].category, DeprecationWarning)
def test_modelform_factory_with_all_fields(self):
form = modelform_factory(Person, fields="__all__")

View File

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

View File

@@ -534,7 +534,7 @@ class TemplateTests(TransRealMixin, TestCase):
try:
with warnings.catch_warnings():
# Ignore pending deprecations of the old syntax of the 'cycle' and 'firstof' tags.
warnings.filterwarnings("ignore", category=PendingDeprecationWarning, module='django.template.base')
warnings.filterwarnings("ignore", category=DeprecationWarning, module='django.template.base')
test_template = loader.get_template(name)
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

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

View File

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

View File

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

View File

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

View File

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