Skip to content

Commit f49e27e

Browse files
committed
test case for 88/256 ANSI color codes
1 parent fa3f668 commit f49e27e

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

test/test_regression.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,20 @@ def test_numeric_column_headers():
127127
assert_equal(result, expected)
128128

129129

130+
def test_88_256_ANSI_color_codes():
131+
"Regression: color codes for terminals with 88/256 colors (issue #26)"
132+
colortable = [('\x1b[48;5;196mred\x1b[49m',
133+
'\x1b[38;5;196mred\x1b[39m')]
134+
colorlessheaders = ('background', 'foreground')
135+
formatted = tabulate(colortable, colorlessheaders, 'pipe')
136+
expected = "\n".join([
137+
'| background | foreground |',
138+
'|:-------------|:-------------|',
139+
'| \x1b[48;5;196mred\x1b[49m | \x1b[38;5;196mred\x1b[39m |'])
140+
print("expected: %r\n\ngot: %r\n" % (expected, formatted))
141+
assert_equal(expected, formatted)
142+
143+
130144
def test_column_with_mixed_value_types():
131145
"Regression: mixed value types in the same column (issue #31)"
132146
expected = '\n'.join([

0 commit comments

Comments
 (0)