def test_hexa_simple(self): str = '#abc' color = get_color(str) self.assertEqual(color.hexval(), '0xaabbcc') str = '#aabbcc' color = get_color(str) self.assertEqual(color.hexval(), '0xaabbcc')
def test_wrong_color(self): str = '' color = get_color(str) self.assertEqual(color.hexval(), '0x000000') str = '#abt' color = get_color(str) self.assertEqual(color.hexval(), '0x000000') str = '#aabbtt' color = get_color(str) self.assertEqual(color.hexval(), '0x000000') str = 'cian' color = get_color(str) self.assertEqual(color.hexval(), '0x000000')
def test_name(self): for data in (('green', '0x008000'), ('purple', '0x800080'), ('cyan', '0x00ffff')): name, expected = data color = get_color(name) self.assertEqual(color.hexval(), expected)
def test_rgb(self): str = 'rgb(230, 100, 180)' color = get_color(str) self.assertEqual(color.hexval(), '0xe664b4')