equal
deleted
inserted
replaced
12 # Contributors: |
12 # Contributors: |
13 # |
13 # |
14 # Description: |
14 # Description: |
15 # |
15 # |
16 |
16 |
17 import unittest, os, sys |
|
18 |
17 |
19 ROOT_PATH = os.path.dirname(os.path.abspath(__file__)) |
|
20 SOURCE_ROOT = os.path.normpath(os.path.join(ROOT_PATH, '../../..')) |
|
21 TESTAUTO_ROOT = os.path.normpath(os.path.join(ROOT_PATH, '../../../testautomation')) |
|
22 if SOURCE_ROOT not in sys.path: |
|
23 sys.path.append(SOURCE_ROOT) |
|
24 if TESTAUTO_ROOT not in sys.path: |
|
25 sys.path.insert(0,TESTAUTO_ROOT) |
|
26 |
|
27 # Find all unittest_*.py files in this folder |
|
28 import re |
|
29 __all__ = filter(lambda name: re.match(r'^unittest_.*\.py$', name) != None, os.listdir(ROOT_PATH)) |
|
30 # Strip .py endings |
|
31 __all__ = map(lambda name: name[:-3], __all__) |
|
32 |
|
33 def collect_suite(): |
|
34 sys.path.insert(0, ROOT_PATH) |
|
35 try: |
|
36 suite = unittest.TestSuite() |
|
37 for test_module in __all__: |
|
38 # Load the test module dynamically and add it to the test suite |
|
39 module = __import__(test_module) |
|
40 suite.addTests(unittest.TestLoader().loadTestsFromModule(module)) |
|
41 return suite |
|
42 finally: |
|
43 del sys.path[0] |
|
44 |
|
45 def runtests(): |
|
46 unittest.TextTestRunner(verbosity=2).run(collect_suite()) |
|
47 |
|
48 if __name__ == '__main__': |
|
49 runtests() |
|