Skip to content

Commit 15ce8f3

Browse files
committed
test filters
1 parent 2302516 commit 15ce8f3

File tree

1 file changed

+29
-0
lines changed

1 file changed

+29
-0
lines changed

tests/test_filters.py

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
from rich.color import Color as RichColor
2+
from rich.color import ColorType
3+
from rich.segment import Segment
4+
from rich.style import Style
5+
from rich.terminal_theme import MONOKAI
6+
7+
from textual.color import Color
8+
from textual.filter import ANSIToTruecolor
9+
10+
11+
def test_ansi_to_truecolor_8_bit_dim():
12+
"""Test that converting an 8-bit color with dim doesn't crash.
13+
14+
Regression test for https://github.com/Textualize/textual/issues/5946
15+
16+
"""
17+
# Given
18+
ansi_filter = ANSIToTruecolor(MONOKAI)
19+
test_color = RichColor("color(253)", ColorType.EIGHT_BIT, number=253)
20+
test_style = Style(color=test_color, dim=True)
21+
segments = [Segment("This should not crash", style=test_style)]
22+
background_color = Color(0, 0, 0)
23+
24+
# When
25+
# This line will crash if the bug is present
26+
new_segments = ansi_filter.apply(segments, background_color)
27+
28+
# Then
29+
assert new_segments is not None

0 commit comments

Comments
 (0)