Found 2 bookmarks
Newest
Python: capture stdout and stderr in unittest - Adam Johnson
Python: capture stdout and stderr in unittest - Adam Johnson
When testing code that outputs to the terminal through either standard out (stdout) or standard error (stderr), you might want to capture that output and make assertions on it. To do so, use contextlib.redirect_stdout() and contextlib.redirect_stderr() to redirect the respective output streams to in-memory buffers that you can then inspect and assert on.
·adamj.eu·
Python: capture stdout and stderr in unittest - Adam Johnson