def prepare(self): os.chdir(fwork.NSUI_PATH) report_dir = os.path.join(fwork.REPORT_DIR, self.config.options.run_id) nsui_log_dir = os.path.join(report_dir, "log") self.config.report_dir = report_dir self.config.nsui_log_dir = nsui_log_dir if not os.path.isdir(report_dir): os.makedirs(report_dir) if not os.path.isdir(nsui_log_dir): os.makedirs(nsui_log_dir) self.config.build_dir = self.config.options.build_dir builds = self.config.options.build_num if not self.config.options.no_install: if builds == "NOT_SET": raise Exception("No Build number provided") else: builds = [s.strip() for s in builds.split(":")] self.config.base_build = builds[0] if len(builds) > 1: self.config.target_build = builds[1] else: import platform if platform.system() == "Windows": NSObj = NSClient() NSObj.enableNSClientFromSysTray() else: pass self.build_dir = self.config.options.build_dir self.reporter = TabDelimitedReporter(self.config)
class TestRunner: def __init__(self, config): self.config = config def add_test(self, test): for m in test.__class__.__dict__.keys(): if m.startswith("test"): method_tuple = (test, m) self.__test_queue.append( method_tuple ) def prepare(self): os.chdir(fwork.NSUI_PATH) report_dir = os.path.join(fwork.REPORT_DIR, self.config.options.run_id) nsui_log_dir = os.path.join(report_dir, "log") self.config.report_dir = report_dir self.config.nsui_log_dir = nsui_log_dir if not os.path.isdir(report_dir): os.makedirs(report_dir) if not os.path.isdir(nsui_log_dir): os.makedirs(nsui_log_dir) self.config.build_dir = self.config.options.build_dir builds = self.config.options.build_num if not self.config.options.no_install: if builds == "NOT_SET": raise Exception("No Build number provided") else: builds = [s.strip() for s in builds.split(":")] self.config.base_build = builds[0] if len(builds) > 1: self.config.target_build = builds[1] else: import platform if platform.system() == "Windows": NSObj = NSClient() NSObj.enableNSClientFromSysTray() else: pass self.build_dir = self.config.options.build_dir self.reporter = TabDelimitedReporter(self.config) def setUp(self): if self.config.options.no_install: pass # Calls install module to install ns client def run(self): test_suites = self.config.options.test_suite if test_suites == "ALL": test_suites = [ts_type for ts_type in self.config.modes.TestSuites.__dict__.keys() if not ts_type.startswith("__")] else: test_suites = [test_suites] app_types = self.config.options.app_type.upper() if app_types == "ALL": app_types = ["WEB", "NATIVE"] else: app_types = [app_types] test_scripts = [] for test_suite in test_suites: test_scripts_ds = getattr(self.config.modes.TestSuites, test_suite) if type(test_scripts_ds) is types.DictType: for app_type in app_types: test_scripts.extend(test_scripts_ds[app_type]) else: test_scripts.extend(test_scripts_ds) if not self.config.options.no_install: test_scripts.insert(0, "ClientInstallTest") test_scripts.append("ClientUninstallTest") for test_script in test_scripts: Test = None results = None print test_script try: exec ("from nsClientAuto.tests.%s import %s as Test" % (test_script, test_script)) except Exception, e: import traceback self.reporter.warn("Error in importing test: %s \n %s" % (str(e), traceback.format_exc()) ) else: test = Test(self.config) try: test.setUp() except Exception, e: self.reporter.warn("Setup Error") else: