From: Vinay Sajip Date: Mon, 13 Jan 2014 22:01:16 +0000 (+0000) Subject: Closes #20242: Merged fix from 3.3. X-Git-Tag: v3.4.0b3~159 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=30e6a64e7675b16c5ba501d98de4702c468b134d;p=python Closes #20242: Merged fix from 3.3. --- 30e6a64e7675b16c5ba501d98de4702c468b134d diff --cc Lib/test/test_logging.py index 3765f36aa6,814f68cc15..3fcc77acb4 --- a/Lib/test/test_logging.py +++ b/Lib/test/test_logging.py @@@ -3517,13 -3337,23 +3517,29 @@@ class BasicConfigTest(unittest.TestCase # level is not explicitly set self.assertEqual(logging.root.level, self.original_logging_level) + def test_strformatstyle(self): + with captured_stdout() as output: + logging.basicConfig(stream=sys.stdout, style="{") + logging.error("Log an error") + sys.stdout.seek(0) + self.assertEqual(output.getvalue().strip(), + "ERROR:root:Log an error") + + def test_stringtemplatestyle(self): + with captured_stdout() as output: + logging.basicConfig(stream=sys.stdout, style="$") + logging.error("Log an error") + sys.stdout.seek(0) + self.assertEqual(output.getvalue().strip(), + "ERROR:root:Log an error") + def test_filename(self): + + def cleanup(h1, h2, fn): + h1.close() + h2.close() + os.remove(fn) + logging.basicConfig(filename='test.log') self.assertEqual(len(logging.root.handlers), 1)