No stdout/stderr is captured with invoke
during tests in combination with structlog
#2827
Labels
invoke
during tests in combination with structlog
#2827
There seems to be an issue with capturing stdout/stderr when using
structlog
with stdlibLogger
in tests.I've raised an issue with
structlog
but they are not convinced the problem originates there since the logs are simply passed to the stdlib Logger.I've traced this down to the click's
isolation
context manager which seems to replacesys.stdout
/sys.stderr
with mocks during testing and my guess would be that this could have something to do with the problem but I'm hoping you may know better.I've tried numerous things like explicitly setting a
StreamHandler(sys.stderr)
to the stdlibbasicConfig
, experimented withmix_stderr
etc. nothing helped. Any ideas how to fix or work around this issue would be most welcome, thank you.An example
A test case:
Expected
Hello! (to be printed)
assertion to pass
Actual
nothing printed (result.stdout is empty)
assertion failure:
The text was updated successfully, but these errors were encountered: