| 1 |
from unittest import TestCase |
| 2 |
|
| 3 |
from beets.util.color import color_split, uncolorize |
| 4 |
|
| 5 |
|
| 6 |
class ColorTestCase(TestCase): |
| 7 |
def test_uncolorize(self): |
| 8 |
assert "test" == uncolorize("test") |
| 9 |
txt = uncolorize("\x1b[31mtest\x1b[39;49;00m") |
| 10 |
assert "test" == txt |
| 11 |
txt = uncolorize("\x1b[31mtest\x1b[39;49;00m test") |
| 12 |
assert "test test" == txt |
| 13 |
txt = uncolorize("\x1b[31mtest\x1b[39;49;00mtest") |
| 14 |
assert "testtest" == txt |
| 15 |
txt = uncolorize("test \x1b[31mtest\x1b[39;49;00m test") |
| 16 |
assert "test test test" == txt |
| 17 |
|
| 18 |
def test_color_split(self): |
| 19 |
exp = ("test", "") |
| 20 |
res = color_split("test", 5) |
| 21 |
assert exp == res |
| 22 |
exp = ("\x1b[31mtes\x1b[39;49;00m", "\x1b[31mt\x1b[39;49;00m") |
| 23 |
res = color_split("\x1b[31mtest\x1b[39;49;00m", 3) |
| 24 |
assert exp == res |