Issue #20242: Fixed basicConfig() format strings for the alternative formatting styles.

This commit is contained in:
Vinay Sajip 2014-01-13 21:59:56 +00:00
parent 66c9350a89
commit 1fd1202072
3 changed files with 29 additions and 7 deletions

View file

@ -3337,6 +3337,22 @@ 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):
logging.basicConfig(filename='test.log')