1#!/usr/bin/python
2
3import unittest
4
5from os.path import dirname, basename, isfile
6import glob
7
8# Find all unittest type in this directory and run it.
9
10class RegressTest(unittest.TestCase):
11    pass
12
13def main():
14    unittest.main()
15
16if __name__ == '__main__':
17    directory = dirname(__file__)
18    if directory == '':
19        directory = '.'
20    modules = glob.glob(directory+"/*.py")
21    __all__ = [ basename(f)[:-3] for f in modules if isfile(f)]
22    suite = unittest.TestSuite()
23
24    for module in __all__:
25        m = __import__(module)
26        for cl in dir(m):
27            try:
28                realcl = getattr(m,cl)
29                if issubclass(realcl, unittest.TestCase):
30                    suite.addTest(realcl())
31            except Exception as e:
32                pass
33
34    unittest.TextTestRunner().run(suite)
35