AlbertUnruhUtils.utils.capturing module

class AlbertUnruhUtils.utils.capturing.STDCopy(std: Literal['in', 'out', 'err', 'stdin', 'stdout', 'stderr'], *args, **kwargs)

Bases: TextIOWrapper

Captures sys.std*.

Usage

You can either set the sys.std*-attribute to this class, or you can use it inside a with-statements, which will then capture just inside the statement.

captured

Everything which got captured.

Type:

str

Notes

stdin (or in) doesn’t work at the moment and will raise an EOFError.

param std:

The sys.std* to capture.

type std:

_STD

param args:

args and kwargs for TextIOWrapper

type args:

param kwargs:

args and kwargs for TextIOWrapper

type kwargs:

captured: str
write(s)

Write string to stream. Returns the number of characters written (which is always equal to the length of the string).

read(size=-1)

Read at most n characters from stream.

Read from underlying buffer until we have n characters or we hit EOF. If n is negative or omitted, read until EOF.

Parameters:

std (Literal['in', 'out', 'err', 'stdin', 'stdout', 'stderr']) –