Esempio n. 1
0
 def parsing_config(self, key):
     """
     解析config.cfg配置文件
     :param group: 传入组名
     :param key: 传入key值
     :return:
     """
     try:
         # 生成config对象
         conf = configparser.ConfigParser()
         # 获取根项目路径,导入SystemOsUtil。SystemOs
         sysos=SystemOs()
         sysOsPath=sysos.sys_path(self.configPath)
         # 用config对象读取配置文件
         conf.read(sysOsPath)
         return conf.get(self.group, key)  # type:str
     except Exception as e:
         print(e)
         # 异常后,让程序停止。暂留
         os._exit(1)
Esempio n. 2
0
    def childConfigReport(self):
        # "获取子配置文件中信息",report
        confFile = self.rootChildConfigPath()
        config1= Config("ReportFile",confFile)
        mpreport= config1.get_path_config("mpReport")
        return mpreport

    def childConfigTestFile(self):
        # "获取子配置文件中信息",testFile
        confFile = self.rootChildConfigPath()
        config1 = Config("TestFile", confFile)
        testFile = config1.get_path_config("mprTestFile")
        return testFile

if __name__ == '__main__':
    test_report = testFileReport()
    systemos = SystemOs()
    #获取项目下test目录位置
    test_dir =systemos.sys_path(test_report.childConfigTestFile())
    """
    #获取report目录,#以时间日期为目录进行整合,#创建report日期目录
    """
    report_dir = systemos.sys_path(test_report.childConfigReport())
    report_dir=systemos.sys_path(report_dir,TestDateTime().local_day())
    systemos.mkdirs_file(report_dir)
    #discover操作
    discover = unittest.defaultTestLoader.discover(test_dir,'test_*.py',None)
    filename = '测试报告'+str(TestDateTime().report_file())
    BeautifulReport(discover).report(description='测试',filename=filename,report_dir=report_dir)