mirror of
https://github.com/httprunner/httprunner.git
synced 2026-05-16 11:27:37 +08:00
feat: make pytest files in chain style
This commit is contained in:
@@ -1,77 +1,57 @@
|
||||
# NOTICE: Generated By HttpRunner. DO NOT EDIT!
|
||||
# FROM: examples/postman_echo/request_methods/hardcode.yml
|
||||
|
||||
from httprunner import HttpRunner, TConfig, TStep
|
||||
from httprunner import HttpRunner, Config, Step, RunRequest, RunTestCase
|
||||
|
||||
|
||||
class TestCaseHardcode(HttpRunner):
|
||||
config = TConfig(
|
||||
**{
|
||||
"name": "request methods testcase in hardcode",
|
||||
"base_url": "https://postman-echo.com",
|
||||
"verify": False,
|
||||
"path": "examples/postman_echo/request_methods/hardcode_test.py",
|
||||
"variables": {},
|
||||
}
|
||||
config = (
|
||||
Config("request methods testcase in hardcode")
|
||||
.base_url("https://postman-echo.com")
|
||||
.verify(False)
|
||||
)
|
||||
|
||||
teststeps = [
|
||||
TStep(
|
||||
**{
|
||||
"name": "get with params",
|
||||
"request": {
|
||||
"method": "GET",
|
||||
"url": "/get",
|
||||
"params": {"foo1": "bar1", "foo2": "bar2"},
|
||||
"headers": {"User-Agent": "HttpRunner/3.0"},
|
||||
},
|
||||
"validate": [{"eq": ["status_code", 200]}],
|
||||
}
|
||||
Step(
|
||||
RunRequest("get with params")
|
||||
.get("/get")
|
||||
.with_params(**{"foo1": "bar1", "foo2": "bar2"})
|
||||
.with_headers(**{"User-Agent": "HttpRunner/3.0"})
|
||||
.validate()
|
||||
.assert_equal("status_code", 200)
|
||||
),
|
||||
TStep(
|
||||
**{
|
||||
"name": "post raw text",
|
||||
"request": {
|
||||
"method": "POST",
|
||||
"url": "/post",
|
||||
"headers": {
|
||||
"User-Agent": "HttpRunner/3.0",
|
||||
"Content-Type": "text/plain",
|
||||
},
|
||||
"data": "This is expected to be sent back as part of response body.",
|
||||
},
|
||||
"validate": [{"eq": ["status_code", 200]}],
|
||||
}
|
||||
Step(
|
||||
RunRequest("post raw text")
|
||||
.post("/post")
|
||||
.with_headers(
|
||||
**{"User-Agent": "HttpRunner/3.0", "Content-Type": "text/plain"}
|
||||
)
|
||||
.with_data("This is expected to be sent back as part of response body.")
|
||||
.validate()
|
||||
.assert_equal("status_code", 200)
|
||||
),
|
||||
TStep(
|
||||
**{
|
||||
"name": "post form data",
|
||||
"request": {
|
||||
"method": "POST",
|
||||
"url": "/post",
|
||||
"headers": {
|
||||
"User-Agent": "HttpRunner/3.0",
|
||||
"Content-Type": "application/x-www-form-urlencoded",
|
||||
},
|
||||
"data": "foo1=bar1&foo2=bar2",
|
||||
},
|
||||
"validate": [{"eq": ["status_code", 200]}],
|
||||
}
|
||||
Step(
|
||||
RunRequest("post form data")
|
||||
.post("/post")
|
||||
.with_headers(
|
||||
**{
|
||||
"User-Agent": "HttpRunner/3.0",
|
||||
"Content-Type": "application/x-www-form-urlencoded",
|
||||
}
|
||||
)
|
||||
.with_data("foo1=bar1&foo2=bar2")
|
||||
.validate()
|
||||
.assert_equal("status_code", 200)
|
||||
),
|
||||
TStep(
|
||||
**{
|
||||
"name": "put request",
|
||||
"request": {
|
||||
"method": "PUT",
|
||||
"url": "/put",
|
||||
"headers": {
|
||||
"User-Agent": "HttpRunner/3.0",
|
||||
"Content-Type": "text/plain",
|
||||
},
|
||||
"data": "This is expected to be sent back as part of response body.",
|
||||
},
|
||||
"validate": [{"eq": ["status_code", 200]}],
|
||||
}
|
||||
Step(
|
||||
RunRequest("put request")
|
||||
.put("/put")
|
||||
.with_headers(
|
||||
**{"User-Agent": "HttpRunner/3.0", "Content-Type": "text/plain"}
|
||||
)
|
||||
.with_data("This is expected to be sent back as part of response body.")
|
||||
.validate()
|
||||
.assert_equal("status_code", 200)
|
||||
),
|
||||
]
|
||||
|
||||
|
||||
Reference in New Issue
Block a user