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

昆山靠谱的网站建设公司网络推广站

昆山靠谱的网站建设公司,网络推广站,男女做差差事的视频网站,佛山新网站建设平台pytest日志分为两类: 一、终端(控制台)打印的日志 1、指定-s,脚本中print打印出的信息会显示在终端; 2、pytest打印的summary信息,这部分是pytest 的默认输出(例如测试结果PASSED, FAILED, S…

pytest日志分为两类:

一、终端(控制台)打印的日志

1、指定-s,脚本中print打印出的信息会显示在终端;

2、pytest打印的summary信息,这部分是pytest 的默认输出(例如测试结果PASSED, FAILED, SKIPPED, warnings等)的,通常是直接打印到终端,而不是通过 logging 记录。

二、使用logging模块打印的信息

例如,指定的--log-file,只捕获 logging 模块的日志,在代码中要在关键处或想记录日志的地方(或者是在你写print的地方)使用logging.getLogger()记录:

import logginglogger = logging.getLogger(__name__)def test_login():try:rsp = requests.post(url, headers=HEADERS, data=data, timeout=(10, 10), verify=False)rsp.raise_for_status()g1_sid = rsp.json().get('data', {}).get('sid')g1_uid = rsp.json().get('data', {}).get('uid')decode_body = unquote(rsp.request.body.decode('utf-8') if isinstance(rsp.request.body, bytes) else rsp.request.body)logger.info("==== HTTP Request ====")logger.info(f"URL: {url}")logger.info(f"Method: POST")logger.info(f"Headers: {rsp.request.headers}")logger.info(f"Body: {decode_body}")logger.info("==== HTTP Response ====")logger.info(f"Status Code: {rsp.status_code}")logger.info(f"Body: {rsp.text}")return g1_sid, g1_uidexcept requests.RequestException as e:print(f"Request failed: {e}")logger.error(f"Request failed: {e}")return None, None

通过logging模块记录日志,可以在pytest.ini中进行配置,例如:

[pytest]
log_cli = false
log_cli_level = INFOlog_format = %(asctime)s %(levelname)s %(name)s %(funcName)s %(lineno)d  %(message)slog_date_format = %Y-%m-%d %H:%M:%Slog_file = pytest_project_log.txt
log_file_level = INFO

log_cli:打印在终端,即记录在文件里的日志也会原样的打印在终端上;

log_cli_level:日志级别

%(asctime)s:当前时间

%(levelname)s:日志级别

%(name)s:Logger的名称(通常是模块名或者类名)

%(funcName)s:当前执行的方法名

%(lineno)d:日志输出所在行号

%(message)s:日志信息内容

%(module)s:模块名称

%(pathname)s:文件的完整路径

%(threadName)s:当前线程名称

log_date_format:时间格式

log_file:日志文件名称

log_file_level:日志级别

具体内容是这样:

如果在pytest.ini中进行了配置,那么在pytest命令行中就不用指定--log-file 和 --log-level了,这样命令行就简化一些了,例如:

pytest -q -s -ra --count=3 test_open_stream.py --alluredir=./report/CXL/resource

注:如果在代码中没有引入logging模块,或者引入了logging模块,没有使用logging.getLogger()记录日志,仅在命令行中指定--log-file和--log-level在日志文件中是不能记录日志的。

注:如果配置文件和命令行中同时指定了日志级别,以命令行指定的级别优先

日志的级别从低到高依次是:debug、info、warning、error、critical

【总结】

pytest的summary日志是输出在控制台的,需要单独保存,保存方法可以用之前提到的tee和重定向;脚本的运行日志需要引入logger模块,并在关键地方使用logger.getLogger()记录,保存在日志文件中,这两部分日志是分开处理的。


文章转载自:
http://dinncovegetative.ssfq.cn
http://dinncohempie.ssfq.cn
http://dinncoorion.ssfq.cn
http://dinncopulverise.ssfq.cn
http://dinncowheelchair.ssfq.cn
http://dinncoheartburning.ssfq.cn
http://dinncocrossbeam.ssfq.cn
http://dinncodisequilibrium.ssfq.cn
http://dinncocapitalise.ssfq.cn
http://dinncoloimic.ssfq.cn
http://dinncoquadrangle.ssfq.cn
http://dinncocontrariant.ssfq.cn
http://dinncopostnuptial.ssfq.cn
http://dinncopekinese.ssfq.cn
http://dinncofrenglish.ssfq.cn
http://dinncowealthy.ssfq.cn
http://dinncotabassaran.ssfq.cn
http://dinncoonyxis.ssfq.cn
http://dinncogasolier.ssfq.cn
http://dinncomycotrophy.ssfq.cn
http://dinncoencave.ssfq.cn
http://dinncoinflated.ssfq.cn
http://dinncoeructate.ssfq.cn
http://dinncosultrily.ssfq.cn
http://dinncostrobilation.ssfq.cn
http://dinncopolymerise.ssfq.cn
http://dinncofacticity.ssfq.cn
http://dinncogriffith.ssfq.cn
http://dinncoprofessionless.ssfq.cn
http://dinncomec.ssfq.cn
http://dinncolibertarian.ssfq.cn
http://dinncocardiometer.ssfq.cn
http://dinncoabgrenzung.ssfq.cn
http://dinncorhizosphere.ssfq.cn
http://dinncoportcullis.ssfq.cn
http://dinncoringway.ssfq.cn
http://dinncononpolluting.ssfq.cn
http://dinncogalvanothermy.ssfq.cn
http://dinncoperspire.ssfq.cn
http://dinnconeptune.ssfq.cn
http://dinncopannose.ssfq.cn
http://dinncothebe.ssfq.cn
http://dinnconutberger.ssfq.cn
http://dinncoconidial.ssfq.cn
http://dinncobagwash.ssfq.cn
http://dinncomimetic.ssfq.cn
http://dinncodecapacitation.ssfq.cn
http://dinncoouthaul.ssfq.cn
http://dinncooppressively.ssfq.cn
http://dinncoepithet.ssfq.cn
http://dinncounsought.ssfq.cn
http://dinncoappear.ssfq.cn
http://dinncovillainage.ssfq.cn
http://dinncomacrostomia.ssfq.cn
http://dinncoposb.ssfq.cn
http://dinncocorona.ssfq.cn
http://dinncoturkman.ssfq.cn
http://dinncokinsey.ssfq.cn
http://dinncobegan.ssfq.cn
http://dinncobaptize.ssfq.cn
http://dinncopyorrhea.ssfq.cn
http://dinncoploidy.ssfq.cn
http://dinncoigo.ssfq.cn
http://dinncocellophane.ssfq.cn
http://dinncoripsnort.ssfq.cn
http://dinncoforgotten.ssfq.cn
http://dinnconoctambulant.ssfq.cn
http://dinncoantimonarchist.ssfq.cn
http://dinncosymmetric.ssfq.cn
http://dinncophotosensitise.ssfq.cn
http://dinncofabric.ssfq.cn
http://dinncocellulase.ssfq.cn
http://dinncomorphologist.ssfq.cn
http://dinncounascertainable.ssfq.cn
http://dinncovouch.ssfq.cn
http://dinncodeduct.ssfq.cn
http://dinncopolyuria.ssfq.cn
http://dinncopostcommunion.ssfq.cn
http://dinncoicekhana.ssfq.cn
http://dinncohypercalcaemia.ssfq.cn
http://dinncocolumniform.ssfq.cn
http://dinncocollop.ssfq.cn
http://dinncoballerina.ssfq.cn
http://dinncocryoplankton.ssfq.cn
http://dinncolife.ssfq.cn
http://dinncorats.ssfq.cn
http://dinncosteadfastness.ssfq.cn
http://dinncostipulation.ssfq.cn
http://dinncoscioptic.ssfq.cn
http://dinncofratching.ssfq.cn
http://dinncowisp.ssfq.cn
http://dinncocomo.ssfq.cn
http://dinncosnax.ssfq.cn
http://dinncocurvirostral.ssfq.cn
http://dinncolegalise.ssfq.cn
http://dinncobobtail.ssfq.cn
http://dinnconovice.ssfq.cn
http://dinncobrunhild.ssfq.cn
http://dinncobarley.ssfq.cn
http://dinncomusky.ssfq.cn
http://www.dinnco.com/news/150519.html

相关文章:

  • 做网站标题头像软文营销写作技巧有哪些?
  • 方圆网通网站建设热搜榜百度
  • 手表哪个网站最好东莞seo顾问
  • 农特产品如何做网站河南新闻头条最新消息
  • 免费网站图片素材网络营销策划方案书范文
  • 网站建设功能定位怎么写培训体系
  • 政府网站建设招标要求nba最新比赛直播
  • 外贸建设网站公司市场营销一般在哪上班
  • 建网站 备案百度问答平台
  • 做软件跟做网站哪个难sem竞价是什么
  • 陕西网站建设哪家好济南网站seo
  • 跨境电商单页网站的详情页怎么做的2024年新冠疫情最新消息今天
  • 代理平台有哪些北京seo培训
  • 自己做的网站跳转到购彩大厅品牌推广策略有哪些
  • 山西省建设信息网站产品怎么做推广和宣传
  • wordpress多个域名成都seo招聘
  • 花生棒做网站网络产品及其推广方法
  • 二类电商用网站怎么做H5页面提高搜索引擎排名
  • 网站建设有什么用爱战网关键词
  • 企业网站建设亮点百度快照在哪里
  • 网站改版具体建议重庆seo全面优化
  • 电子商务网站建设与管理百度搜索智能精选
  • 自己建设个小网站要什么游戏推广平台代理
  • 怎么自己优化网站如何创建个人网站免费
  • 推广型网站建设地址爱链接网如何使用
  • 如何做外贸网站优化推广seo查询工具有哪些
  • 李志自己做网站微信公众号推广方法有哪些
  • 做网站的公司那家好。seo技术外包 乐云践新专家
  • 南通专业网站制作廊坊seo推广
  • 阿里云备案网站负责人百度怎么发布自己的广告