MCPcopy
hub / github.com/pytest-dev/pytest / FDCapture

Class FDCapture

src/_pytest/capture.py:581–601  ·  view source on GitHub ↗

Capture IO to/from a given OS-level file descriptor. snap() produces text.

Source from the content-addressed store, hash-verified

579
580
581class FDCapture(FDCaptureBase[str]):
582 """Capture IO to/from a given OS-level file descriptor.
583
584 snap() produces text.
585 """
586
587 EMPTY_BUFFER = ""
588
589 def snap(self) -> str:
590 self._assert_state("snap", ("started", "suspended"))
591 self.tmpfile.seek(0)
592 res = self.tmpfile.read()
593 self.tmpfile.seek(0)
594 self.tmpfile.truncate()
595 return res
596
597 def writeorg(self, data: str) -> None:
598 """Write to original file descriptor."""
599 self._assert_state("writeorg", ("started", "suspended"))
600 # XXX use encoding of original stream
601 os.write(self.targetfd_save, data.encode("utf-8"))
602
603
604# MultiCapture

Callers 1

_get_multicaptureFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected