Exemplo n.º 1
0
class CharStyleTests(unittest.TestCase):

    def setUp(self):
        self.style = CharStyle()

    def test_default_char_style(self):
        self.assertEqual(self.style.fg_color, termstr.Color.white)
        self.assertEqual(self.style.bg_color, termstr.Color.black)
        self.assertEqual(self.style.is_bold, False)
        self.assertEqual(self.style.is_underlined, False)

    def test_pickle_char_style(self):
        style = CharStyle()
        loaded_style = pickle.loads(pickle.dumps(style))
        self.assertEqual(style, loaded_style)
        self.assertTrue(style is loaded_style)

    def test_repr(self):
        self.assertEqual(repr(self.style),
                         "<CharStyle: fg:(255, 255, 255) bg:(0, 0, 0) attr:>")

    def test_code_for_term(self):
        self.assertEqual(self.style.code_for_term(),
                         "\x1b[0m\x1b[38;2;255;255;255m\x1b[48;2;0;0;0m")
Exemplo n.º 2
0
 def setUp(self):
     self.style = CharStyle()