def color_to_hex(color): """ Given either an hexadecimal or HTML color name, return a the hex approximation without the `#`. """ if color.startswith("#"): return x256.from_hex(color.strip("#")) else: return x256.from_html_name(color)
def test_from_html_name(self): color = x256.from_html_name(self.html_name_red) self.assertEqual(self.red_color, color) color = x256.from_html_name(self.html_name_blue) self.assertEqual(self.blue_color, color)