Skip to main content



def capture_stderr() -> Generator[List[bytes], None, None]

Context manager for capturing output to stderr. A stderr output of anything run in its context will be captured in the target variable of the with statement.


List of captured lines.


class GeneratorContextManager(contextlib._GeneratorContextManager)

Extended contextlib._GeneratorContextManager that provides content property.


def content() -> Any

Fully consumes the underlying generator and returns the yielded value.


Value that would normally be the target variable of an associated with statement.


  • StopIteration - If the underlying generator is already exhausted.


class ContextManager()

Class for decorating generator functions that should act as a context manager.

Just like with contextlib.contextmanager, the generator returned from the decorated function must yield exactly one value that will be used as the target variable of the with statement. If the same function with the same arguments is called again from within previously generated context, the generator will be ignored and the target variable will be reused.


  • function - Decorated generator function.
  • generators - Mapping of serialized function arguments to generators.
  • values - Mapping of serialized function arguments to yielded values.