mirror of
https://github.com/Textualize/rich.git
synced 2025-08-04 10:08:40 +00:00
themed tracebacks
This commit is contained in:
parent
26345530ad
commit
ebb4eaa26f
15 changed files with 193 additions and 107 deletions
|
@ -2,8 +2,10 @@ import io
|
|||
import os
|
||||
import tempfile
|
||||
|
||||
import pytest
|
||||
|
||||
from rich.style import Style
|
||||
from rich.theme import Theme
|
||||
from rich.theme import Theme, ThemeStack, ThemeStackError
|
||||
|
||||
|
||||
def test_inherit():
|
||||
|
@ -36,3 +38,16 @@ def test_read():
|
|||
write_theme.write(theme.config)
|
||||
load_theme = Theme.read(filename)
|
||||
assert theme.styles == load_theme.styles
|
||||
|
||||
|
||||
def test_theme_stack():
|
||||
theme = Theme({"warning": "red"})
|
||||
stack = ThemeStack(theme)
|
||||
assert stack.get("warning") == Style.parse("red")
|
||||
new_theme = Theme({"warning": "bold yellow"})
|
||||
stack.push_theme(new_theme)
|
||||
assert stack.get("warning") == Style.parse("bold yellow")
|
||||
stack.pop_theme()
|
||||
assert stack.get("warning") == Style.parse("red")
|
||||
with pytest.raises(ThemeStackError):
|
||||
stack.pop_theme()
|
Loading…
Add table
Add a link
Reference in a new issue