summaryrefslogtreecommitdiffstats
path: root/Lib/test
diff options
context:
space:
mode:
authorVinay Sajip <vinay_sajip@yahoo.co.uk>2013-03-23 11:18:45 (GMT)
committerVinay Sajip <vinay_sajip@yahoo.co.uk>2013-03-23 11:18:45 (GMT)
commit68b4cc87cd75822552914fb59f5bf53fe6c28202 (patch)
treee1ef437a8e25985704dbb0ba0a5d0c8147f5cd71 /Lib/test
parenta4cfd60f3d86d2cbaa864f83a41241800674bf15 (diff)
downloadcpython-68b4cc87cd75822552914fb59f5bf53fe6c28202.zip
cpython-68b4cc87cd75822552914fb59f5bf53fe6c28202.tar.gz
cpython-68b4cc87cd75822552914fb59f5bf53fe6c28202.tar.bz2
Issue #17521: Corrected non-enabling of logger following two calls to fileConfig().
Diffstat (limited to 'Lib/test')
-rw-r--r--Lib/test/test_logging.py34
1 files changed, 32 insertions, 2 deletions
diff --git a/Lib/test/test_logging.py b/Lib/test/test_logging.py
index bbd4852..d11b938 100644
--- a/Lib/test/test_logging.py
+++ b/Lib/test/test_logging.py
@@ -764,9 +764,30 @@ class ConfigFileTest(BaseTest):
datefmt=
"""
- def apply_config(self, conf):
+ disable_test = """
+ [loggers]
+ keys=root
+
+ [handlers]
+ keys=screen
+
+ [formatters]
+ keys=
+
+ [logger_root]
+ level=DEBUG
+ handlers=screen
+
+ [handler_screen]
+ level=DEBUG
+ class=StreamHandler
+ args=(sys.stdout,)
+ formatter=
+ """
+
+ def apply_config(self, conf, **kwargs):
file = io.StringIO(textwrap.dedent(conf))
- logging.config.fileConfig(file)
+ logging.config.fileConfig(file, **kwargs)
def test_config0_ok(self):
# A simple config file which overrides the default settings.
@@ -870,6 +891,15 @@ class ConfigFileTest(BaseTest):
# Original logger output is empty.
self.assert_log_lines([])
+ def test_logger_disabling(self):
+ self.apply_config(self.disable_test)
+ logger = logging.getLogger('foo')
+ self.assertFalse(logger.disabled)
+ self.apply_config(self.disable_test)
+ self.assertTrue(logger.disabled)
+ self.apply_config(self.disable_test, disable_existing_loggers=False)
+ self.assertFalse(logger.disabled)
+
class LogRecordStreamHandler(StreamRequestHandler):
"""Handler for a streaming logging request. It saves the log message in the