From 14bfe781f07e065a7bb00ac7057e0d061c907ad3 Mon Sep 17 00:00:00 2001 From: Robert O'Shea Date: Thu, 28 Jul 2022 02:13:51 +0100 Subject: [PATCH] Added "file-like" methods to DontReadFromInput --- src/_pytest/capture.py | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/src/_pytest/capture.py b/src/_pytest/capture.py index d6cf42c3b..e0d56264f 100644 --- a/src/_pytest/capture.py +++ b/src/_pytest/capture.py @@ -203,12 +203,38 @@ class DontReadFromInput: def fileno(self) -> int: raise UnsupportedOperation("redirected stdin is pseudofile, has no fileno()") + def flush(self) -> None: + raise UnsupportedOperation("redirected stdin is pseudofile, has no flush()") + def isatty(self) -> bool: return False def close(self) -> None: pass + def readable(self) -> bool: + return False + + def seek(self, offset: int) -> int: + raise UnsupportedOperation("redirected stdin is pseudofile, has no seek(int)") + + def seekable(self) -> bool: + return False + + def tell(self) -> int: + raise UnsupportedOperation("redirected stdin is pseudofile, has no tell()") + + def truncate(self, size: int) -> None: + raise UnsupportedOperation("cannont truncate stdin") + + def write(self, byte) -> None: + raise UnsupportedOperation("cannot write to stdin") + + writelines = write + + def writable(self) -> bool: + return False + @property def buffer(self): return self