pytest_lean2.py
#coding=utf-
import pytest
import os
import sys
import time
import json
sys.path.append("/".join(os.path.dirname(os.path.abspath(__file__)).split("/")[:-])+"/lib")
import requests
sys.path.append("/".join(os.path.dirname(os.path.abspath(__file__)).split("/")[:-]))
from util.getinfolib import getinfo
import logging,sys log = logging.getLogger(__name__) class TestUM: '''
setup_class**********>
setup_method##########>>
setup---------->
teardown---------->
teardown_method##########>>
teardown_class**********>
'''
def setup(self):
print ("setup---------->")
def teardown(self):
print ("teardown---------->")
def setup_class(self):
self.dic={}
self.url_1=getinfo().go()
self.headers={
'Accept': 'application/json, text/plain, */*'
,'client': 'Web'
,'Content-Type': 'application/json;charset=UTF-8'
,'Origin': self.url_1
,'Referer': self.url_1
,'token': 'NGKPaLge8urbOlOAuHasURwYP4AKQIo8O1zad5F3vLA='
,'User-Agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_13_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/77.0.3865.90 Safari/537.36'
}
print ("\nsetup_class**********>")
def teardown_class(self):
print ("teardown_class**********>")
def setup_method(self, method):
print ("setup_method##########>>")
def teardown_method(self, method):
print ("teardown_method##########>>") def get_company_id(self,url,type,companyName):
payload={
"companyType":type,
"companyStatus":"",
"hasEnv":"",
"hasDevice":"",
"page": ,
"size": ,
"companyName":""
}
r = requests.get(url, params=payload,headers=self.headers)
assert r.status_code==
assert r.json()['code']== company_list=r.json()["data"]['content']
for i in company_list:
if(i["companyName"]==companyName):
if(type==):
self.dic["waste_company_id"]=i["id"]
elif(type==):
self.dic["consumer_company_id"]=i["id"]
elif(type==):
self.dic["transport_company_id"]=i["id"]
elif(type==):
self.dic["operate_company_id"]=i["id"]
else:
self.dic["charge_company_id"]=i["id"]
break # kaptcha
def test_kaptcha(self): url=self.url_1+"/login/kaptcha"
payload = {}
r = requests.get(url, params=payload) assert r.status_code==
# login
def test_login_pc(self): url=self.url_1+"/login/pc"
payload = {"userName":"abc","passWord":"","kaptcha":""}
r = requests.get(url, params=payload)
self.dic["token"]=r.json()['data']['token']
self.dic["t"]=time.strftime("%Y%m%d%H%M%S", time.localtime())
self.headers["token"]=self.dic["token"] assert r.status_code==
assert r.json()['code']== # add_waste_company
def test_add_waste_company(self): url=self.url_1+"/companies"
payload={"companyName":"test产废单位","companyType":,"companyLinkman":"小明","companyPhone":"","address":{"province":,"city":,"area":,"street":,"detail":"东京市红高粱村"},"gpsLocation":"130,40","email":"ewew@qq.com","businessLicenceUrl":r"http://test-icloudeep-img.oss-cn-beijing.aliyuncs.com/module/uploads/cd7288dfc50f4a25ba15929e685a7f10.jpeg","nearWater":,"industryType":"mouldOfPlastics","companyStatus":"",'companyDesc':'原料'}
payload["companyName"]=payload["companyName"]+self.dic["t"]
payload["companyLinkman"]=payload["companyLinkman"]+self.dic["t"]
payload["companyDesc"]=payload["companyDesc"]+self.dic["t"] #带有嵌套的字典,需要转换为json传输
r = requests.post(url, data=json.dumps(payload),headers=self.headers) assert r.status_code==
assert r.json()['code']== #获取单位ID
self.get_company_id(url,payload["companyType"],payload["companyName"]) # add_trans_company
def test_add_trans_company(self): url=self.url_1+"/companies"
payload={"companyName":"test运输单位","companyType":,"companyLinkman":"小明","companyPhone":"","address":{"province":,"city":,"area":,"street":,"detail":"东京市红高粱村"},"gpsLocation":"132,26","email":"swded@qq.com","businessLicenceUrl":"http://test-icloudeep-img.oss-cn-beijing.aliyuncs.com/module/uploads/62c0eb0f821141cda92ffcec25d4208d.jpeg","remark":"备注"}
payload["companyName"]=payload["companyName"]+self.dic["t"]
payload["companyLinkman"]=payload["companyLinkman"]+self.dic["t"]
payload["remark"]=payload["remark"]+self.dic["t"] #带有嵌套的字典,需要转换为json传输
r = requests.post(url, data=json.dumps(payload),headers=self.headers) assert r.status_code==
assert r.json()['code']== #获取单位ID
self.get_company_id(url,payload["companyType"],payload["companyName"]) # add_consumer_company
def test_add_consumer_company(self): url=self.url_1+"/companies"
payload={"companyName":"test处置单位","companyType":,"companyLinkman":"小明","companyPhone":"","address":{"province":,"city":,"area":,"street":,"detail":"东京市红高粱村"},"gpsLocation":"132,23","email":"wqwq@qq.com","businessLicenceUrl":"http://test-icloudeep-img.oss-cn-beijing.aliyuncs.com/module/uploads/c36c0e66b9954761a90aba9f5b19c71d.jpeg","remark":"备注","nearWater":""}
payload["companyName"]=payload["companyName"]+self.dic["t"]
payload["companyLinkman"]=payload["companyLinkman"]+self.dic["t"]
payload["remark"]=payload["remark"]+self.dic["t"] #带有嵌套的字典,需要转换为json传输
r = requests.post(url, data=json.dumps(payload),headers=self.headers) assert r.status_code==
assert r.json()['code']== #获取单位ID
self.get_company_id(url,payload["companyType"],payload["companyName"]) # add_charge_company
def test_add_charge_company(self): url=self.url_1+"/companies"
payload={"companyName":"test监管单位","companyType":,"companyLinkman":"小明","companyPhone":"","address":{"province":,"city":,"area":,"street":,"detail":"东京市红高粱村"},"gpsLocation":"132,22","email":"swsq@qq.com","businessLicenceUrl":"http://test-icloudeep-img.oss-cn-beijing.aliyuncs.com/module/uploads/f448cc7669cf45eda56b6181d1bd20b7.jpeg","remark":"备注","adminArea":{"wholeCountry":"false","province":,"city":"","area":"","street":""}}
payload["companyName"]=payload["companyName"]+self.dic["t"]
payload["companyLinkman"]=payload["companyLinkman"]+self.dic["t"]
payload["remark"]=payload["remark"]+self.dic["t"] #带有嵌套的字典,需要转换为json传输
r = requests.post(url, data=json.dumps(payload),headers=self.headers) assert r.status_code==
assert r.json()['code']== #获取单位ID
self.get_company_id(url,payload["companyType"],payload["companyName"]) # add_operate_company
def test_add_operate_company(self): url=self.url_1+"/companies"
payload={"companyName":"test运营单位","companyType":,"companyLinkman":"小明","companyPhone":"","address":{"province":,"city":,"area":,"street":,"detail":"东京市红高粱村"},"gpsLocation":"132,26","email":"deswaq@qq.com","businessLicenceUrl":"http://test-icloudeep-img.oss-cn-beijing.aliyuncs.com/module/uploads/7a4c448f9ec349a496d414440f42f09f.jpeg","remark":"备注","adminArea":{"wholeCountry":"false","province":,"city":,"area":"","street":""}}
payload["companyName"]=payload["companyName"]+self.dic["t"]
payload["companyLinkman"]=payload["companyLinkman"]+self.dic["t"]
payload["remark"]=payload["remark"]+self.dic["t"] #带有嵌套的字典,需要转换为json传输
r = requests.post(url, data=json.dumps(payload),headers=self.headers) assert r.status_code==
assert r.json()['code']== #获取单位ID
self.get_company_id(url,payload["companyType"],payload["companyName"]) # add_wasteinfo_company def test_add_wasteinfo_company(self):
url=self.url_1+"/companies/"+self.dic["waste_company_id"]+"/declarations/producer"
payload={"wasteInfo":[{"wasteType":"HW09","wasteCode":"900-005-09","customWasteName":"废乳化液","yearDeclare":"","consumerId":"20191126200118230CP515590"}]}
payload["wasteInfo"][]["consumerId"]=self.dic["consumer_company_id"]
#带有嵌套的字典,需要转换为json传输
r = requests.post(url,data=json.dumps(payload),headers=self.headers)
log.info(r.json())
assert r.status_code==
assert r.json()['code']==

