diff --git a/rich/file_proxy.py b/rich/file_proxy.py index 4b0b0da6c2..e32523bd6b 100644 --- a/rich/file_proxy.py +++ b/rich/file_proxy.py @@ -55,3 +55,6 @@ def flush(self) -> None: def fileno(self) -> int: return self.__file.fileno() + + def isatty(self) -> bool: + return self.__file.isatty() diff --git a/tests/test_file_proxy.py b/tests/test_file_proxy.py index 2ec4d789e3..ff23493d14 100644 --- a/tests/test_file_proxy.py +++ b/tests/test_file_proxy.py @@ -35,3 +35,10 @@ def test_new_lines(): assert file.getvalue() == "-\n" file_proxy.flush() assert file.getvalue() == "-\n-\n" + + +def test_isatty_delegates_to_proxied_file(): + file = io.StringIO() + console = Console(file=file) + file_proxy = FileProxy(console, file) + assert file_proxy.isatty() == file.isatty()