captured_stdout
Capture the output of sys.stdout:
with captured_stdout() as stdout:
print("hello")
self.assertEqual(stdout.getvalue(), "hello\n")
def captured_stdout() - > ContextManager
Capture the output of sys.stdout:
Returns
| Type | Description |
|---|---|
ContextManager | A context manager that yields a StringIO object containing the captured standard output stream |