diff options
| author | Aymeric Augustin <aymeric.augustin@polyconseil.fr> | 2012-05-03 15:27:01 +0200 |
|---|---|---|
| committer | Aymeric Augustin <aymeric.augustin@polyconseil.fr> | 2012-05-03 15:27:01 +0200 |
| commit | e84f79f05113f546810c1908c7baef99fb1e874a (patch) | |
| tree | 4cb5f3e428caa894bd9acc06fc3cd6250b018715 /tests | |
| parent | 227cec686e512412f613c3d14743b85445765d92 (diff) | |
Fixed #18042 -- Advanced deprecation warnings.
Thanks Ramiro for the patch.
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/regressiontests/cache/tests.py | 6 | ||||
| -rw-r--r-- | tests/regressiontests/decorators/tests.py | 2 | ||||
| -rw-r--r-- | tests/regressiontests/logging_tests/tests.py | 11 | ||||
| -rw-r--r-- | tests/regressiontests/requests/tests.py | 9 | ||||
| -rw-r--r-- | tests/regressiontests/settings_tests/tests.py | 5 | ||||
| -rw-r--r-- | tests/regressiontests/utils/text.py | 14 | ||||
| -rwxr-xr-x | tests/runtests.py | 2 |
7 files changed, 41 insertions, 8 deletions
diff --git a/tests/regressiontests/cache/tests.py b/tests/regressiontests/cache/tests.py index 00ccda6102..16368c6fe9 100644 --- a/tests/regressiontests/cache/tests.py +++ b/tests/regressiontests/cache/tests.py @@ -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() diff --git a/tests/regressiontests/decorators/tests.py b/tests/regressiontests/decorators/tests.py index 749df43e0c..ecec2812ab 100644 --- a/tests/regressiontests/decorators/tests.py +++ b/tests/regressiontests/decorators/tests.py @@ -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): diff --git a/tests/regressiontests/logging_tests/tests.py b/tests/regressiontests/logging_tests/tests.py index 5563ea6b4f..6ec7f2a645 100644 --- a/tests/regressiontests/logging_tests/tests.py +++ b/tests/regressiontests/logging_tests/tests.py @@ -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"], diff --git a/tests/regressiontests/requests/tests.py b/tests/regressiontests/requests/tests.py index 5c3cf59eaf..c838832b25 100644 --- a/tests/regressiontests/requests/tests.py +++ b/tests/regressiontests/requests/tests.py @@ -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) diff --git a/tests/regressiontests/settings_tests/tests.py b/tests/regressiontests/settings_tests/tests.py index 493ee8021d..2027382a85 100644 --- a/tests/regressiontests/settings_tests/tests.py +++ b/tests/regressiontests/settings_tests/tests.py @@ -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: diff --git a/tests/regressiontests/utils/text.py b/tests/regressiontests/utils/text.py index aae75339bc..bce7f99264 100644 --- a/tests/regressiontests/utils/text.py +++ b/tests/regressiontests/utils/text.py @@ -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( diff --git a/tests/runtests.py b/tests/runtests.py index 5e5c7dcecc..f1edc5d8ba 100755 --- a/tests/runtests.py +++ b/tests/runtests.py @@ -10,7 +10,7 @@ from django import contrib # databrowse is deprecated, but we still want to run its tests warnings.filterwarnings('ignore', "The Databrowse contrib app is deprecated", - PendingDeprecationWarning, 'django.contrib.databrowse') + DeprecationWarning, 'django.contrib.databrowse') CONTRIB_DIR_NAME = 'django.contrib' MODEL_TESTS_DIR_NAME = 'modeltests' |
