예제 #1
0
 def test_decorate_tmux_color_fg_bg(self):
     self.assertEqual(
         "#[fg=colour9,bg=colour12]example",
         Colorsh.decorate("example",
                          enc="tmux",
                          fg=Color("red"),
                          bg=Color("blue")))
예제 #2
0
 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"])))
예제 #3
0
 def test_decorate_ansi_color_fg_bg(self):
     self.assertEqual(
         ANSI_ESCAPE_SEQUENCE + "0;38;5;9;48;5;12m" + "example" +
         ANSI_ESCAPE_SEQUENCE + "0m",
         Colorsh.decorate("example",
                          enc="ansi",
                          fg=Color("red"),
                          bg=Color("blue")))
예제 #4
0
    def test_parse_from_string_in_term16_range(self):
        c = Color("black")
        self.assertEqual(c.name, "black")
        self.assertEqual(c.value, 0)

        c = Color("white")
        self.assertEqual(c.name, "white")
        self.assertEqual(c.value, 15)
예제 #5
0
    def test_parse_from_int_in_8bit_range(self):
        c = Color(10)
        self.assertEqual(c.name, "lime")
        self.assertEqual(c.value, 10)

        c = Color(240)
        self.assertEqual(c.name, None)
        self.assertEqual(c.value, 240)
예제 #6
0
 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"])))
예제 #7
0
    def test_parse_from_string_is_case_insensitive(self):
        c = Color("blue")
        self.assertEqual(c.name, "blue")
        self.assertEqual(c.value, 12)

        c = Color("BLUE")
        self.assertEqual(c.name, "blue")
        self.assertEqual(c.value, 12)

        c = Color("Blue")
        self.assertEqual(c.name, "blue")
        self.assertEqual(c.value, 12)
예제 #8
0
 def test_setting_value_also_sets_name(self):
     c = Color()
     c.value = 9
     self.assertEqual(c.name, "red")
     self.assertEqual(c.value, 9)
예제 #9
0
 def test_parse_from_term16(self):
     c = Color(Term16.red)
     self.assertEqual(c.name, "red")
     self.assertEqual(c.value, 9)
예제 #10
0
 def test_parse_from_invalid_type(self):
     c = Color(float(1337.0))
     self.assertEqual(c.name, None)
     self.assertEqual(c.value, None)
예제 #11
0
 def test_parse_from_int_not_in_8bit_range(self):
     c = Color(1984)
     self.assertEqual(c.name, None)
     self.assertEqual(c.value, None)
예제 #12
0
 def test_parse_from_string_is_whitespace_resilient(self):
     c = Color("\tyellow\r\n           ")
     self.assertEqual(c.name, "yellow")
     self.assertEqual(c.value, 11)
예제 #13
0
 def test_parse_from_string_not_in_term16_range(self):
     c = Color("toopretty")
     self.assertEqual(c.name, None)
     self.assertEqual(c.value, None)