simplify StdCaptureFD snapshot reading
This commit is contained in:
parent
ea18e9656b
commit
e2bb81124c
|
@ -538,17 +538,16 @@ class StdCaptureFD(Capture):
|
||||||
|
|
||||||
def readouterr(self):
|
def readouterr(self):
|
||||||
""" return snapshot value of stdout/stderr capturings. """
|
""" return snapshot value of stdout/stderr capturings. """
|
||||||
if hasattr(self, "out"):
|
out = self._readsnapshot('out')
|
||||||
out = self._readsnapshot(self.out.tmpfile)
|
err = self._readsnapshot('err')
|
||||||
else:
|
return out, err
|
||||||
out = ""
|
|
||||||
if hasattr(self, "err"):
|
def _readsnapshot(self, name):
|
||||||
err = self._readsnapshot(self.err.tmpfile)
|
if hasattr(self, name):
|
||||||
else:
|
f = getattr(self, name).tmpfile
|
||||||
err = ""
|
else:
|
||||||
return [out, err]
|
return ''
|
||||||
|
|
||||||
def _readsnapshot(self, f):
|
|
||||||
f.seek(0)
|
f.seek(0)
|
||||||
res = f.read()
|
res = f.read()
|
||||||
enc = getattr(f, "encoding", None)
|
enc = getattr(f, "encoding", None)
|
||||||
|
|
Loading…
Reference in New Issue