当前位置: 首页 > news >正文

我是做化工回收的做哪个网站比较好做推广最好的网站是哪个?

我是做化工回收的做哪个网站比较好,做推广最好的网站是哪个?,行业网站开发费用,建设网站论坛都需要哪些工具实现思路 使用excel管理用例用例信息#xff0c;requests模块发送http请求#xff0c;实现了记录日志#xff0c;邮件发送测试报告的功能 目录结构如下#xff1a; 下面直接上代码#xff1a; 统筹脚本 # -*- coding:utf-8 -*-import osfrom interface import Interfa…实现思路 使用excel管理用例用例信息requests模块发送http请求实现了记录日志邮件发送测试报告的功能 目录结构如下 下面直接上代码 统筹脚本 # -*- coding:utf-8 -*-import osfrom interface import Interfacefrom testcase_get import Get_testcasefrom result_save import Save_test_resultfrom result_send import Send_reportfrom config.config import Configfrom logging_save import loggerif __name__ __main__:cur_path os.path.split(os.path.realpath(__file__))[0]  # 获取当前文件绝对路径case_path os.path.join(cur_path, test_case, 20170602.xls)test_case Get_testcase(case_path).readExcel()  # 获取用例if not isinstance(test_case, list):  # 判断用例是否获取成功logger.info(Test_case get failed... \n Done!)else:logger.info(获取用例成功)# 调用接口test_result Interface().interfaceTest(test_case)# 获取执行结果用于发邮件count_success test_result[3]count_failure test_result[4]failed_case_detail test_result[5]# 保存测试结果Save_test_result().save_result(case_path, test_result[0], test_result[1], test_result[2])logger.info(保存测试结果成功)# 获取邮件配置信息mail_config Config(os.path.join(cur_path, config, mail.conf)).get_mail_config()logger.info(获取邮箱配置成功)login_user mail_config[0]login_pwd mail_config[1]from_addr mail_config[2]to_addrs mail_config[3]smtp_server mail_config[4]mail_send Send_report(count_success, count_failure, failed_case_detail)# 获取最新测试报告last_report mail_send.newest_report()logger.info(邮件发送结果)mail_send.send_result(login_user, login_pwd,from_addr, to_addrs,smtp_server,last_report)logger.info(DONE!) 请求封装 # coding:utf-8import jsonimport requestsfrom logging_save import loggerfrom result_check import Result_checkfrom url_transform import urltransformclass Interface:def __init__(self, ):passdef interfaceTest(self, case_list):接口调用主函数# 用于存结果res_flags []# 用于存请求报文request_urls []# 用于存返回报文responses []# 用户存失败的用例failed_case []# 统计成功失败的用例数count_success 0count_failure 0for case in case_list:try:# 模块product case[0]# 用例idcase_id case[1]# 用例标题interface_name case[2].strip(\n)# 用例描述case_detail case[3]# 请求方式method case[4]# 请求urlurl case[5]# 入参param case[6]# 预期结果res_check case[7]except Exception as e:return 测试用例格式不正确%s % e# 定义消息头信息headers {content-type: application/json,User-Agent: Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:22.0) Gecko/20100101 Firefox/22.0}# 对url进行封装new_url urltransform().urltransform(url, method, param)if method.upper() GET:results requests.get(new_url).textlogger.info(u正在调用接口: %s % interface_name)# print resultsresponses.append(results)# 用于存储预期结果与实际结果的比较结果res Result_check().interface_result_check(results, res_check)request_urls.append(new_url)else:request_urls.append(new_url)if param :passelse:data json.loads(param)  # 将参数转化为json格式results requests.post(new_url, datajson.dumps(data), headersheaders).textresponses.append(results)res Result_check().interface_result_check(results, res_check)if pass in res:res_flags.append(pass)count_success 1else:logger.warning(u接口返回结果与预期结果不一致失败URL: %s METHOD :%s % (url, method))res_flags.append(fail)count_failure 1failed_case.append((interface_name, method, url))logger.info(u共执行 %s 条用例,PASS: %s,FAILED: %s % (len(case_list), count_success, count_failure))return res_flags, request_urls, responses, count_success, count_failure, failed_case 日志封装 # codingutf-8import loggingimport sysimport tracebackimport timeclass LoggingUtils:封装日志工具类的基本操作def __init__(self,logfile)::param logfile:self.logger logging.getLogger(logfile)self.hdlr logging.FileHandler(logfile)formatter logging.Formatter(%(asctime)s %(levelname)s - %(message)s)self.ch logging.StreamHandler()self.ch.setLevel(logging.INFO)self.ch.setFormatter(formatter)self.hdlr.setFormatter(formatter)self.logger.addHandler(self.hdlr)self.logger.addHandler(self.ch)self.logger.setLevel(logging.DEBUG)def debug(self, msg)::param msg::return:self.logger.debug(msg)self.hdlr.flush()def info(self, msg)::param msg::return:self.logger.info(msg)self.hdlr.flush()def warning(self,msg):self.logger.warning(msg)self.hdlr.flush()def error(self, msg)::param msg::return:self.logger.error(msg)# self.logger.removeHandler(logging.StreamHandler())self.logger.removeHandler(self.ch)self.hdlr.flush()def error_sys(self, limitNone)::param limit::return:exceptionType, exceptionValue, exceptionTraceback sys.exc_info()if limit is None:if hasattr(sys, tracebacklimit):limit sys.tracebacklimitn 0eline \nwhile exceptionTraceback is not None and (limit is None or n limit):f exceptionTraceback.tb_framelineno exceptionTraceback.tb_linenoco f.f_codefilename co.co_filenamename co.co_nameeline File %s, line %d, in %s \n % (filename, lineno, name)exceptionTraceback exceptionTraceback.tb_nextn n 1eline \n.join(traceback.format_exception_only(exceptionType, exceptionValue))self.logger.error(eline)self.hdlr.flush()timer time.strftime(%Y-%m-%d,time.localtime())logger LoggingUtils(%s.log%timer) 同时在这我为大家准备了一份软件测试视频教程含面试、接口、自动化、性能测试等就在下方需要的可以直接去观看也可以直接【点击文末小卡片免费领取资料文档】 软件测试视频教程观看处 软件测试工程师大忌盲目自学软件测试真的会毁终生能救一个是一个...... 结果比对 #coding:utf-8class result_check():def __init__(self):passdef result_check(self,results,res_check):结果对比函数#返回结果将结果中的json数据转化为可以和预期结果比较的数据res results.replace(:,).replace( : ,)#预期结果是xx11;xx22res_check res_check.split(;)for s in res_check:if s in res:passelse:return 结果不匹配 str(s)return passresult_save.py   保存测试结果的模块复制原有的用例保存为新的excel#coding:utf-8from xlutils import copyimport xlrdimport timeimport osclass Save_test_result():def __init__(self):passdef save_result(self,file_path,res_flags,request_urls,responses)::return:book xlrd.open_workbook(file_path)new_book copy.copy(book)sheet new_book.get_sheet(0)i 1for request_url, response, flag in zip(request_urls, responses, res_flags):sheet.write(i, 8, u%s % request_url)sheet.write(i, 9, u%s % response)sheet.write(i, 10, u%s % flag)i 1report_path os.path.abspath(os.path.join(report))if not os.path.exists(report_path):os.makedirs(report_path)new_book.save(os.path.abspath(os.path.join(report_path, Report%s.xls % time.strftime(%Y.%m.%d%H%M%S))))结果邮件 #coding:utf-8import smtplibfrom email.mime.text import MIMETextfrom email.header import Headerfrom email.mime.multipart import MIMEMultipartimport osfrom logging_save import  loggerclass Send_report(object):def __init__(self,count_success,count_failure,failed_case)::param count_success::param count_failure::param failed_case:self.count_success count_successself.count_failure count_failureself.failed_case failed_casedef newest_report(self,testreportreport):获取最新的测试报告:param testreport::return:lists os.listdir(testreport)lists.sort(keylambda fn: os.path.getmtime(os.path.join(testreport,fn)))file_new os.path.join(testreport, lists[-1])logger.info(获取最新附件报告成功)return file_newdef send_result(self,username,passwd,from_addr,to_addrs,smtpserver,*args)::param username::param passwd::param from_addr::param to_addrs::param smtpserver::param args::return:sender from_addrsubject 财富港接口测试结果username usernamepasswd passwd邮件内容tille (u用例名称, u请求方式, uurl)details (u成功: str(self.count_success) u失败: str(self.count_failure)) \n u失败的用例如下 : \\n \n.join(str(zip(tille, i)) for i in self.failed_case).decode(unicode-escape)logger.info(邮件附件为: %s %(args[0].split(\\)[1]))if args ! None: #判断是否添加附件msg MIMEMultipart()msg.attach(MIMEText(details, plain, utf-8))i 0while i len(args): #可以添加多个附件part MIMEText(open(args[i], rb).read(), base64, utf-8)part[Content-Type] application/octet-streampart[Content-Disposition] attachment; filename%s%args[i]msg.attach(part) #添加附件i 1msg[subject] Header(subject, utf-8)msg[From] from_addrmsg[To] ,.join(eval(to_addrs)) #兼容多个收件人smtp smtplib.SMTP()try:smtp.connect(smtpserver)smtp.login(username, passwd)smtp.sendmail(sender, eval(to_addrs), msg.as_string())smtp.close()logger.info(带附件测试报告发送成功)except smtplib.SMTPAuthenticationError,e:logger.error(邮箱账户或密码错误: str(e))else:msg MIMEText(details, plain, utf-8)msg[subject] Header(subject, utf-8)msg[From] from_addrmsg[To]  ,.join(eval(to_addrs))smtp smtplib.SMTP()try:smtp.connect(smtpserver)smtp.login(username, passwd)smtp.sendmail(sender, eval(to_addrs), msg.as_string())logger.info(测试报告发送成功)smtp.close()except smtplib.SMTPAuthenticationError,e:logger.error(邮箱账户或密码错误 : str(e)) 用例获取及数据格式化 #coding:utf-8import xlrdfrom logging_save import loggerclass Get_testcase(object):def __init__(self, file_path)::param file_path: 用例文件路径self.file_path file_pathdef readExcel(self):读取用例函数:return: 测试用例列表try:book xlrd.open_workbook(self.file_path)  # 打开excelexcept Exception, error:logger.error(路径不在或者excel不正确 : str(error))return errorelse:sheet book.sheet_by_index(0)  # 取第一个sheet页rows sheet.nrows  # 取这个sheet页的所有行数case_list []  # 用于保存用例信息for i in range(rows):if i ! 0:case_list.append(sheet.row_values(i)) # 把每一条测试用例添加到case_list中return case_list 请求url转换 #coding:utf-8class urltransform(object):def __init__(self):passdef urltransform(self, url, method, param)::return:if param :new_url urlelse:if method.upper() GET:new_url url ? param.replace(;, )  #如果有参数且为GET方法则组装urlelse:new_url urlreturn new_url 测试用例excel结构 config目录下config.py   获取配置文件信息的模块 #conding:utf-8import ConfigParserclass Config(object):def __init__(self,file_path):self.config ConfigParser.ConfigParser()self.config.read(file_path)def get_mail_config(self):login_user self.config.get(SMTP, login_user)login_pwd self.config.get(SMTP, login_pwd)from_addr self.config.get(SMTP, from_addr)to_addrs self.config.get(SMTP, to_addrs)smtp_server self.config.get(SMTP, smtp_server)port self.config.get(SMTP, port)return login_user, login_pwd , from_addr, to_addrs,smtp_server, portdef report_save_config(self):pass mail.conf [SMTP]login_user 18******163.comlogin_pwd ******from_addr BI18******163.comto_addrs [18******163.com]#to_addrs [1******qq.com,******.com]smtp_server smtp.163.comport 25测试报告 邮件接收结果 最后感谢每一个认真阅读我文章的人礼尚往来总是要有的虽然不是什么很值钱的东西如果你用得到的话可以直接拿走 这些资料对于做【软件测试】的朋友来说应该是最全面最完整的备战仓库这个仓库也陪伴我走过了最艰难的路程希望也能帮助到你凡事要趁早特别是技术行业一定要提升技术功底。
http://www.zqtcl.cn/news/923646/

