Salome HOME
Merge Dev_2.1.0 with PythonAPI branch
[modules/shaper.git] / src / PythonAPI / Test / TestSketcherSetLength.py
1 import unittest
2 import model
3 import math
4 import TestSketcher
5 from TestSketcher import SketcherTestCase
6
7 class SketcherSetLength(SketcherTestCase):   
8     def runTest(self):
9         # Set the constraint
10         line = self.sketch.addLine(0, 0, 0, 1)
11         self.sketch.setLength(line.result(), 25.0)
12         # Commit the transaction
13         model.do()
14         # Check the result
15         length = math.sqrt(
16             math.pow((line.endPointData().x() - line.startPointData().x()), 2) + 
17             math.pow((line.endPointData().y() - line.startPointData().y()), 2)
18             )
19         self.assertAlmostEqual(length, 25.0, delta=TestSketcher.DELTA)
20         
21 if __name__ == "__main__":
22     unittest.main()