def test_palette_has_index(self): palette = Palette(a=Color.from_hex("#FF0000")) index = palette._tree self.assertTrue(index is not None) # def test_rebuild_changes_index(self): # palette = Palette() # palette["a"] = (1, 2) # # index = palette.distance_index # palette["b"] = (2, 4) # # self.assertNotEquals(palette.distance_index, index)
def test_nearest_web_red(self): palette = Palette(**WEB_PALETTE) red = Color.from_hex("#FF0000") self.assertEquals(palette.find_nearest(red)[0], "red") self.assertEquals(palette.find_nearest(red)[1], red)
def test_nearest_web_almost_white(self): palette = Palette(**WEB_PALETTE) almost_white = Color.from_hex("#FFFFFe") white = Color.from_hex("#FFFFFF") self.assertEquals(palette.find_nearest(almost_white)[0], "white") self.assertEquals(palette.find_nearest(almost_white)[1], white)
def test_palette_has_index(self): palette = Palette(a=Color.from_hex("#FF0000")) index = palette._tree self.assertTrue(index is not None)