mirror of
https://github.com/python/cpython.git
synced 2025-08-31 05:58:33 +00:00
Issue #20242: Fixed basicConfig() format strings for the alternative formatting styles.
This commit is contained in:
parent
66c9350a89
commit
1fd1202072
3 changed files with 29 additions and 7 deletions
|
@ -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')
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue