Skip to main content

captured_output

Return a context manager used by captured_stdout/stdin/stderr that temporarily replaces the sys stream stream_name with a StringIO.

def captured_output(
stream_name: string
) - > contextmanager

Return a context manager used by captured_stdout/stdin/stderr that temporarily replaces the sys stream stream_name with a StringIO.

Parameters

NameTypeDescription
stream_namestringThe name of the attribute in the sys module to be temporarily replaced, such as 'stdout', 'stderr', or 'stdin'

Returns

TypeDescription
contextmanagerA context manager that yields the StringIO object replacing the original system stream