def __init__(self): JSONFILE = "config.json" YAMLFILE = "config.yaml" if os.path.exists(JSONFILE): f = open(JSONFILE, 'r', encoding="utf-8") self.argstr = json.load(f) if self.warning_message(self.argstr): raise ArgmentError(Exception, "使用老json格式,需要换成新的配置文件!{0}".format(MESSAGE)) logger.info("获取运行参数 {0}".format(self.argstr)) elif os.path.exists(YAMLFILE): file = open(YAMLFILE, 'r', encoding="utf-8") file_data = file.read() file.close() self.argstr = yaml.load(file_data, Loader=yaml.FullLoader) logger.info("获取运行参数 {0}".format(self.argstr))
def testsuit_runner(self): try: return self.argstr['runner']['name'] except Exception as e: raise ArgmentError(e, "参数配置错误")
def jsonfile_path(self): try: return self.argstr['ski_filepath'] except Exception as e: raise ArgmentError(e, "参数配置错误")
def case_path(self): try: return self.argstr['case']['path'] except Exception as e: raise ArgmentError(e, "参数配置错误")
def report_path(self): try: return self.argstr['report']['path'] except Exception as e: raise ArgmentError(e, "参数配置错误")
def mode(self): try: return self.argstr['unittestcase']['mode'] except Exception as e: raise ArgmentError(e, "mode 参数配置错误")
def log_level(self): try: return self.argstr['log']['level'] except Exception as e: raise ArgmentError(e, "参数配置错误")
def log_filepath(self): try: return self.argstr['log']['file_path'] except Exception as e: raise ArgmentError(e, "参数配置错误")
def pytest_commands(self): try: return self.argstr['runner']['commands'] except Exception as e: raise ArgmentError(e, "参数配置错误")
def auto_model_path(self): try: return self.argstr['auto']['model_path'] except Exception as e: raise ArgmentError(e, "参数配置错误")
def report_add_time(self): try: return self.argstr['report']['addtime.now'] except Exception as e: raise ArgmentError(e, "参数配置错误")