我正在探索pytest以自动化测试活动。我想将var
值存储在一个.py文件中,该文件位于“TestCases”文件夹之外。JSON正文是:
req_json= "{ \r\n\"ReqParamList\": { \r\n \"StdValue\": \"age@name\" \r\n } \r\n}"
resp = requests.request("POST", cURL, data=req_json, headers=headers, params=eid)
年龄和姓名从数据库中提取,并作为var存储在单独的py文件中
import mysql.connector
from mysql.connector import errors
try:
cnx = mysql.connector.connect(
host="hostname",
port=port,
database="dbname",
user="uname",
connection_timeout=5,
password="pw")
# Fname
FnameCur = cnx.cursor()
RandomFname = ("select fname from firstnames limit 1")
FnameCur .execute(RandomFname)
for row in FnameCur :
fname = (row[0])
print("fname is:", fname)
# Lname
LnameCur = cnx.cursor()
RandomLname = ("select Lname from lasttnames where Lname in (select "
"Lname from (select Lname from lasttnames ORDER BY RAND("
") limit 1)t)")
LnameCur.execute(RandomLname )
for row in LnameCur:
Lname = (row[0])
print ("Lname is:",Lname)
except Error as e:
print("Error", e)
finally:
if (cnx.is_connected()):
fnameCur .close()
LnameCur.close()
谁能帮我一下吗
目前没有回答
相关问题 更多 >
编程相关推荐