mirror of
https://github.com/httprunner/httprunner.git
synced 2026-05-19 00:17:37 +08:00
add TeardownHooksFailure exception
This commit is contained in:
@@ -103,3 +103,7 @@ def alter_response(response):
|
||||
response.headers["Content-Type"] = "html/text"
|
||||
response.json["headers"]["Host"] = "127.0.0.1:8888"
|
||||
response.attributes["new_attribute"] = "new_attribute"
|
||||
|
||||
def alter_response_error(response):
|
||||
# NameError
|
||||
not_defined_variable
|
||||
|
||||
@@ -222,11 +222,37 @@ class TestRunner(ApiServerUnittest):
|
||||
]
|
||||
}
|
||||
]
|
||||
# with self.assertRaises(exceptions.AssertionError):
|
||||
runner = HttpRunner().run(testsets)
|
||||
|
||||
summary = runner.summary
|
||||
self.assertFalse(summary["success"])
|
||||
self.assertEqual(summary["stat"]["failures"], 1)
|
||||
|
||||
def test_run_httprunner_with_teardown_hooks_error(self):
|
||||
testsets = [
|
||||
{
|
||||
"name": "test teardown hooks",
|
||||
"config": {
|
||||
'path': 'tests/httpbin/hooks.yml',
|
||||
},
|
||||
"testcases": [
|
||||
{
|
||||
"name": "test teardown hooks",
|
||||
"request": {
|
||||
"url": "http://127.0.0.1:3458/headers",
|
||||
"method": "GET",
|
||||
"data": "abc"
|
||||
},
|
||||
"teardown_hooks": [
|
||||
"${alter_response_error($response)}"
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
runner = HttpRunner().run(testsets)
|
||||
summary = runner.summary
|
||||
self.assertFalse(summary["success"])
|
||||
self.assertEqual(summary["stat"]["errors"], 1)
|
||||
|
||||
def test_run_testset_with_teardown_hooks_success(self):
|
||||
test = {
|
||||
|
||||
Reference in New Issue
Block a user