From: Serge Rehbinder Date: Wed, 3 Feb 2016 14:36:43 +0000 (+0100) Subject: fix test scripts X-Git-Tag: sprint-02~16 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=f1223c4008ba0007e1fb6a45e1bd99ee02f1da41;p=tools%2Fsat.git fix test scripts --- diff --git a/test/config/create_user_pyconf.py b/test/config/create_user_pyconf.py index 4b5a256..bf43f67 100644 --- a/test/config/create_user_pyconf.py +++ b/test/config/create_user_pyconf.py @@ -34,7 +34,7 @@ class TestConfig(unittest.TestCase): ''' def test_option_value(self): - '''Test the display of the right value of "sat config -v VARS.hostname" + '''Creation of ~/.salomeTools/salomeTools.pyconf ''' res = "KO" user_dir = os.path.expanduser(os.path.join('~','.salomeTools')) @@ -46,7 +46,7 @@ class TestConfig(unittest.TestCase): sat = salomeTools('') sat.config('-v .') - expected_file = os.path.expanduser(os.path.join('~','.salomeTools', 'salomeTools-' + sat.cfg.INTERNAL.sat_version + ".pyconf")) + expected_file = os.path.expanduser(os.path.join('~','.salomeTools', 'salomeTools.pyconf')) if os.path.exists(expected_file): res = "OK" diff --git a/test/config/option_copy.py b/test/config/option_copy.py index cd80b87..4e20f3a 100644 --- a/test/config/option_copy.py +++ b/test/config/option_copy.py @@ -30,20 +30,23 @@ from salomeTools import salomeTools import HTMLTestRunner class TestConfig(unittest.TestCase): - '''pyunit class : each method execute one test. + '''sat config -c ''' def test_option_copy(self): - '''Test the copy of a pyconf" + '''Test the copy of a pyconf ''' res = "KO" appli_to_copy = "appli-test" + + expected_file = os.path.expanduser(os.path.join('~','.salomeTools', 'Applications', 'LOCAL_' + appli_to_copy + '.pyconf')) + if os.path.exists(expected_file): + os.remove(expected_file) # The command to test sat = salomeTools('') sat.config('appli-test -c') - expected_file = os.path.expanduser(os.path.join('~','.salomeTools', 'Application', 'LOCAL_' + appli_to_copy + '.pyconf')) if os.path.exists(expected_file): res = "OK" diff --git a/test/config/option_value.py b/test/config/option_value.py index 2b1d903..f54c0dd 100644 --- a/test/config/option_value.py +++ b/test/config/option_value.py @@ -19,6 +19,7 @@ import unittest import os import sys +import platform # get execution path testdir = os.path.dirname(os.path.realpath(__file__)) @@ -30,14 +31,14 @@ from tools import outRedirection import HTMLTestRunner class TestConfig(unittest.TestCase): - '''pyunit class : each method execute one test. + '''OPTION VALUE. ''' def test_option_value(self): '''Test the display of the right value of "sat config -v VARS.hostname" ''' - # expected value - expected = '\x1b[36mhostname\x1b[0m: is221560\n' + + OK = "KO" # output redirection my_out = outRedirection() @@ -52,14 +53,17 @@ class TestConfig(unittest.TestCase): # get results res = my_out.read_results() + if platform.node() in res: + OK = "OK" + # pyunit method to compare 2 str - self.assertEqual(res, expected) + self.assertEqual(OK, "OK") def test_option_list(self): '''Test the display of the right value of "sat config -l" ''' - # expected value - expected = '------ \x1b[34m/home/salome/SPN_PRIVATE/sat5dev_Applications\x1b[0m\nappli-test\n\n------ \x1b[34m/export/home/serioja/.salomeTools/Applications\x1b[0m\n\n' + + OK = "KO" # output redirection my_out = outRedirection() @@ -74,8 +78,12 @@ class TestConfig(unittest.TestCase): # get results res = my_out.read_results() + # get results + if "ERROR" not in res: + OK = "OK" + # pyunit method to compare 2 str - self.assertEqual(res, expected) + self.assertEqual(OK, "OK") # test launch if __name__ == '__main__': diff --git a/test/config/option_value_2.py b/test/config/option_value_2.py index ddf0528..e123f2d 100644 --- a/test/config/option_value_2.py +++ b/test/config/option_value_2.py @@ -19,6 +19,7 @@ import unittest import os import sys +import platform # get execution path testdir = os.path.dirname(os.path.realpath(__file__)) @@ -30,14 +31,14 @@ from tools import outRedirection import HTMLTestRunner class TestConfig(unittest.TestCase): - '''pyunit class : each method execute one test. + '''test of sat config -v VARS.python ''' def test_option_value(self): - '''Test the display of the right value of "sat config -v VARS.hostname" + '''Test the display of the right value of "sat config -v VARS.python" ''' - # expected value - expected = '\x1b[36mhostname\x1b[0m: is221560\n' + + OK = 'KO' # output redirection my_out = outRedirection() @@ -51,31 +52,14 @@ class TestConfig(unittest.TestCase): # get results res = my_out.read_results() + + + if platform.python_version() in res: + OK = 'OK' # pyunit method to compare 2 str - self.assertEqual(res, expected) + self.assertEqual(OK, 'OK') - def test_option_list(self): - '''Test the display of the right value of "sat config -l" - ''' - # expected value - expected = '------ \x1b[34m/home/salome/SPN_PRIVATE/sat5dev_Applications\x1b[0m\nappli-test\n\n------ \x1b[34m/export/home/serioja/.salomeTools/Applications\x1b[0m\n\n' - - # output redirection - my_out = outRedirection() - - # The command to test - sat = salomeTools('') - sat.config('-l') - - # stop output redirection - my_out.end_redirection() - - # get results - res = my_out.read_results() - - # pyunit method to compare 2 str - self.assertEqual(res, expected) # test launch if __name__ == '__main__':