def test_color_table_error_when_more_than_256_colors(self): x = np.array(range(100)) z = np.zeros(len(x)) d = np.array([[x, z, z], [z, x, z], [z, z, x]]) image = core.get_image(d) with self.assertRaises(RuntimeError): core.get_colors(image)
def test_no_color_table_error_when_less_equal_256_colors(self): x = np.array(range(85)) z = np.zeros(len(x)) d = np.array([[x, z, z], [z, x, z], [z, z, x]]) image = core.get_image(d) try: core.get_colors(image) except RuntimeError as e: msg = "`get_colors` RuntimeError on 255 distinct colors.\n{}" self.fail(msg.format(e))
def test_get_colors(self): colors = core.get_colors(self.flickinger_image) self.assertEqual( colors, Counter({ b'\xff\x00\x00': 42, b'\x00\x00\xff': 42, b'\xff\xff\xff': 16 }))
def test_logical_screen_descriptor(self): colors = core.get_colors(self.flickinger_image) self.assertEqual( core._get_logical_screen_descriptor(self.flickinger_image, colors), b'\x0a\x00\x0a\x00\x91\x00\x00')