调用命令

pytest pytest_lean2.py -o log_cli=true -o log_cli_level=INFO

参考:

https://www.cnblogs.com/landhu/p/9910460.html

pytest 打印调试信息的更多相关文章

  1. STM32M CUBE实现printf打印调试信息以及实现单字节接收

    在写单片机程序时我们一般喜欢使用printf来通过串口打印调试信息,但这个函数是不能够直接使用的.必须做点对库函数的修改. 具体project下载地址: http://download.csdn.ne ...

  2. debug.js在手机上打印调试信息

    在做移动端开发的时候大家应该都遇到过这么一个问题:如何在手机上打印调试信息? 在pc端我们通常会用console.log 或者 alert,但大家知道console.log在手机上是看不到打印信息的: ...

  3. rpm命令如何打印调试信息?

    问题描述: 今天在做rpm相关操作的时候,发现报错,并且还不知道如何入手来解决问题,就左查右查的问题还是没有解决,后来就想,rpm能否打印debug信息,然后也百度了,也没有找到,后来想我为啥不看看r ...

  4. NDK编程中如何在C文件中打印调试信息

      1,在Android.mk文件中加上 LOCAL_LDLIBS := -L$(SYSROOT)/usr/lib -llog LOCAL_PATH := $(call my-dir)include ...

  5. Android Studio 打印调试信息

    转自:https://www.2cto.com/kf/201611/569468.html 之前开发单片机软件还是上位机都习惯使用printf(),相信很多很会有和我一样的习惯.开始学习安卓了,当然也 ...

  6. VC++6.0 打印调试信息

    1.在MFC中加入TRACE语句 2.在TOOLS->MFC TRACER中选择 “ENABLE TRACING”点击OK 3.进行调试运行,GO(F5)(特别注意:不是执行‘!’以前之所以不能 ...

  7. QT+VS中使用qDebug()打印调试信息无法显示

    首先右键点击项目名称,找到最后一项属性 然后依次设置为如图所示即可 再次编译后,会弹出CMD窗口,出现qDebug的调试信息.

  8. Logcat打印调试信息

    Android Logcat调试中的V.D.I.W.E的分别代表什么? Log.v -- 黑色 -- verbose infoLog.d -- 蓝色 -- debug infoLog.i -- 绿色 ...

  9. [ios2]iphone编程中使用封装的NSLog来打印调试信息 【转】

    使用NSLog的一个风险是:它的运行会占用时间和设备资源. 简单而粗暴的解决方案是:在release前,将所有的NSLog注释掉.简单有效,但副作用是:下次你要调试时,又得将NSLog一个个取消注释. ...

随机推荐

  1. Linux内核调优部分参数说明

    #接收套接字缓冲区大小的默认值(以字节为单位). net.core.rmem_default = 262144 #接收套接字缓冲区大小的最大值(以字节为单位). net.core.rmem_max = ...

  2. 【03】Kubernets:K8S 操作入门

    写在前面的话 经过上一节,我们顺利将 K8S 集群搭建了起来,在其中我也简单的谈了一下关于 K8S 的网络.那么这一节我们主要谈谈如何来简单的使用 K8S 的命令.当然这些命令有很多,我们只是通过一个 ...

  3. 关于plupload组件无法拍照上传的解决方案

    关于plupload组件无法拍照上传的解决方案 其实是由于文件大小的问题 filters: { max_file_size: '2mb',//把这个调大些就可以了 前提是服务器支持 prevent_d ...

  4. Layui 时间转换时间戳

    我比较喜欢用Layui,当然也遇到一些坑!例如:绑定时间的时候是那种 是这种13位数据的日期,如果不经过转换是不能正常显示的,当然这是我遇到的问题不知道你们有没有遇到,后来我也是经过了解才知道怎么回事 ...

  5. 【转】Visual Studio Code(VS code)你们都在用吗?或许你们需要看一下这篇博文

    写在前面 在前端开发中,有一个非常好用的工具,Visual Studio Code,简称VS code. 都不用我安利VS code,大家就会乖乖的去用,无数个大言不惭的攻城狮,都被VS code比德 ...

  6. .Net Core 3.0 WebAPI && MySQL 8.0搭建详情

    微软在2019年9月24日发布了dotNet Core 3.0和C# 8.0,添加了许多新Features,详情点我.无疑dotNet Core 3.0和一个月之后即将发布的dotNet Core 3 ...

  7. Git 快速极简图文教程 第一篇

    Git简介 Git 是目前使用最广泛,最著名的工具.据了解,目前绝大部分互联网公司都已经全部切入到git作为版本管理工具,尤其是bat等头部公司,这是一个标准的技能. Git 最早是有linux之父, ...

  8. 使用脚本安装elasticsearch7.3的记录

    使用脚本安装elasticsearch7.3的记录 #!/bin/sh # https://www.elastic.co/guide/en/elasticsearch/reference/curren ...

  9. pymysql操作(老版本的,新版有基础不同)

    导入库 import pymysql 创建链接 conn=pymysql.connect(host='127.0.0.1',port='3306',user='root',passwd='123456 ...

  10. 【SSH错误】ssh_exchange_identification: read: Connection reset by peer

    进行远程登录时,ssh root@xxxxxxxxx出现如下错误 ssh_exchange_identification: read: Connection reset by peer 解决方案:登录 ...