summaryrefslogtreecommitdiff
path: root/tests/logging_tests
diff options
context:
space:
mode:
authorTim Graham <timograham@gmail.com>2015-09-15 14:13:34 -0400
committerTim Graham <timograham@gmail.com>2015-09-23 11:33:49 -0400
commit6b37719616b77872f9498ca74022563c178031e6 (patch)
tree4211ef8621658d70933ae8e266f62449ccad80c1 /tests/logging_tests
parent7cb3a488436e8e7d0249280e95ba2ee945c96c87 (diff)
downloaddjango-6b37719616b77872f9498ca74022563c178031e6.tar.gz
Refs #24526 -- Made the django logger handle INFO messages.
Without an explicit 'level', only messages at WARNING or higher are handled. This makes the config consistent with the docs which say, "The django catch-all logger sends all messages at the INFO level or higher to the console."
Diffstat (limited to 'tests/logging_tests')
-rw-r--r--tests/logging_tests/tests.py30
1 files changed, 29 insertions, 1 deletions
diff --git a/tests/logging_tests/tests.py b/tests/logging_tests/tests.py
index 9c39bb2d59..6cba5942b1 100644
--- a/tests/logging_tests/tests.py
+++ b/tests/logging_tests/tests.py
@@ -6,6 +6,7 @@ import warnings
from admin_scripts.tests import AdminScriptTestCase
+from django.conf import settings
from django.core import mail
from django.core.files.temp import NamedTemporaryFile
from django.test import RequestFactory, SimpleTestCase, override_settings
@@ -13,7 +14,8 @@ from django.test.utils import LoggingCaptureMixin, patch_logger
from django.utils.deprecation import RemovedInNextVersionWarning
from django.utils.encoding import force_text
from django.utils.log import (
- AdminEmailHandler, CallbackFilter, RequireDebugFalse, RequireDebugTrue,
+ DEFAULT_LOGGING, AdminEmailHandler, CallbackFilter, RequireDebugFalse,
+ RequireDebugTrue,
)
from django.utils.six import StringIO
@@ -67,6 +69,17 @@ class LoggingFiltersTest(SimpleTestCase):
class DefaultLoggingTest(LoggingCaptureMixin, SimpleTestCase):
+ @classmethod
+ def setUpClass(cls):
+ super(DefaultLoggingTest, cls).setUpClass()
+ cls._logging = settings.LOGGING
+ logging.config.dictConfig(DEFAULT_LOGGING)
+
+ @classmethod
+ def tearDownClass(cls):
+ super(DefaultLoggingTest, cls).tearDownClass()
+ logging.config.dictConfig(cls._logging)
+
def test_django_logger(self):
"""
The 'django' base logger only output anything when DEBUG=True.
@@ -78,6 +91,21 @@ class DefaultLoggingTest(LoggingCaptureMixin, SimpleTestCase):
self.logger.error("Hey, this is an error.")
self.assertEqual(self.logger_output.getvalue(), 'Hey, this is an error.\n')
+ def test_django_logger_warning(self):
+ with self.settings(DEBUG=True):
+ self.logger.warning('warning')
+ self.assertEqual(self.logger_output.getvalue(), 'warning\n')
+
+ def test_django_logger_info(self):
+ with self.settings(DEBUG=True):
+ self.logger.info('info')
+ self.assertEqual(self.logger_output.getvalue(), 'info\n')
+
+ def test_django_logger_debug(self):
+ with self.settings(DEBUG=True):
+ self.logger.debug('debug')
+ self.assertEqual(self.logger_output.getvalue(), '')
+
class WarningLoggerTests(SimpleTestCase):
"""