| 1 |
from rich.console import Console |
| 2 |
|
| 3 |
|
| 4 |
def test_jupyter(): |
| 5 |
console = Console(force_jupyter=True) |
| 6 |
assert console.width == 115 |
| 7 |
assert console.height == 100 |
| 8 |
assert console.color_system == "truecolor" |
| 9 |
|
| 10 |
|
| 11 |
def test_jupyter_columns_env(): |
| 12 |
console = Console(_environ={"JUPYTER_COLUMNS": "314"}, force_jupyter=True) |
| 13 |
assert console.width == 314 |
| 14 |
# width take precedence |
| 15 |
console = Console(width=40, _environ={"JUPYTER_COLUMNS": "314"}, force_jupyter=True) |
| 16 |
assert console.width == 40 |
| 17 |
# Should not fail |
| 18 |
console = Console( |
| 19 |
width=40, _environ={"JUPYTER_COLUMNS": "broken"}, force_jupyter=True |
| 20 |
) |
| 21 |
|
| 22 |
|
| 23 |
def test_jupyter_lines_env(): |
| 24 |
console = Console(_environ={"JUPYTER_LINES": "220"}, force_jupyter=True) |
| 25 |
assert console.height == 220 |
| 26 |
# height take precedence |
| 27 |
console = Console(height=40, _environ={"JUPYTER_LINES": "220"}, force_jupyter=True) |
| 28 |
assert console.height == 40 |
| 29 |
# Should not fail |
| 30 |
console = Console( |
| 31 |
width=40, _environ={"JUPYTER_LINES": "broken"}, force_jupyter=True |
| 32 |
) |