File tree Expand file tree Collapse file tree 1 file changed +29
-0
lines changed Expand file tree Collapse file tree 1 file changed +29
-0
lines changed Original file line number Diff line number Diff line change 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
You can’t perform that action at this time.
0 commit comments