def _add_with_prereq(self, entry, _auto=False): if self._debug < 3: for prereq in entry.inst.OPTIONS.prerequisites: impl = prereq.implementation # If only a class name is given, assume it refers to a class # in the same module as the defining test, and convert to full # path using that module. if "." not in impl: impl = sys.modules[ entry.inst.__class__.__module__].__name__ + "." + impl prereq.implementation = impl pretestclass = module.get_object(impl) pretestclass.set_test_options() preentry = TestEntry( pretestclass(self.config, self.environment, self.UI), prereq.args, prereq.kwargs, True) presig, argsig = preentry.signature if presig not in self._multitestset: self._add_with_prereq(preentry, True) testcaseid = entry.signature if not _auto: self._tests.append(entry) elif testcaseid not in self._testset: self._tests.append(entry) self._testset.add(testcaseid)
def get_server(config): username = config.get("USERNAME") if username and os.getuid() == 0: pwent = passwd.getpwnam(username) else: pwent = None pm = ProcessManager(pwent) app = framework.FrameworkAdapter(config) if "MIDDLEWARE" in config: for mwtuple in config["MIDDLEWARE"]: mwobj = module.get_object(mwtuple[0]) args = mwtuple[1:] app = mwobj(app, *args) if config.DEBUG: logging.loglevel_debug() return FCGIServer(app, procmanager=pm, bindAddress=config.SOCKETPATH, errorhandler=None, umask=config.get("SOCKET_UMASK", 0), debug=config.DEBUG)
def get_server(config): username = config.get("USERNAME") middleware = config.get("MIDDLEWARE", []) if username and os.getuid() == 0: pwent = passwd.getpwnam(username) else: pwent = None app = module.get_object(config.APP_LOCATION) if config.DEBUG: logging.loglevel_debug() for mwtuple in middleware: mwobj = module.get_object(mwtuple[0]) args = mwtuple[1:] app = mwobj(app *args) return SCGIServer(app, config.SOCKETPATH, umask=config.get("SOCKET_UMASK", 0), pwent=pwent, debug=config.DEBUG)
def get_report(config): from . import default rname = config.get("reportname", "default") if rname.startswith("default"): if locale.getpreferredencoding() == 'UTF-8': return default.DefaultReportUnicode() else: return default.DefaultReport() elif "." in rname: robj = module.get_object(rname) return robj() else: raise ReportFindError("No report {} defined.".format(rname))
def get_server(config): username = config.get("USERNAME") middleware = config.get("MIDDLEWARE", []) if username and os.getuid() == 0: pwent = passwd.getpwnam(username) else: pwent = None app = module.get_object(config.APP_LOCATION) if config.DEBUG: logging.loglevel_debug() for mwtuple in middleware: mwobj = module.get_object(mwtuple[0]) args = mwtuple[1:] app = mwobj(app * args) return SCGIServer(app, config.SOCKETPATH, umask=config.get("SOCKET_UMASK", 0), pwent=pwent, debug=config.DEBUG)
def get_test_class(dbcase): """Return the implementation class of a TestCase, or None if not found. """ if dbcase.automated and dbcase.valid: impl = dbcase.testimplementation if impl: obj = module.get_object(impl) if type(obj) is type and issubclass(obj, core.Test): return obj else: raise InvalidTestError("%r is not a Test class object." % (obj,)) else: return None else: return None
def get_test_class(dbcase): """Return the implementation class of a TestCase, or None if not found. """ if dbcase.automated and dbcase.valid: impl = dbcase.testimplementation if impl: obj = module.get_object(impl) if type(obj) is type and issubclass(obj, core.TestCase): return obj else: raise InvalidTestError( "{!r} is not a Test class object.".format(obj)) else: return None else: return None
def get_TestEntry_instance(string, config): """Return a TestEntry instance from a string representing a test class plus arguments. """ paren_i = string.find("(") if paren_i > 0: args = string[paren_i+1:-1] string = string[:paren_i] args, kwargs = core.parse_args(args) else: args = () kwargs = {} try: cls = module.get_object(string) except (module.ModuleImportError, module.ObjectImportError), err: logging.warn(err) return None
def get_suite(dbsuite, config): """Get a Suite object. Return the implementation class of a TestSuite, or a generic Suite instance if not defined. """ name = dbsuite.name if " " in name: name = identifier(name) impl = dbsuite.suiteimplementation if impl: try: obj = module.get_object(impl) except module.ObjectImportError: logging.warning("Did not find suite implementation %r." % (impl,)) else: if type(obj) is type and issubclass(obj, core.TestSuite): return obj(config, name=name) else: raise InvalidObjectError("%r is not a TestSuite class object." % (obj,)) return core.TestSuite(config, name=name)
def get_suite(dbsuite, config): """Get a Suite object. Return the implementation class of a TestSuite, or a generic Suite instance if not defined. """ name = dbsuite.name if " " in name: name = identifier(name) impl = dbsuite.suiteimplementation if impl: try: obj = module.get_object(impl) except module.ObjectImportError: logging.warning("Did not find suite implementation %r." % (impl, )) else: if type(obj) is type and issubclass(obj, core.TestSuite): return obj(config, name=name) else: raise InvalidObjectError( "%r is not a TestSuite class object." % (obj, )) return core.TestSuite(config, name=name)
def get_controller(equipment, accessmethod, logfile=None): """Return controller instance that is based on the equipment role.""" path = _CONTROLLERMAP[accessmethod] constructor = module.get_object(path) return constructor(equipment, logfile)