mirror of
https://github.com/python/cpython.git
synced 2025-08-31 14:07:50 +00:00
bpo-36015: Handle StreamHandler representaton of stream with an integer name (GH-11908)
This commit is contained in:
parent
3918ad6b45
commit
ca87eebb22
2 changed files with 10 additions and 0 deletions
|
@ -760,6 +760,10 @@ class TestStreamHandler(logging.StreamHandler):
|
|||
def handleError(self, record):
|
||||
self.error_record = record
|
||||
|
||||
class StreamWithIntName(object):
|
||||
level = logging.NOTSET
|
||||
name = 2
|
||||
|
||||
class StreamHandlerTest(BaseTest):
|
||||
def test_error_handling(self):
|
||||
h = TestStreamHandler(BadStream())
|
||||
|
@ -797,6 +801,10 @@ class StreamHandlerTest(BaseTest):
|
|||
actual = h.setStream(old)
|
||||
self.assertIsNone(actual)
|
||||
|
||||
def test_can_represent_stream_with_int_name(self):
|
||||
h = logging.StreamHandler(StreamWithIntName())
|
||||
self.assertEqual(repr(h), '<StreamHandler 2 (NOTSET)>')
|
||||
|
||||
# -- The following section could be moved into a server_helper.py module
|
||||
# -- if it proves to be of wider utility than just test_logging
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue