MCPcopy Create free account
hub / github.com/pytest-dev/pytest / FDCapture

Class FDCapture

src/_pytest/capture.py:443–462  ·  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

441
442
443class FDCapture(FDCaptureBinary):
444 """Capture IO to/from a given OS-level file descriptor.
445
446 snap() produces text.
447 """
448
449 # Ignore type because it doesn't match the type in the superclass (bytes).
450 EMPTY_BUFFER = "" # type: ignore
451
452 def snap(self):
453 self._assert_state("snap", ("started", "suspended"))
454 self.tmpfile.seek(0)
455 res = self.tmpfile.read()
456 self.tmpfile.seek(0)
457 self.tmpfile.truncate()
458 return res
459
460 def writeorg(self, data):
461 """Write to original file descriptor."""
462 super().writeorg(data.encode("utf-8")) # XXX use encoding of original stream
463
464
465# MultiCapture

Callers 1

_get_multicaptureFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected