def test_color_mutation_doesnt_stray_beyond_bounds(self, mock_rand): mock_rand.side_effect = [-4, 258, 0] color = Color(24, 149, 134) new_color = color.mutate() mock_rand.assert_any_call(8, 40) mock_rand.assert_any_call(133, 165) mock_rand.assert_any_call(118, 150) self.assertEqual(new_color._r, 0) self.assertEqual(new_color._g, 255) self.assertEqual(new_color._b, 0)
def test_can_mutate_color(self, mock_rand): mock_rand.side_effect = [23, 45, 67] color = Color(24, 149, 134) new_color = color.mutate() mock_rand.assert_any_call(8, 40) mock_rand.assert_any_call(133, 165) mock_rand.assert_any_call(118, 150) self.assertEqual(new_color._r, 23) self.assertEqual(new_color._g, 45) self.assertEqual(new_color._b, 67)