Open tonybaloney opened 2 years ago
I just ran into this! I didn't fix it myself since I found your TODO, but here's a test for it (based off the CPython test):
def test_stream_error_handling():
class BadStream(object):
def write(self, data):
raise RuntimeError('deliberate mistake')
class TestStreamHandler(picologging.StreamHandler):
def handleError(self, record):
self.error_record = record
handler = TestStreamHandler(BadStream())
record = picologging.makeLogRecord({})
handler.handle(record)
assert handler.error_record is record
handler = picologging.StreamHandler(BadStream())
with pytest.raises(RuntimeError, match="RuntimeError: deliberate mistake"):
handler.handle(record)
This test currently fails since TestStreamHandler handleError isn't being called.
https://github.com/microsoft/picologging/blob/f3eedeb49c627248b3861a7f0d21c2b2dc764cda/src/picologging/streamhandler.cxx#L65