Salome HOME
68f8477c032a37c17a406df4c34e4d9bcd1fca43
[modules/yacs.git] / src / yacsloader_swig / Test / testExecForEachGeoMesh.py
1 #!/usr/bin/env python3
2 # Copyright (C) 2006-2024  CEA, EDF
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 import tempfile
31
32 class TestExecForEachGeoMesh(unittest.TestCase):
33
34     def setUp(self):
35         SALOMERuntime.RuntimeSALOME_setRuntime(1)
36         self.l = loader.YACSLoader()
37         self.e = pilot.ExecutorSwig()
38         self.p = self.l.load("samples/geomesh0ForEach.xml")
39         pass
40         
41     @unittest.skipIf("SMESH_ROOT_DIR" not in os.environ, "requires SMESH (and GEOM)")
42     def test1_Run(self):
43         # --- start execution, run without breakpoints
44         time.sleep(1)
45         
46         print("================= Start of CONTINUE =====================")
47         self.e.setExecMode(0) # YACS::CONTINUE
48         run1 = threading.Thread(None, self.e.RunPy, "continue", (self.p,0))
49         run1.start()
50         time.sleep(0.1)
51         self.e.waitPause()
52         #self.e.displayDot(p)
53         run1.join()
54         self.assertEqual(106, self.p.getChildByName('PyScript0').getEffectiveState())
55         print("================= End of CONTINUE =======================")
56         pass
57
58     pass
59
60 if __name__ == '__main__':
61   dir_test = tempfile.mkdtemp(suffix=".yacstest")
62   file_test = os.path.join(dir_test,"UnitTestsResult")
63   with open(file_test, '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())