Salome HOME
1c447d64851dda2d9d0a43ab9dcae5bcbc7c512e
[modules/yacs.git] / src / yacsloader_swig / Test / testExecForEachGeoMesh.py
1 #!/usr/bin/env python3
2 # Copyright (C) 2006-2020  CEA/DEN, EDF R&D
3 #
4 # This library is free software; you can redistribute it and/or
5 # modify it under the terms of the GNU Lesser General Public
6 # License as published by the Free Software Foundation; either
7 # version 2.1 of the License, or (at your option) any later version.
8 #
9 # This library is distributed in the hope that it will be useful,
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
12 # Lesser General Public License for more details.
13 #
14 # You should have received a copy of the GNU Lesser General Public
15 # License along with this library; if not, write to the Free Software
16 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
17 #
18 # See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
19 #
20
21 import time
22 import unittest
23 import threading
24
25 import SALOMERuntime
26 import loader
27 import pilot
28
29 import os
30
31 class TestExecForEachGeoMesh(unittest.TestCase):
32
33     def setUp(self):
34         SALOMERuntime.RuntimeSALOME_setRuntime(1)
35         self.l = loader.YACSLoader()
36         self.e = pilot.ExecutorSwig()
37         self.p = self.l.load("samples/geomesh0ForEach.xml")
38         pass
39         
40     @unittest.skipIf("SMESH_ROOT_DIR" not in os.environ, "requires SMESH (and GEOM)")
41     def test1_Run(self):
42         # --- start execution, run without breakpoints
43         time.sleep(1)
44         
45         print("================= Start of CONTINUE =====================")
46         self.e.setExecMode(0) # YACS::CONTINUE
47         run1 = threading.Thread(None, self.e.RunPy, "continue", (self.p,0))
48         run1.start()
49         time.sleep(0.1)
50         self.e.waitPause()
51         #self.e.displayDot(p)
52         run1.join()
53         self.assertEqual(106, self.p.getChildByName('PyScript0').getEffectiveState())
54         print("================= End of CONTINUE =======================")
55         pass
56
57     pass
58
59 if __name__ == '__main__':
60     import os
61     import sys
62     U = os.getenv('USER')
63     with open(os.path.join("/tmp", U, "UnitTestsResult"), 'a') as f:
64         f.write("  --- TEST src/yacsloader: testExec.py\n")
65         suite = unittest.makeSuite(TestExecForEachGeoMesh)
66         result = unittest.TextTestRunner(f, descriptions=1, verbosity=1).run(suite)
67
68     sys.exit(not result.wasSuccessful())