Files
httprunner.py/examples/httpbin/upload_test.py
2025-02-05 21:32:44 +08:00

39 lines
1.1 KiB
Python

# NOTE: Generated By HttpRunner v4.3.5
# FROM: upload.yml
from httprunner import HttpRunner, Config, Step, RunRequest
class TestCaseUpload(HttpRunner):
config = Config("test upload file with httpbin").base_url("${get_httpbin_server()}")
teststeps = [
Step(
RunRequest("upload file")
.with_variables(
**{
"file_path": "test.env",
"m_encoder": "${multipart_encoder(file=$file_path)}",
}
)
.post("/post")
.with_headers(**{"Content-Type": "${multipart_content_type($m_encoder)}"})
.with_data("$m_encoder")
.validate()
.assert_equal("status_code", 200)
.assert_startswith("body.files.file", "UserName=test")
),
Step(
RunRequest("upload file with keyword")
.post("/post")
.upload(**{"file": "test.env"})
.validate()
.assert_equal("status_code", 200)
.assert_startswith("body.files.file", "UserName=test")
),
]
if __name__ == "__main__":
TestCaseUpload().test_start()