def test_pygame2_math_base_Vector_epsilon(self): # __doc__ (as of 2010-01-06) for pygame2.math.base.Vector.epsilon: # Gets or sets the exactness delta of the Vector. def seteps (v, eps): v.epsilon = eps v = Vector (2); self.assertAlmostEqual (v.epsilon, 0, places=5) v.epsilon = 0.0000004 self.assertEqual (v.epsilon, 0.0000004) v.epsilon = 57293.2 self.assertEqual (v.epsilon, 57293.2) self.assertRaises (TypeError, seteps, v, None) self.assertRaises (TypeError, seteps, v, "Hello")
def test_pygame2_math_base_Vector_elements(self): # __doc__ (as of 2010-01-06) for pygame2.math.base.Vector.elements: # Gets or sets the elements of the Vector. # # This will only set a maximum of dimension values. def setelems (v, elems): v.elements = elems for i in range (2, 50): v = Vector (i) elems = v.elements self.assertEqual (len (elems), i) for j in range (i): self.assertEqual (elems[j], 0) v = Vector ([1,2,3,4]) self.assertEqual (len (v.elements), 4) self.assertEqual (v.elements[0], 1) self.assertEqual (v.elements[1], 2) self.assertEqual (v.elements[2], 3) self.assertEqual (v.elements[3], 4) v = Vector (10) self.assertEqual (len (v.elements), 10) v.elements = (1, 2, 3, 4) self.assertEqual (v.elements[0], 1) self.assertEqual (v.elements[1], 2) self.assertEqual (v.elements[2], 3) self.assertEqual (v.elements[3], 4) for i in range (4, 10): self.assertEqual (v.elements[i], 0) v.elements = range (50) self.assertEqual (len (v.elements), 10) for i in range (10): self.assertEqual (v.elements[i], i) self.assertRaises (TypeError, setelems, v, "Hello") self.assertRaises (TypeError, setelems, v, None)