Skip to content

Commit ac7ebfa

Browse files
authored
doc: internal: fix MultiCapture.readouterr (#6878)
Remove wrong docstring: it might actually return bytes. Replace it with a type annotation which is clear enough.
1 parent db92cea commit ac7ebfa

File tree

1 file changed

+10
-6
lines changed

1 file changed

+10
-6
lines changed

src/_pytest/capture.py

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -510,12 +510,16 @@ def stop_capturing(self):
510510
if self.in_:
511511
self.in_.done()
512512

513-
def readouterr(self):
514-
""" return snapshot unicode value of stdout/stderr capturings. """
515-
return CaptureResult(
516-
self.out.snap() if self.out is not None else "",
517-
self.err.snap() if self.err is not None else "",
518-
)
513+
def readouterr(self) -> CaptureResult:
514+
if self.out:
515+
out = self.out.snap()
516+
else:
517+
out = ""
518+
if self.err:
519+
err = self.err.snap()
520+
else:
521+
err = ""
522+
return CaptureResult(out, err)
519523

520524

521525
class NoCapture:

0 commit comments

Comments
 (0)