相关文章:

  • 网站页面设计规范大连装修公司哪家好
  • 祁东网站建设微信公众号做的网站
  • 火山开发软件可以开发网站吗盐城代运营
  • 网页制作与网站建设从入门到精通民宿客栈网站制作
  • 如何写手机适配网站自己做的网站能上传到凡科吗
  • 建设公司网站开发方案seo优化工具的种类
  • 没备案的网站怎么做淘客企业做网站服务费
  • 网址站点异常怎么解决机关单位建设网站 说明
  • 阿虎手机站青岛关键词排名系统
  • 西安网站建设聚星互联网站成功案例
  • 山东鲁为建设集团网站百度的合作网站有哪些
  • 电子商务网站建设与管理程序设计题6哪家微网站做的好
  • 网站建设图文片平面网页设计是什么
  • 域外网站宁波建设监理协会
  • 胶州网站建设公司哪家好wordpress怎么改标题
  • php网站开发综合案例免费注册推广网站
  • 邯郸做网站的地方广州网站制作
  • 企业网站制作公司24小时接单郑州手机网站推广外包
  • 接做施工图的网站手机移动网站模板
  • 做网站月薪资多少钱如何打开微信小程序
  • 免费建站网站一级大录像不卡在线看网页无锡网站排名提升
  • 无锡门户网站制作服务郑州艾特网站建设
  • 建设网站 万网网页设计表单代码模板
  • 网站速度查询app开发模板网站
  • 国外案例网站做电商网站有什么用
  • 自己做的网站点击赚钱免费制作二级网站
  • 产品包装设计网站网站开发所需费用
  • 新手学做百度联盟网站html水平导航栏怎么做
  • 单页网站排名seo营销软件
  • 网站建设项目报告书广州品牌网站设计价格