def run(): if os.path.exists('report/'): shutil.rmtree(path='report/') logger.add(file_path['log'], enqueue=True, encoding='utf-8') logger.info(""" _ _ _ _____ _ __ _ _ __ (_) / \ _ _| |_ __|_ _|__ ___| |_ / _` | '_ \| | / _ \| | | | __/ _ \| |/ _ \/ __| __| | (_| | |_) | |/ ___ \ |_| | || (_) | | __/\__ \ |_ \__,_| .__/|_/_/ \_\__,_|\__\___/|_|\___||___/\__| |_| Starting ... ... ... """) pytest.main( args=['test/test_api.py', f'--alluredir={file_path["report"]}/data']) # 自动以服务形式打开报告 # os.system(f'allure serve {report}/data') # 本地生成报告 os.system( f'allure generate {file_path["report"]}/data -o {file_path["report"]}/html --clean' ) logger.success('报告已生成') # 发送邮件带附件报告 EmailServe.send_email(email, file_path['report']) # 删除本地附件 os.remove(email['enclosures'])
def run(cls): if os.path.exists('../report'): shutil.rmtree(path='../report') logger.add(logfile, enqueue=True, encoding='utf-8') logger.info('开始测试...') pytest.main(args=[f'--alluredir={report}/data']) os.system(f'allure generate {report}/data -o {report}/html --clean') logger.success('报告已生成')
def run(): if os.path.exists('report/'): shutil.rmtree(path='report/') logger.add(logfile, enqueue=True, encoding='utf-8') logger.info('开始测试...') pytest.main(args=['test/test_api.py', f'--alluredir={report}/data']) # 自动以服务形式打开报告 # os.system(f'allure serve {report}/data') # 本地生成报告 os.system(f'allure generate {report}/data -o {report}/html --clean') logger.success('报告已生成')
def __init__(self, host: str, port: int = 22, username: str = "root", password: str = None, private_key_file: str = None, privat_passowrd: str = None): # 进行SSH连接 self.trans = paramiko.Transport((host, port)) self.host = host if password is None: self.trans.connect(username=username, pkey=paramiko.RSAKey.from_private_key_file(private_key_file, privat_passowrd)) else: self.trans.connect(username=username, password=password) # 将sshclient的对象的transport指定为以上的trans self.ssh = paramiko.SSHClient() logger.success("SSH客户端创建成功.") self.ssh._transport = self.trans # 创建SFTP客户端 self.ftp_client = paramiko.SFTPClient.from_transport(self.trans) logger.success("SFTP客户端创建成功.")
def run(): if os.path.exists('report/'): shutil.rmtree(path='report/') logger.add(logfile, enqueue=True, encoding='utf-8') logger.info(""" _ _ _ _____ _ __ _ _ __ (_) / \ _ _| |_ __|_ _|__ ___| |_ / _` | '_ \| | / _ \| | | | __/ _ \| |/ _ \/ __| __| | (_| | |_) | |/ ___ \ |_| | || (_) | | __/\__ \ |_ \__,_| .__/|_/_/ \_\__,_|\__\___/|_|\___||___/\__| |_| Starting ... ... ... """) pytest.main(args=['test/test_api.py', f'--alluredir={report}/data']) # 自动以服务形式打开报告 # os.system(f'allure serve {report}/data') # 本地生成报告 os.system(f'allure generate {report}/data -o {report}/html --clean') logger.success('报告已生成')
def run(): if os.path.exists('report/'): shutil.rmtree(path='report/') logger.add(logfile, enqueue=True, encoding='utf-8') logger.info(""" _ _ _ _____ _ __ _ _ __ (_) / \\ _ _| |_ __|_ _|__ ___| |_ / _` | '_ \\| | / _ \\| | | | __/ _ \\| |/ _ \\/ __| __| | (_| | |_) | |/ ___ \\ |_| | || (_) | | __/\\__ \\ |_ \\__,_| .__/|_/_/ \\_\\__,_|\\__\\___/|_|\\___||___/\\__| |_| Starting ... ... ... """) pytest.main(args=['test/test_api.py', f'--alluredir={report}/data']) # 生成本地生成报告 os.system(f'allure generate {report}/data -o {report}/html --clean') logger.success('报告已生成,请查收') # 启动allure服务 os.system(f'allure serve {report}/data' ) # 该方法会生成一个http服务 挂载报告文件 阻塞线程 (如果需要压缩报告,请注释)
def del_report(): """删除本地附件""" os.remove(s_email['enclosures']) logger.success('附件删除完成')