def setUp(self): self.gradient_start = 0 self.gradient_stop = 952 self.gradient_steps = 20 self.gradient = util.gradient(self.gradient_start, self.gradient_stop, self.gradient_steps) self.reverse_gradient = util.gradient(self.gradient_stop, self.gradient_start, self.gradient_steps)
class TestGradient(object): """tests for the gradient function""" gradient_start = 0 gradient_stop = 952 gradient_steps = 20 gradient = util.gradient(gradient_start, gradient_stop, gradient_steps) reverse_gradient = util.gradient(gradient_stop, gradient_start, gradient_steps) def test_gradient_size(self): assert self.gradient_steps == len(self.gradient) def test_gradient_end_points(self): assert self.gradient_start == self.gradient[0] assert self.gradient_stop == self.gradient[-1] def test_gradient_order(self): ordered = sorted(self.gradient) assert ordered == self.gradient ordered = sorted(self.reverse_gradient) ordered.reverse() assert ordered == self.reverse_gradient