问题
httprunner4.0,前端传过来的json,执行不了。报错
代码
from httprunner import HttpRunner, Config, Step, RunRequest, RunTestCase
#httprunner 4.3 python 3.10
testcase = {
"config": {
"name": "test case name",
"base_url": "http://baidu.com"
},
"teststeps": [
{
"name": "get request",
"request": {
"method": "GET",
"url": "/get"
},
"validate": [
{
"equals": ["status_code", 200]
}
]
}
]
}
runner = HttpRunner()
runner.test_start(testcase.get('teststeps'))
报错信息
D:\rj\Python\python3.10\python.exe D:/rj/python_code/seer_utils/Tool/httprunner/11.py
Traceback (most recent call last):
File “D:\rj\python_code\seer_utils\Tool\httprunner\11.py”, line 27, in
runner.test_start(testcase.get(‘teststeps’))
File “D:\rj\Python\python3.10\lib\site-packages\httprunner\runner.py”, line 215, in test_start
self.__init()
File “D:\rj\Python\python3.10\lib\site-packages\httprunner\runner.py”, line 57, in __init
self.__config = self.config.struct()
AttributeError: ‘HttpRunner’ object has no attribute ‘config’
环境
httprunner 4.3 python 3.10