代码贴全下
NOTE: Generated By HttpRunner v3.1.6
FROM: testcases\login.yml
import pytest
from httprunner import Parameters
from httprunner import HttpRunner, Config, Step, RunRequest, RunTestCase
class TestCaseLogin(HttpRunner):
@pytest.mark.parametrize(
“param”,
Parameters(
{
“name-user-pwd-check_body_code-check_body_msg”: “${parameterize(datas/login.csv)}”
}
),
)
def test_start(self, param):
super().test_start(param)
config = Config("登录模块").base_url("${ENV(BASE_URL)}").verify(False)
teststeps = [
Step(
RunRequest("$name")
.setup_hook("${get_password_encryption($request)}")
.post("/v4/app_user/email/login")
.with_headers(**{"Connection": "keep-alive", "lang": "zh_CN"})
.with_json({"email": "$user", "password": "$pwd"})
.validate()
.assert_equal("status_code", 200)
.assert_equal("body.code", "$check_body_code")
.assert_equal("body.msg", "$check_body_msg")
),
]
if name == “main”:
TestCaseLogin().test_start()
运行YML不会报错,直接运行py文件就会报错。
好像加了之后要用命令行的hrun 命令执行,不能直接右键run了
这里变成绿色可执行就行
如下面