Salome HOME
Add tests for connection with SHAPERSTUDY
[modules/smesh.git] / doc / salome / examples / testme.py
1 #!/usr/bin/env python3
2 # Copyright (C) 2007-2019  CEA/DEN, EDF R&D, OPEN CASCADE
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
22 import unittest, sys, os
23
24 class SalomeSession(object):
25     def __init__(self, script):
26         import runSalome
27         run_script = "runSalome.py"
28         if sys.platform == 'win32':
29             module_dir = os.getenv("KERNEL_ROOT_DIR")
30             if module_dir: run_script = os.path.join(module_dir, "bin", "salome", run_script)
31             pass
32         sys.argv  = [run_script]
33         sys.argv += ["--terminal"]
34         sys.argv += ["--modules=GEOM,SHAPER,SHAPERSTUDY,SMESH"]
35         sys.argv += ["%s" % script]
36         if sys.platform == 'win32':
37             main_module_path = sys.modules['__main__'].__file__
38             sys.modules['__main__'].__file__ = ''
39         clt, d = runSalome.main()
40         if sys.platform == 'win32':
41             sys.modules['__main__'].__file__ = main_module_path
42         return
43
44     def __del__(self):
45         port = os.getenv('NSPORT')
46         import killSalomeWithPort
47         killSalomeWithPort.killMyPort(port)
48         return
49     pass
50
51 class MyTest(unittest.TestCase):
52     def testFunction(self):
53         SalomeSession(sys.argv[1])
54     pass
55
56 unittest.main(argv=sys.argv[:1])