Salome HOME
set VARS.user to Unknown is USER var not set (no more exception), extend printings...
[tools/sat.git] / test / test_sat5_0 / config / test_option_edit.py
1 #!/usr/bin/env python
2 #-*- coding:utf-8 -*-
3
4 #  Copyright (C) 2010-2018  CEA/DEN
5 #
6 #  This library is free software; you can redistribute it and/or
7 #  modify it under the terms of the GNU Lesser General Public
8 #  License as published by the Free Software Foundation; either
9 #  version 2.1 of the License.
10 #
11 #  This library is distributed in the hope that it will be useful,
12 #  but WITHOUT ANY WARRANTY; without even the implied warranty of
13 #  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14 #  Lesser General Public License for more details.
15 #
16 #  You should have received a copy of the GNU Lesser General Public
17 #  License along with this library; if not, write to the Free Software
18 #  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
19
20 import os
21 import sys
22 import threading
23 import time
24 import unittest
25
26 from src.salomeTools import Sat
27 from unittestpy.tools import check_proc_existence_and_kill_multi
28
29 sleep_time = 2
30
31 class TestCase(unittest.TestCase):
32     """sat config --edit"""
33     
34     def test_010(self):
35         # Test the launch of the editor when invoking the config -e
36         OK = "KO"
37
38         sat = Sat("-oUSER.editor='cooledit'")
39         sat.config()
40         cmd_config = threading.Thread(target=sat.config, args=('-e',))
41         cmd_config.start()
42
43         time.sleep(sleep_time)
44
45         editor = sat.cfg.USER.editor
46         pid = check_proc_existence_and_kill_multi(editor + ".*" + "salomeTools\.pyconf", 10)
47
48         if pid:
49             OK = "OK"
50         self.assertEqual(OK, "OK")
51
52     def test_020(self):
53         # Test the launch of the editor when invoking the config -e appli-test
54         OK = "KO"
55
56         sat = Sat("-oUSER.editor='cooledit'")
57         sat.config()
58         cmd_config = threading.Thread(target=sat.config, args=('appli-test -e',))
59         cmd_config.start()
60
61         time.sleep(sleep_time)
62
63         editor = sat.cfg.USER.editor
64         pid = check_proc_existence_and_kill_multi(editor + ".*" + "appli-test\.pyconf", 10)
65
66         if pid:
67             OK = "OK"
68         self.assertEqual(OK, "OK")
69  
70 # test launch
71 if __name__ == '__main__':
72     unittest.main()
73     pass