diff options
| author | Aymeric Augustin <aymeric.augustin@m4x.org> | 2012-12-24 22:32:41 +0100 |
|---|---|---|
| committer | Aymeric Augustin <aymeric.augustin@m4x.org> | 2012-12-29 21:58:12 +0100 |
| commit | fb9f1b9bfb7378027adfe916733c701a89f8bb24 (patch) | |
| tree | e87438c9e4c907f6afe35755647afcda60dae0bf /tests | |
| parent | 067505ad19f088e8db1d8c788ceea388c7241bcd (diff) | |
Removed backwards-compatibility shim for #16288.
Also unit-tested django.utils.log.RequireDebugTrue for consistency.
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/regressiontests/logging_tests/tests.py | 71 |
1 files changed, 10 insertions, 61 deletions
diff --git a/tests/regressiontests/logging_tests/tests.py b/tests/regressiontests/logging_tests/tests.py index 07804eb398..f9838949ab 100644 --- a/tests/regressiontests/logging_tests/tests.py +++ b/tests/regressiontests/logging_tests/tests.py @@ -5,12 +5,12 @@ import logging import sys import warnings -from django.conf import compat_patch_logging_config, LazySettings +from django.conf import LazySettings from django.core import mail from django.test import TestCase, RequestFactory from django.test.utils import override_settings from django.utils.encoding import force_text -from django.utils.log import CallbackFilter, RequireDebugFalse +from django.utils.log import CallbackFilter, RequireDebugFalse, RequireDebugTrue from django.utils.six import StringIO from django.utils.unittest import skipUnless @@ -40,46 +40,10 @@ OLD_LOGGING = { } -class PatchLoggingConfigTest(TestCase): - """ - Tests for backward-compat shim for #16288. These tests should be removed in - Django 1.6 when that shim and DeprecationWarning are removed. - - """ - def test_filter_added(self): - """ - Test that debug-false filter is added to mail_admins handler if it has - no filters. - - """ - config = copy.deepcopy(OLD_LOGGING) - - with warnings.catch_warnings(record=True) as w: - warnings.simplefilter("always") - compat_patch_logging_config(config) - self.assertEqual(len(w), 1) - - self.assertEqual( - config["handlers"]["mail_admins"]["filters"], - ['require_debug_false']) - - def test_filter_configuration(self): - """ - Test that the auto-added require_debug_false filter is an instance of - `RequireDebugFalse` filter class. - - """ - config = copy.deepcopy(OLD_LOGGING) - with warnings.catch_warnings(record=True): - compat_patch_logging_config(config) - - flt = config["filters"]["require_debug_false"] - self.assertEqual(flt["()"], "django.utils.log.RequireDebugFalse") - +class LoggingFiltersTest(TestCase): def test_require_debug_false_filter(self): """ Test the RequireDebugFalse filter class. - """ filter_ = RequireDebugFalse() @@ -89,32 +53,17 @@ class PatchLoggingConfigTest(TestCase): with self.settings(DEBUG=False): self.assertEqual(filter_.filter("record is not used"), True) - def test_no_patch_if_filters_key_exists(self): - """ - Test that the logging configuration is not modified if the mail_admins - handler already has a "filters" key. - - """ - config = copy.deepcopy(OLD_LOGGING) - config["handlers"]["mail_admins"]["filters"] = [] - new_config = copy.deepcopy(config) - compat_patch_logging_config(new_config) - - self.assertEqual(config, new_config) - - def test_no_patch_if_no_mail_admins_handler(self): + def test_require_debug_true_filter(self): """ - Test that the logging configuration is not modified if the mail_admins - handler is not present. - + Test the RequireDebugTrue filter class. """ - config = copy.deepcopy(OLD_LOGGING) - config["handlers"].pop("mail_admins") - new_config = copy.deepcopy(config) - compat_patch_logging_config(new_config) + filter_ = RequireDebugTrue() - self.assertEqual(config, new_config) + with self.settings(DEBUG=True): + self.assertEqual(filter_.filter("record is not used"), True) + with self.settings(DEBUG=False): + self.assertEqual(filter_.filter("record is not used"), False) class DefaultLoggingTest(TestCase): def setUp(self): |
