diff --git a/rich/console.py b/rich/console.py index 49cac1a2..3ec9a8aa 100644 --- a/rich/console.py +++ b/rich/console.py @@ -1005,7 +1005,8 @@ class Console: width: Optional[int] = None height: Optional[int] = None - for file_descriptor in _STD_STREAMS_OUTPUT if WINDOWS else _STD_STREAMS: + streams = _STD_STREAMS_OUTPUT if WINDOWS else _STD_STREAMS + for file_descriptor in streams: try: width, height = os.get_terminal_size(file_descriptor) except (AttributeError, ValueError, OSError): # Probably not a terminal diff --git a/tests/test_panel.py b/tests/test_panel.py index 2a1286a4..65eb9bc0 100644 --- a/tests/test_panel.py +++ b/tests/test_panel.py @@ -111,6 +111,7 @@ def test_title_text() -> None: console = Console( file=io.StringIO(), width=50, + height=20, legacy_windows=False, force_terminal=True, color_system="truecolor", @@ -119,7 +120,7 @@ def test_title_text() -> None: result = console.file.getvalue() print(repr(result)) - expected = "╭───────────────────────────────────\x1b[31m title \x1b[0m────────────────────────────────────╮\n│ Hello, World │\n╰──────────────────────────────────\x1b[1;35m subtitle \x1b[0m──────────────────────────────────╯\n" + expected = "╭────────────────────\x1b[31m title \x1b[0m─────────────────────╮\n│ Hello, World │\n╰───────────────────\x1b[1;35m subtitle \x1b[0m───────────────────╯\n" assert result == expected