mirror of
https://github.com/Textualize/rich.git
synced 2025-08-04 18:18:22 +00:00
Test to ensure NullFile set as Console.file when stdout null
This commit is contained in:
parent
1601f89bf1
commit
97bffbc7b1
1 changed files with 10 additions and 0 deletions
|
@ -9,6 +9,7 @@ from unittest import mock
|
|||
import pytest
|
||||
|
||||
from rich import errors
|
||||
from rich._null_file import NullFile
|
||||
from rich.color import ColorSystem
|
||||
from rich.console import (
|
||||
CaptureError,
|
||||
|
@ -238,6 +239,15 @@ def test_print_json_indent_none():
|
|||
assert result == expected
|
||||
|
||||
|
||||
def test_console_null_file(monkeypatch):
|
||||
# When stdout and stderr are null, Console.file should be replaced with NullFile
|
||||
monkeypatch.setattr("sys.stdout", None)
|
||||
monkeypatch.setattr("sys.stderr", None)
|
||||
|
||||
console = Console()
|
||||
assert isinstance(console.file, NullFile)
|
||||
|
||||
|
||||
def test_log():
|
||||
console = Console(
|
||||
file=io.StringIO(),
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue