diff options
-rwxr-xr-x | systest | 16 |
1 files changed, 15 insertions, 1 deletions
@@ -1,7 +1,9 @@ #!/usr/bin/python import cliapp +import imp import logging +import os import re import subprocess import unittest @@ -19,7 +21,10 @@ class SystemTest(cliapp.Application): def process_args(self, args): loader = unittest.defaultTestLoader loader.suiteClass = self.create_suite - suite = loader.loadTestsFromNames(args) + suite = unittest.TestSuite() + for filename in args: + module = self.load_module(filename) + suite.addTest(loader.loadTestsFromModule(module)) unittest.TextTestRunner().run(suite) def create_suite(self, tests): @@ -28,6 +33,15 @@ class SystemTest(cliapp.Application): suite = unittest.TestSuite(tests) return suite + def load_module(self, filename): + for t in imp.get_suffixes(): + suffix, mode, kind = t + if filename.endswith(suffix): + module_name = os.path.basename(filename[:-len(suffix)]) + with open(filename, mode) as f: + return imp.load_module(module_name, f, filename, t) + raise Exception("Unknown module: %s" % filename) + if __name__ == '__main__': SystemTest().run() |