diff options
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") |
