mirror of
https://github.com/httprunner/httprunner.git
synced 2026-09-05 23:51:25 +08:00
change varaible name: response content => response body
This commit is contained in:
+3
-3
@@ -23,14 +23,14 @@ def load_testcases(testcase_file_path):
|
|||||||
|
|
||||||
def parse_response_object(resp_obj):
|
def parse_response_object(resp_obj):
|
||||||
try:
|
try:
|
||||||
resp_content = resp_obj.json()
|
resp_body = resp_obj.json()
|
||||||
except ValueError:
|
except ValueError:
|
||||||
resp_content = resp_obj.text
|
resp_body = resp_obj.text
|
||||||
|
|
||||||
return {
|
return {
|
||||||
'status_code': resp_obj.status_code,
|
'status_code': resp_obj.status_code,
|
||||||
'headers': resp_obj.headers,
|
'headers': resp_obj.headers,
|
||||||
'content': resp_content
|
'body': resp_body
|
||||||
}
|
}
|
||||||
|
|
||||||
def diff_response(resp_obj, expected_resp_json):
|
def diff_response(resp_obj, expected_resp_json):
|
||||||
|
|||||||
+4
-4
@@ -38,10 +38,10 @@ class TestUtils(ApiServerUnittest):
|
|||||||
parse_result = utils.parse_response_object(resp_obj)
|
parse_result = utils.parse_response_object(resp_obj)
|
||||||
self.assertIn('status_code', parse_result)
|
self.assertIn('status_code', parse_result)
|
||||||
self.assertIn('headers', parse_result)
|
self.assertIn('headers', parse_result)
|
||||||
self.assertIn('content', parse_result)
|
self.assertIn('body', parse_result)
|
||||||
self.assertIn('Content-Type', parse_result['headers'])
|
self.assertIn('Content-Type', parse_result['headers'])
|
||||||
self.assertIn('Content-Length', parse_result['headers'])
|
self.assertIn('Content-Length', parse_result['headers'])
|
||||||
self.assertIn('success', parse_result['content'])
|
self.assertIn('success', parse_result['body'])
|
||||||
|
|
||||||
def test_parse_response_object_text(self):
|
def test_parse_response_object_text(self):
|
||||||
url = "http://127.0.0.1:5000/"
|
url = "http://127.0.0.1:5000/"
|
||||||
@@ -49,10 +49,10 @@ class TestUtils(ApiServerUnittest):
|
|||||||
parse_result = utils.parse_response_object(resp_obj)
|
parse_result = utils.parse_response_object(resp_obj)
|
||||||
self.assertIn('status_code', parse_result)
|
self.assertIn('status_code', parse_result)
|
||||||
self.assertIn('headers', parse_result)
|
self.assertIn('headers', parse_result)
|
||||||
self.assertIn('content', parse_result)
|
self.assertIn('body', parse_result)
|
||||||
self.assertIn('Content-Type', parse_result['headers'])
|
self.assertIn('Content-Type', parse_result['headers'])
|
||||||
self.assertIn('Content-Length', parse_result['headers'])
|
self.assertIn('Content-Length', parse_result['headers'])
|
||||||
self.assertTrue(str, type(parse_result['content']))
|
self.assertTrue(str, type(parse_result['body']))
|
||||||
|
|
||||||
def test_diff_response_status_code_equal(self):
|
def test_diff_response_status_code_equal(self):
|
||||||
status_code = random.randint(200, 511)
|
status_code = random.randint(200, 511)
|
||||||
|
|||||||
Reference in New Issue
Block a user