summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_logging.py
diff options
context:
space:
mode:
authorƁukasz Langa <lukasz@langa.pl>2018-06-08 11:02:48 (GMT)
committerGitHub <noreply@github.com>2018-06-08 11:02:48 (GMT)
commit214f18e49feb6a9d6c05aa09a4bb304905e81334 (patch)
treee39653d73ef272826e492d4af2da4261e6ce6dea /Lib/test/test_logging.py
parent66f02aa32f1e4adb9f24cf186f8c495399d5ce9b (diff)
downloadcpython-214f18e49feb6a9d6c05aa09a4bb304905e81334.zip
cpython-214f18e49feb6a9d6c05aa09a4bb304905e81334.tar.gz
cpython-214f18e49feb6a9d6c05aa09a4bb304905e81334.tar.bz2
bpo-33802: Do not interpolate in ConfigParser while reading defaults (GH-7524)
This solves a regression in logging config due to changes in BPO-23835.
Diffstat (limited to 'Lib/test/test_logging.py')
-rw-r--r--Lib/test/test_logging.py43
1 files changed, 43 insertions, 0 deletions
diff --git a/Lib/test/test_logging.py b/Lib/test/test_logging.py
index 5098866..ba70b11 100644
--- a/Lib/test/test_logging.py
+++ b/Lib/test/test_logging.py
@@ -1451,6 +1451,49 @@ class ConfigFileTest(BaseTest):
self.apply_config(self.disable_test, disable_existing_loggers=False)
self.assertFalse(logger.disabled)
+ def test_defaults_do_no_interpolation(self):
+ """bpo-33802 defaults should not get interpolated"""
+ ini = textwrap.dedent("""
+ [formatters]
+ keys=default
+
+ [formatter_default]
+
+ [handlers]
+ keys=console
+
+ [handler_console]
+ class=logging.StreamHandler
+ args=tuple()
+
+ [loggers]
+ keys=root
+
+ [logger_root]
+ formatter=default
+ handlers=console
+ """).strip()
+ fd, fn = tempfile.mkstemp(prefix='test_logging_', suffix='.ini')
+ try:
+ os.write(fd, ini.encode('ascii'))
+ os.close(fd)
+ logging.config.fileConfig(
+ fn,
+ defaults=dict(
+ version=1,
+ disable_existing_loggers=False,
+ formatters={
+ "generic": {
+ "format": "%(asctime)s [%(process)d] [%(levelname)s] %(message)s",
+ "datefmt": "[%Y-%m-%d %H:%M:%S %z]",
+ "class": "logging.Formatter"
+ },
+ },
+ )
+ )
+ finally:
+ os.unlink(fn)
+
class SocketHandlerTest(BaseTest):