Salome HOME
fe005dae9ef36b13b6e164a57a302061f4371958
[modules/shaper.git] / src / PythonAPI / Test / TestSketcherSetLength.py
1 import unittest
2 from salome.shaper 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, 25.0)
12         # Commit the transaction
13         model.do()
14         # Check the result
15         length = math.sqrt(
16             math.pow((line.endPoint().x() - line.startPoint().x()), 2) + 
17             math.pow((line.endPoint().y() - line.startPoint().y()), 2)
18             )
19         self.assertAlmostEqual(length, 25.0, delta=TestSketcher.DELTA)
20
21 if __name__ == "__main__":
22     unittest.main()