mirror of
https://github.com/python/cpython.git
synced 2025-08-04 08:59:19 +00:00
Closes #16110: fileConfig now accepts a pre-initialised ConfigParser instance.
This commit is contained in:
parent
96df7da0ac
commit
cf9e2f2420
3 changed files with 52 additions and 9 deletions
|
@ -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:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue