diff options
author | Vinay Sajip <vinay_sajip@yahoo.co.uk> | 2012-10-09 08:06:03 (GMT) |
---|---|---|
committer | Vinay Sajip <vinay_sajip@yahoo.co.uk> | 2012-10-09 08:06:03 (GMT) |
commit | cf9e2f242081e119763f717df5fef5e6fcba8c77 (patch) | |
tree | c8a24513a6ba7450b914e7d69c55fab017a838d0 /Lib/test/test_logging.py | |
parent | 96df7da0acbba9e704d31436de4cb440d2df367b (diff) | |
download | cpython-cf9e2f242081e119763f717df5fef5e6fcba8c77.zip cpython-cf9e2f242081e119763f717df5fef5e6fcba8c77.tar.gz cpython-cf9e2f242081e119763f717df5fef5e6fcba8c77.tar.bz2 |
Closes #16110: fileConfig now accepts a pre-initialised ConfigParser instance.
Diffstat (limited to 'Lib/test/test_logging.py')
-rw-r--r-- | Lib/test/test_logging.py | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/Lib/test/test_logging.py b/Lib/test/test_logging.py index dc49fc1..a2a136b 100644 --- a/Lib/test/test_logging.py +++ b/Lib/test/test_logging.py @@ -26,6 +26,7 @@ import logging.handlers import logging.config import codecs +import configparser import datetime import pickle import io @@ -1279,6 +1280,24 @@ class ConfigFileTest(BaseTest): # Original logger output is empty. self.assert_log_lines([]) + def test_config0_using_cp_ok(self): + # A simple config file which overrides the default settings. + with captured_stdout() as output: + file = io.StringIO(textwrap.dedent(self.config0)) + cp = configparser.ConfigParser() + cp.read_file(file) + logging.config.fileConfig(cp) + logger = logging.getLogger() + # Won't output anything + logger.info(self.next_message()) + # Outputs a message + logger.error(self.next_message()) + self.assert_log_lines([ + ('ERROR', '2'), + ], stream=output) + # Original logger output is empty. + self.assert_log_lines([]) + def test_config1_ok(self, config=config1): # A config file defining a sub-parser as well. with captured_stdout() as output: |