| 1 |
from unittest import TestCase |
| 2 |
|
| 3 |
from beets.util.layout import split_into_lines |
| 4 |
|
| 5 |
|
| 6 |
class LayoutTestCase(TestCase): |
| 7 |
def test_split_into_lines(self): |
| 8 |
# Test uncolored text |
| 9 |
txt = split_into_lines("test test test", 5, 5) |
| 10 |
assert txt == ["test", "test", "test"] |
| 11 |
# Test multiple colored texts |
| 12 |
colored_text = "\x1b[31mtest \x1b[39;49;00m" * 3 |
| 13 |
split_txt = [ |
| 14 |
"\x1b[31mtest\x1b[39;49;00m", |
| 15 |
"\x1b[31mtest\x1b[39;49;00m", |
| 16 |
"\x1b[31mtest\x1b[39;49;00m", |
| 17 |
] |
| 18 |
txt = split_into_lines(colored_text, 5, 5) |
| 19 |
assert txt == split_txt |
| 20 |
# Test single color, multi space text |
| 21 |
colored_text = "\x1b[31m test test test \x1b[39;49;00m" |
| 22 |
txt = split_into_lines(colored_text, 5, 5) |
| 23 |
assert txt == split_txt |
| 24 |
# Test single color, different spacing |
| 25 |
colored_text = "\x1b[31mtest\x1b[39;49;00mtest test test" |
| 26 |
# ToDo: fix color_len to handle mid-text color escapes, and thus |
| 27 |
# split colored texts over newlines (potentially with dashes?) |
| 28 |
split_txt = ["\x1b[31mtest\x1b[39;49;00mt", "est", "test", "test"] |
| 29 |
txt = split_into_lines(colored_text, 5, 5) |
| 30 |
assert txt == split_txt |