The result of :method:`CaptureFixture.readouterr`.
| 473 | @final |
| 474 | @functools.total_ordering |
| 475 | class CaptureResult(Generic[AnyStr]): |
| 476 | """The result of :method:`CaptureFixture.readouterr`.""" |
| 477 | |
| 478 | __slots__ = ("out", "err") |
| 479 | |
| 480 | def __init__(self, out: AnyStr, err: AnyStr) -> None: |
| 481 | self.out: AnyStr = out |
| 482 | self.err: AnyStr = err |
| 483 | |
| 484 | def __len__(self) -> int: |
| 485 | return 2 |
| 486 | |
| 487 | def __iter__(self) -> Iterator[AnyStr]: |
| 488 | return iter((self.out, self.err)) |
| 489 | |
| 490 | def __getitem__(self, item: int) -> AnyStr: |
| 491 | return tuple(self)[item] |
| 492 | |
| 493 | def _replace( |
| 494 | self, *, out: Optional[AnyStr] = None, err: Optional[AnyStr] = None |
| 495 | ) -> "CaptureResult[AnyStr]": |
| 496 | return CaptureResult( |
| 497 | out=self.out if out is None else out, err=self.err if err is None else err |
| 498 | ) |
| 499 | |
| 500 | def count(self, value: AnyStr) -> int: |
| 501 | return tuple(self).count(value) |
| 502 | |
| 503 | def index(self, value) -> int: |
| 504 | return tuple(self).index(value) |
| 505 | |
| 506 | def __eq__(self, other: object) -> bool: |
| 507 | if not isinstance(other, (CaptureResult, tuple)): |
| 508 | return NotImplemented |
| 509 | return tuple(self) == tuple(other) |
| 510 | |
| 511 | def __hash__(self) -> int: |
| 512 | return hash(tuple(self)) |
| 513 | |
| 514 | def __lt__(self, other: object) -> bool: |
| 515 | if not isinstance(other, (CaptureResult, tuple)): |
| 516 | return NotImplemented |
| 517 | return tuple(self) < tuple(other) |
| 518 | |
| 519 | def __repr__(self) -> str: |
| 520 | return f"CaptureResult(out={self.out!r}, err={self.err!r})" |
| 521 | |
| 522 | |
| 523 | class MultiCapture(Generic[AnyStr]): |
no outgoing calls