_pytest._io.saferepr module

_try_repr_or_str(obj)[source]
_format_repr_exception(exc: BaseException, obj: Any)str[source]
_ellipsize(s: str, maxsize: int)str[source]
class SafeRepr(maxsize: int)[source]

Bases: reprlib.Repr

subclass of repr.Repr that limits the resulting size of repr() and includes information on exceptions raised during the call.

repr(x: Any)str[source]
repr_instance(x: Any, level: int)str[source]
safeformat(obj: Any)str[source]

return a pretty printed string for the given object. Failing __repr__ functions of user instances will be represented with a short exception info.

saferepr(obj: Any, maxsize: int = 240)str[source]

return a size-limited safe repr-string for the given object. Failing __repr__ functions of user instances will be represented with a short exception info and ‘saferepr’ generally takes care to never raise exceptions itself. This function is a wrapper around the Repr/reprlib functionality of the standard 2.6 lib.

class AlwaysDispatchingPrettyPrinter(indent=1, width=80, depth=None, stream=None, *, compact=False, sort_dicts=True)[source]

Bases: pprint.PrettyPrinter

PrettyPrinter that always dispatches (regardless of width).

_format(object, stream, indent, allowance, context, level)[source]
_pformat_dispatch(object, indent=1, width=80, depth=None, *, compact=False)[source]