class TestEbColor(BaseTestCase): def setup(self): self.color = EbColor() def test_init(self): color2 = EbColor(r=3, g=255, b=84) assert_equal(color2.r, 3) assert_equal(color2.g, 255) assert_equal(color2.b, 84) def test_init_default(self): assert_equal(self.color.r, 0) assert_equal(self.color.g, 0) assert_equal(self.color.b, 0) def test_from_block(self): block = Block() block.from_list([0x5f, 0x0a]) self.color.from_block(block, 0) assert_equal(self.color.r, 248) assert_equal(self.color.g, 144) assert_equal(self.color.b, 16) def test_to_block(self): block = Block() block.from_list([0] * 2) self.color.r = 248 self.color.g = 144 self.color.b = 16 self.color.to_block(block, 0) assert_list_equal(block.to_list(), [0x5f, 0x0a]) def test_from_tuple(self): self.color.from_tuple((20, 40, 69)) assert_equal(self.color.r, 20) assert_equal(self.color.g, 40) assert_equal(self.color.b, 69) def test_tuple(self): self.color.from_tuple((20, 40, 69)) assert_equal(self.color.tuple(), (20, 40, 69)) def test_from_list(self): self.color.from_list([20, 40, 69]) assert_equal(self.color.tuple(), (16, 40, 64)) self.color.from_list([55, 44, 33, 20, 40, 69], offset=2) assert_equal(self.color.tuple(), (32, 16, 40)) def test_to_list(self): self.color.from_tuple((20, 40, 69)) test_list = [0] * 5 self.color.to_list(test_list) assert_list_equal(test_list, [20, 40, 69, 0, 0]) self.color.to_list(test_list, 2) assert_list_equal(test_list, [20, 40, 20, 40, 69]) def test_list(self): self.color.from_tuple((20, 40, 69)) assert_equal(self.color.list(), [20, 40, 69])