def test_empty_colors(self): limit = Limit() self.assertFalse(limit) colors = [(1, 1, 1), (2, 2, 2)] limit.limit_colors(colors, ListMath) self.assertEqual(colors, [(1, 1, 1), (2, 2, 2)])
def test_colors(self): limit = Limit( ratio=Fraction(3, 4), knee=Fraction(1, 4), gain=Fraction(1, 2)) self.assertTrue(limit) cl = color_list_test.COLORS1[:] limit.limit_colors(cl, ListMath) c = 106 + 1 / 4 expected = [(c, 0, 0), (0, c, 0), (0, 0, c), (c, c, c)] self.assertEqual(len(expected), len(cl)) asserts = 0 for exp, act in zip(expected, cl): for e, a in zip(exp, act): self.assertAlmostEqual(e, a) asserts += 1 self.assertEqual(asserts, 12)