Beispiel #1
0
    def load_tests(self):
        """
        Iterate through the plugoos inside the folder specified by the
        config file and instantiate them.
        """
        pluginfiles = [fname[:-3] for fname in os.listdir(self.config.main.testdir)\
                         if fname.endswith(".py")]
        for fname in pluginfiles:
            test = Storage()
            test_name = fname
            if not self.config.main.testdir in sys.path:
                sys.path.insert(0, self.config.main.testdir)
            #print "Fname: %s\n__import__(%s)" % (fname, fname)
            #print sys.path
            module = __import__(fname)
            try:
                test.name = module.__plugoo__
                test.desc = module.__desc__
                test.module = module
            except Exception, e:
                self.logger.warning("Soft fail %s", e)
                test.name = test_name
                test.desc = ""
                test.module = module

            try:
                self.tests[test_name] = test
            except Exception, e:
                print "Failed to load the test %s %s" % (name, e)