def test_decorate_tmux_style(self): self.assertEqual( "#[fg=bold]example", Colorsh.decorate("example", enc="tmux", style=Style(["bold"]))) self.assertEqual( "#[fg=bold,italics]example", Colorsh.decorate("example", enc="tmux", style=Style(["bold", "italics"])))
def test_decorate_ansi_style_takes_only_first_style_from_list(self): self.assertEqual( ANSI_ESCAPE_SEQUENCE + "1m" + "example" + ANSI_ESCAPE_SEQUENCE + "0m", Colorsh.decorate("example", enc="ansi", style=Style(["bold", "faint", 3])))
def test_parse_from_not_uniform_list_with_another_list_inside(self): s = Style([1, ["faint", Styles.italics]]) self.assertEqual(s.styles[0].name, "bold") self.assertEqual(s.styles[0].value, 1) self.assertEqual(s.styles[1].name, "faint") self.assertEqual(s.styles[1].value, 2) self.assertEqual(s.styles[2].name, "italics") self.assertEqual(s.styles[2].value, 3)
def test_decorate_tmux_color_and_style(self): self.assertEqual( "#[fg=colour9,bold,italics,bg=colour12]example", Colorsh.decorate("example", enc="tmux", fg=Color("red"), bg=Color("blue"), style=Style(["bold", "italics"])))
def test_decorate_ansi_color_and_style(self): self.assertEqual( ANSI_ESCAPE_SEQUENCE + "1;38;5;9;48;5;12m" + "example" + ANSI_ESCAPE_SEQUENCE + "0m", Colorsh.decorate("example", enc="ansi", fg=Color("red"), bg=Color("blue"), style=Style(["bold"])))
def test_parse_from_int_not_in_range(self): s = Style(1984) self.assertEqual(s.styles, [])
def test_parse_from_int_in_range(self): s = Style(1) self.assertEqual(s.styles[0].name, "bold") self.assertEqual(s.styles[0].value, 1)
def test_parse_from_uniform_list(self): s = Style(["bold", "faint"]) self.assertEqual(s.styles[0].name, "bold") self.assertEqual(s.styles[0].value, 1) self.assertEqual(s.styles[1].name, "faint") self.assertEqual(s.styles[1].value, 2)
def test_parse_from_styles_enum(self): s = Style(Styles.bold) self.assertEqual(s.styles[0].name, "bold") self.assertEqual(s.styles[0].value, 1)
def test_parse_from_string_not_in_range(self): s = Style("damnNiceStyleButNotSupported") self.assertEqual(s.styles, [])
def test_decorate_ansi_style(self): self.assertEqual( ANSI_ESCAPE_SEQUENCE + "1m" + "example" + ANSI_ESCAPE_SEQUENCE + "0m", Colorsh.decorate("example", enc="ansi", style=Style(["bold"])))