Salome HOME
Run all SMESH tests at once: all tests pass in 2min instead of 1h20min
[modules/smesh.git] / doc / salome / examples / tests.py.in
1 DIR='@CMAKE_CURRENT_SOURCE_DIR@'
2 TESTS='@GOOD_TESTS@'
3 REINIT_SALOME=@TEST_REINIT_SALOME@
4
5 import os
6 import unittest
7 import salome
8
9 class MyTest(unittest.TestCase):
10     def setUp(self):
11         if REINIT_SALOME:
12             salome.salome_init()
13     def tearDown(self):
14         if REINIT_SALOME:
15             salome.salome_close()
16     pass
17
18 if __name__ == "__main__":
19     tests = TESTS.split(';')
20     for test in tests:
21         file_name = os.path.basename(test)
22         if os.path.isabs(test):
23             file_path = file_name
24         else:
25             file_path = os.path.join(DIR, file_name)
26         case_name = 'test_' + file_name[:-3]
27         code = """
28 def func(self):
29   with open('{}') as f:
30     exec(f.read())
31 """
32         exec(code.format(file_path))
33         setattr(MyTest, case_name, func)
34
35     unittest.main()