mirror of
https://github.com/httprunner/httprunner.git
synced 2026-05-17 18:27:36 +08:00
refactor teardown_hooks set attribute: remove response attributes interlayer
This commit is contained in:
@@ -102,7 +102,10 @@ def alter_response(response):
|
||||
response.status_code = 500
|
||||
response.headers["Content-Type"] = "html/text"
|
||||
response.json["headers"]["Host"] = "127.0.0.1:8888"
|
||||
response.attributes["new_attribute"] = "new_attribute"
|
||||
response.new_attribute = "new_attribute_value"
|
||||
response.new_attribute_dict = {
|
||||
"key": 123
|
||||
}
|
||||
|
||||
def alter_response_error(response):
|
||||
# NameError
|
||||
|
||||
@@ -187,7 +187,8 @@ class TestRunner(ApiServerUnittest):
|
||||
{"eq": ["json.headers.Host", "127.0.0.1:8888"]},
|
||||
{"eq": ["content.headers.Host", "127.0.0.1:8888"]},
|
||||
{"eq": ["text.headers.Host", "127.0.0.1:8888"]},
|
||||
{"eq": ["attributes.new_attribute", "new_attribute"]}
|
||||
{"eq": ["new_attribute", "new_attribute_value"]},
|
||||
{"eq": ["new_attribute_dict.key", 123]}
|
||||
]
|
||||
}
|
||||
]
|
||||
@@ -216,7 +217,7 @@ class TestRunner(ApiServerUnittest):
|
||||
"${alter_response($response)}"
|
||||
],
|
||||
"validate": [
|
||||
{"eq": ["attributes.attribute_not_exist", "new_attribute"]}
|
||||
{"eq": ["attribute_not_exist", "new_attribute"]}
|
||||
]
|
||||
}
|
||||
]
|
||||
@@ -225,7 +226,7 @@ class TestRunner(ApiServerUnittest):
|
||||
runner = HttpRunner().run(testsets)
|
||||
summary = runner.summary
|
||||
self.assertFalse(summary["success"])
|
||||
self.assertEqual(summary["stat"]["failures"], 1)
|
||||
self.assertEqual(summary["stat"]["errors"], 1)
|
||||
|
||||
def test_run_httprunner_with_teardown_hooks_error(self):
|
||||
testsets = [
|
||||
|
||||
Reference in New Issue
Block a user