mirror of
https://github.com/httprunner/httprunner.git
synced 2026-07-11 23:41:44 +08:00
refactor: hrp build
This commit is contained in:
@@ -2,11 +2,9 @@ import logging
|
||||
import time
|
||||
from typing import List
|
||||
|
||||
import funppy
|
||||
|
||||
|
||||
def get_version():
|
||||
return funppy.__version__
|
||||
def get_user_agent():
|
||||
return "hrp/funppy"
|
||||
|
||||
|
||||
def sleep(n_secs):
|
||||
@@ -57,17 +55,3 @@ def setup_hook_example(name):
|
||||
def teardown_hook_example(name):
|
||||
logging.warning("teardown_hook_example")
|
||||
return f"teardown_hook_example: {name}"
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
funppy.register("get_version", get_version)
|
||||
funppy.register("sum", sum)
|
||||
funppy.register("sum_ints", sum_ints)
|
||||
funppy.register("concatenate", concatenate)
|
||||
funppy.register("sum_two_int", sum_two_int)
|
||||
funppy.register("sum_two", sum_two_int)
|
||||
funppy.register("sum_two_string", sum_two_string)
|
||||
funppy.register("sum_strings", sum_strings)
|
||||
funppy.register("setup_hook_example", setup_hook_example)
|
||||
funppy.register("teardown_hook_example", teardown_hook_example)
|
||||
funppy.serve()
|
||||
|
||||
@@ -1,75 +0,0 @@
|
||||
# NOTE: Generated By hrp v4.1.0-beta, DO NOT EDIT!
|
||||
|
||||
import logging
|
||||
import time
|
||||
import funppy
|
||||
|
||||
from typing import List
|
||||
|
||||
|
||||
def get_version():
|
||||
return funppy.__version__
|
||||
|
||||
|
||||
def sleep(n_secs):
|
||||
time.sleep(n_secs)
|
||||
|
||||
|
||||
def sum(*args):
|
||||
result = 0
|
||||
for arg in args:
|
||||
result += arg
|
||||
return result
|
||||
|
||||
|
||||
def sum_ints(*args: List[int]) -> int:
|
||||
result = 0
|
||||
for arg in args:
|
||||
result += arg
|
||||
return result
|
||||
|
||||
|
||||
def sum_two_int(a: int, b: int) -> int:
|
||||
return a + b
|
||||
|
||||
|
||||
def sum_two_string(a: str, b: str) -> str:
|
||||
return a + b
|
||||
|
||||
|
||||
def sum_strings(*args: List[str]) -> str:
|
||||
result = ""
|
||||
for arg in args:
|
||||
result += arg
|
||||
return result
|
||||
|
||||
|
||||
def concatenate(*args: List[str]) -> str:
|
||||
result = ""
|
||||
for arg in args:
|
||||
result += str(arg)
|
||||
return result
|
||||
|
||||
|
||||
def setup_hook_example(name):
|
||||
logging.warning("setup_hook_example")
|
||||
return f"setup_hook_example: {name}"
|
||||
|
||||
|
||||
def teardown_hook_example(name):
|
||||
logging.warning("teardown_hook_example")
|
||||
return f"teardown_hook_example: {name}"
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
funppy.register("get_version", get_version)
|
||||
funppy.register("sleep", sleep)
|
||||
funppy.register("sum", sum)
|
||||
funppy.register("sum_ints", sum_ints)
|
||||
funppy.register("sum_two_int", sum_two_int)
|
||||
funppy.register("sum_two_string", sum_two_string)
|
||||
funppy.register("sum_strings", sum_strings)
|
||||
funppy.register("concatenate", concatenate)
|
||||
funppy.register("setup_hook_example", setup_hook_example)
|
||||
funppy.register("teardown_hook_example", teardown_hook_example)
|
||||
funppy.serve()
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"project_name": "demo-with-py-plugin",
|
||||
"project_path": "/Users/debugtalk/MyProjects/HttpRunner-dev/httprunner/examples/demo-with-py-plugin",
|
||||
"create_time": "2022-05-28T12:05:33.048579+08:00",
|
||||
"hrp_version": "v4.1.0-beta"
|
||||
"create_time": "2022-05-28T21:41:04.822656+08:00",
|
||||
"hrp_version": "v4.1.0"
|
||||
}
|
||||
@@ -24,7 +24,7 @@ teststeps:
|
||||
method: POST
|
||||
url: /post
|
||||
headers:
|
||||
User-Agent: funplugin/${get_version()}
|
||||
User-Agent: ${get_user_agent()}
|
||||
Content-Type: "application/x-www-form-urlencoded"
|
||||
body: "foo1=$foo1&foo2=$foo3"
|
||||
validate:
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
"expect_foo2": "config_bar2"
|
||||
},
|
||||
"headers": {
|
||||
"User-Agent": "funplugin/${get_version()}"
|
||||
"User-Agent": "${get_user_agent()}"
|
||||
},
|
||||
"base_url": "https://postman-echo.com",
|
||||
"verify": false,
|
||||
|
||||
@@ -6,7 +6,7 @@ config:
|
||||
expect_foo1: config_bar1
|
||||
expect_foo2: config_bar2
|
||||
headers:
|
||||
User-Agent: funplugin/${get_version()}
|
||||
User-Agent: ${get_user_agent()}
|
||||
verify: False
|
||||
export: ["foo3"]
|
||||
|
||||
|
||||
Reference in New Issue
Block a user