| 4 | |
| 5 | |
| 6 | class 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 | |
| 34 | if __name__ == "__main__": |
no test coverage detected