def test_Particle_speed_should_remain_constant(): almost_eq = approximately_eq(13) assert_speed_unchanged = assert_evolution(lambda:abs(p.vel), almost_eq) p = Particle(30, 40, 50, 60, 70) for dt in xrange(10,30,1): p.move(dt/1000.0) assert_speed_unchanged()
def test_vector_normalized_should_not_change_direction(vector): close_enough = approximately_eq(15) norm_times_size = vector.normalized() * abs(vector) for n, v in zip(norm_times_size, vector): assert close_enough(n, v)
def test_vector_normalize_should_make_unit_vector(vector): vector.normalize() assert approximately_eq(15)(abs(vector), 1)
def test_vector_normalized_should_return_unit_vector(vector): assert approximately_eq(15)(abs(vector.normalized()), 1)