mirror of
https://github.com/django/django.git
synced 2025-11-02 04:48:33 +00:00
Fixed #18042 -- Advanced deprecation warnings.
Thanks Ramiro for the patch.
This commit is contained in:
parent
227cec686e
commit
e84f79f051
27 changed files with 75 additions and 38 deletions
6
tests/regressiontests/cache/tests.py
vendored
6
tests/regressiontests/cache/tests.py
vendored
|
|
@ -1442,12 +1442,18 @@ def hello_world_view(request, value):
|
|||
)
|
||||
class CacheMiddlewareTest(TestCase):
|
||||
|
||||
# The following tests will need to be modified in Django 1.6 to not use
|
||||
# deprecated ways of using the cache_page decorator that will be removed in
|
||||
# such version
|
||||
def setUp(self):
|
||||
self.factory = RequestFactory()
|
||||
self.default_cache = get_cache('default')
|
||||
self.other_cache = get_cache('other')
|
||||
self.save_warnings_state()
|
||||
warnings.filterwarnings('ignore', category=DeprecationWarning, module='django.views.decorators.cache')
|
||||
|
||||
def tearDown(self):
|
||||
self.restore_warnings_state()
|
||||
self.default_cache.clear()
|
||||
self.other_cache.clear()
|
||||
|
||||
|
|
|
|||
|
|
@ -70,7 +70,7 @@ class DecoratorsTest(TestCase):
|
|||
|
||||
def setUp(self):
|
||||
self.warning_state = get_warnings_state()
|
||||
warnings.filterwarnings('ignore', category=PendingDeprecationWarning,
|
||||
warnings.filterwarnings('ignore', category=DeprecationWarning,
|
||||
module='django.views.decorators.cache')
|
||||
|
||||
def tearDown(self):
|
||||
|
|
|
|||
|
|
@ -1,9 +1,10 @@
|
|||
import copy
|
||||
import warnings
|
||||
|
||||
from django.conf import compat_patch_logging_config
|
||||
from django.core import mail
|
||||
from django.test import TestCase, RequestFactory
|
||||
from django.test.utils import override_settings
|
||||
from django.test.utils import override_settings, get_warnings_state, restore_warnings_state
|
||||
from django.utils.log import CallbackFilter, RequireDebugFalse, getLogger
|
||||
|
||||
|
||||
|
|
@ -40,7 +41,13 @@ class PatchLoggingConfigTest(TestCase):
|
|||
|
||||
"""
|
||||
config = copy.deepcopy(OLD_LOGGING)
|
||||
compat_patch_logging_config(config)
|
||||
|
||||
warnings_state = get_warnings_state()
|
||||
warnings.filterwarnings('ignore', category=DeprecationWarning, module='django.conf')
|
||||
try:
|
||||
compat_patch_logging_config(config)
|
||||
finally:
|
||||
restore_warnings_state(warnings_state)
|
||||
|
||||
self.assertEqual(
|
||||
config["handlers"]["mail_admins"]["filters"],
|
||||
|
|
|
|||
|
|
@ -420,5 +420,10 @@ class RequestsTests(unittest.TestCase):
|
|||
'CONTENT_LENGTH': len(payload),
|
||||
'wsgi.input': ExplodingStringIO(payload)})
|
||||
|
||||
with self.assertRaises(UnreadablePostError):
|
||||
request.raw_post_data
|
||||
warnings_state = get_warnings_state()
|
||||
warnings.filterwarnings('ignore', category=DeprecationWarning, module='django.http')
|
||||
try:
|
||||
with self.assertRaises(UnreadablePostError):
|
||||
request.raw_post_data
|
||||
finally:
|
||||
restore_warnings_state(warnings_state)
|
||||
|
|
|
|||
|
|
@ -1,4 +1,5 @@
|
|||
import os
|
||||
import warnings
|
||||
|
||||
from django.conf import settings, global_settings
|
||||
from django.core.exceptions import ImproperlyConfigured
|
||||
|
|
@ -274,10 +275,14 @@ class EnvironmentVariableTest(TestCase):
|
|||
Ensures proper settings file is used in setup_environ if
|
||||
DJANGO_SETTINGS_MODULE is set in the environment.
|
||||
"""
|
||||
# Decide what to do with these tests when setup_environ() gets removed in Django 1.6
|
||||
def setUp(self):
|
||||
self.original_value = os.environ.get('DJANGO_SETTINGS_MODULE')
|
||||
self.save_warnings_state()
|
||||
warnings.filterwarnings('ignore', category=DeprecationWarning, module='django.core.management')
|
||||
|
||||
def tearDown(self):
|
||||
self.restore_warnings_state()
|
||||
if self.original_value:
|
||||
os.environ['DJANGO_SETTINGS_MODULE'] = self.original_value
|
||||
elif 'DJANGO_SETTINGS_MODULE' in os.environ:
|
||||
|
|
|
|||
|
|
@ -1,9 +1,19 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
import unittest
|
||||
import warnings
|
||||
|
||||
from django.test import SimpleTestCase
|
||||
from django.utils import text
|
||||
|
||||
class TestUtilsText(unittest.TestCase):
|
||||
class TestUtilsText(SimpleTestCase):
|
||||
|
||||
# In Django 1.6 truncate_words() and truncate_html_words() will be removed
|
||||
# so these tests will need to be adapted accordingly
|
||||
def setUp(self):
|
||||
self.save_warnings_state()
|
||||
warnings.filterwarnings('ignore', category=DeprecationWarning, module='django.utils.text')
|
||||
|
||||
def tearDown(self):
|
||||
self.restore_warnings_state()
|
||||
|
||||
def test_truncate_chars(self):
|
||||
truncator = text.Truncator(
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue