python-coloredlogs icon indicating copy to clipboard operation
python-coloredlogs copied to clipboard

output not being redirected by contextlib

Open roedoejet opened this issue 5 years ago • 0 comments

When testing log outputs I sometimes use io and contextlib.redirect_stderr in the following way:

import io
from contextlib import redirect_stderr

log_output = io.StringIO()
with redirect_stderr(log_output):
    cause_some_horrible_error()

Up until 14.1, this would work as expected. That is, running log_output.getvalue() would return the output of the logged error. However, now log_output.getvalue() just returns an empty string. This seems broken in 14.1, 14.2, 14.3 and 15.0.

roedoejet avatar Dec 18 '20 21:12 roedoejet