| 4 | | |
| 5 | | import sys |
| 6 | | import glob |
| 7 | | import imp |
| 8 | | import unittest |
| 9 | | from os.path import abspath, dirname, basename, join as joinpath |
| 10 | | |
| 11 | | _mydir = abspath(joinpath(dirname(__file__))) |
| 12 | | |
| 13 | | # Make sure that imapclient is imported from the right place |
| 14 | | _import_dir = abspath(joinpath(_mydir, '..', '..')) |
| 15 | | sys.path.insert(0, _import_dir) |
| 16 | | |
| 17 | | def load_suite(): |
| 18 | | full_suite = unittest.TestSuite() |
| 19 | | for modpath in glob.glob(joinpath(_mydir, 'test_*.py')): |
| 20 | | module_name = basename(modpath).split('.', 1)[0] |
| 21 | | module = imp.load_source(module_name, modpath) |
| 22 | | suite = unittest.defaultTestLoader.loadTestsFromModule(module) |
| 23 | | full_suite.addTest(suite) |
| 24 | | return full_suite |
| 25 | | |
| 26 | | def run_suite(): |
| 27 | | suite = load_suite() |
| 28 | | runner = unittest.TextTestRunner(verbosity=1) |
| 29 | | runner.run(suite) |
| 30 | | |
| 31 | | |