Skip to main content

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

TypeDescription
ContextManagerA context manager that yields a StringIO object containing the captured standard output stream