MCPcopy
hub / github.com/httprunner/httprunner / TestCaseHooks

Class TestCaseHooks

examples/httpbin/hooks_test.py:6–31  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

4
5
6class TestCaseHooks(HttpRunner):
7
8 config = Config("basic test with httpbin").base_url("${get_httpbin_server()}")
9
10 teststeps = [
11 Step(
12 RunRequest("headers")
13 .with_variables(**{"a": 123})
14 .setup_hook("${setup_hook_add_kwargs($request)}")
15 .setup_hook("${setup_hook_remove_kwargs($request)}")
16 .get("/headers")
17 .teardown_hook("${teardown_hook_sleep_N_secs($response, 1)}")
18 .validate()
19 .assert_equal("status_code", 200)
20 .assert_contained_by("body.headers.Host", "${get_httpbin_server()}")
21 ),
22 Step(
23 RunRequest("alter response")
24 .get("/headers")
25 .teardown_hook("${alter_response($response)}")
26 .validate()
27 .assert_equal("status_code", 500)
28 .assert_equal('headers."Content-Type"', "html/text")
29 .assert_equal("body.headers.Host", "127.0.0.1:8888")
30 ),
31 ]
32
33
34if __name__ == "__main__":

Callers 1

hooks_test.pyFile · 0.85

Calls 11

ConfigClass · 0.90
StepClass · 0.90
RunRequestClass · 0.90
base_urlMethod · 0.80
assert_contained_byMethod · 0.80
assert_equalMethod · 0.80
validateMethod · 0.45
teardown_hookMethod · 0.45
getMethod · 0.45
setup_hookMethod · 0.45
with_variablesMethod · 0.45

Tested by

no test coverage detected