diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-05-14 20:18:28 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-05-14 20:18:28 +0000 |
commit | f8363b456f1ab31ee56abad579b215af195093d5 (patch) | |
tree | b1500c675c2e0a55fb75721a854e1510acf7c862 /tests/test_rich_print.py | |
parent | Initial commit. (diff) | |
download | rich-f8363b456f1ab31ee56abad579b215af195093d5.tar.xz rich-f8363b456f1ab31ee56abad579b215af195093d5.zip |
Adding upstream version 9.11.0.upstream/9.11.0upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'tests/test_rich_print.py')
-rw-r--r-- | tests/test_rich_print.py | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/tests/test_rich_print.py b/tests/test_rich_print.py new file mode 100644 index 0000000..18467c6 --- /dev/null +++ b/tests/test_rich_print.py @@ -0,0 +1,42 @@ +import io + +import rich +from rich.console import Console + + +def test_get_console(): + console = rich.get_console() + assert isinstance(console, Console) + + +def test_reconfigure_console(): + rich.reconfigure(width=100) + assert rich.get_console().width == 100 + + +def test_rich_print(): + console = rich.get_console() + output = io.StringIO() + backup_file = console.file + try: + console.file = output + rich.print("foo", "bar") + rich.print("foo\n") + rich.print("foo\n\n") + assert output.getvalue() == "foo bar\nfoo\n\nfoo\n\n\n" + finally: + console.file = backup_file + + +def test_rich_print_X(): + console = rich.get_console() + output = io.StringIO() + backup_file = console.file + try: + console.file = output + rich.print("foo") + rich.print("fooX") + rich.print("fooXX") + assert output.getvalue() == "foo\nfooX\nfooXX\n" + finally: + console.file = backup_file |