| 1 | import unittest |
| 2 | from colored.colored import Colored |
| 3 | from colored.attributes import Style |
| 4 | from colored.library import Library |
| 5 | |
| 6 | |
| 7 | class TestStyles(unittest.TestCase): |
| 8 | |
| 9 | def setUp(self): |
| 10 | self.ESC: str = '\x1b[' |
| 11 | self.END: str = 'm' |
| 12 | self.UNDERLINE_COLOR: str = f'{self.ESC}4;58;5;' |
| 13 | |
| 14 | def test_style_code(self): |
| 15 | for code in Library.STYLES.values(): |
| 16 | style = Colored(code) |
| 17 | self.assertEqual(f'{self.ESC}{code}{self.END}', style.attribute()) |
| 18 | |
| 19 | def test_style_name(self): |
| 20 | for name, code in Library.STYLES.items(): |
| 21 | style = Colored(name) |
| 22 | self.assertEqual(f'{self.ESC}{code}{self.END}', style.attribute()) |
| 23 | |
| 24 | def test_underline_color(self): |
| 25 | for code in Library.COLORS.values(): |
| 26 | self.assertEqual(f'{self.UNDERLINE_COLOR}{code}{self.END}', Style.underline_color(color=code)) |
| 27 | |
| 28 | |
| 29 | if __name__ == '__main__': |
| 30 | unittest.main() |