shithub: aubio

ref: 779966bd7d91e0ff09e26d8d2f8524791e72e5b4
dir: /interfaces/python/run_all_tests/

View raw version
#! /usr/bin/python

if __name__ == '__main__':
  import os, sys, unittest
  def load_test():
    # get relevant files
    curdir = os.path.dirname(sys.argv[0])
    if curdir == '': curdir = '.'
    files = os.listdir(curdir)
    modfiles = filter (lambda y: y.endswith('.py'), files) 
    modfiles = filter (lambda f: f.startswith('test_'), modfiles)
    # get module names
    modnames = map (lambda x: os.path.splitext(x)[0], modfiles)
    # import them
    modules = map (__import__, modnames)
    # create a test suites from the imported module
    load_from_module = unittest.defaultTestLoader.loadTestsFromModule
    tests = map(load_from_module, modules)
    return unittest.TestSuite(tests)
  unittest.main(defaultTest = 'load_test')