diff options
| author | Claude Paroz <claude@2xlibre.net> | 2012-05-03 18:19:18 +0200 |
|---|---|---|
| committer | Claude Paroz <claude@2xlibre.net> | 2012-05-03 18:30:07 +0200 |
| commit | 10cf3c64273db407402ea9723569dfc8d059e186 (patch) | |
| tree | 09278a014019f628169ec4774a3ad6fb13650fb4 /tests/regressiontests/logging_tests | |
| parent | e9a56606e738c478373d052bbd876ff84afdb995 (diff) | |
Used catch_warnings instead of save/restore methods. Refs #17049.
Diffstat (limited to 'tests/regressiontests/logging_tests')
| -rw-r--r-- | tests/regressiontests/logging_tests/tests.py | 12 |
1 files changed, 5 insertions, 7 deletions
diff --git a/tests/regressiontests/logging_tests/tests.py b/tests/regressiontests/logging_tests/tests.py index 6ec7f2a645..e4c045b9d8 100644 --- a/tests/regressiontests/logging_tests/tests.py +++ b/tests/regressiontests/logging_tests/tests.py @@ -4,7 +4,7 @@ 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, get_warnings_state, restore_warnings_state +from django.test.utils import override_settings from django.utils.log import CallbackFilter, RequireDebugFalse, getLogger @@ -42,12 +42,9 @@ class PatchLoggingConfigTest(TestCase): """ config = copy.deepcopy(OLD_LOGGING) - warnings_state = get_warnings_state() - warnings.filterwarnings('ignore', category=DeprecationWarning, module='django.conf') - try: + with warnings.catch_warnings(record=True) as w: compat_patch_logging_config(config) - finally: - restore_warnings_state(warnings_state) + self.assertEqual(len(w), 1) self.assertEqual( config["handlers"]["mail_admins"]["filters"], @@ -60,7 +57,8 @@ class PatchLoggingConfigTest(TestCase): """ config = copy.deepcopy(OLD_LOGGING) - compat_patch_logging_config(config) + with warnings.catch_warnings(record=True): + compat_patch_logging_config(config) flt = config["filters"]["require_debug_false"] self.assertEqual(flt["()"], "django.utils.log.RequireDebugFalse") |
