x-www-form-urlencoded:

path = "/api/v1/topics/update"
params={'accesstoken':'d38a77f0-6f29-45cd-8d49-f72f15b98fd2','topic_id':'5c89021773798770589936b0','title':'hahaha','tab':'share','content':'hahaha'}
response_text = requests.post(url=self.url+path, data=params).text

# 将响应内容转换成字典格式
response_dict = json.loads(response_text)
# 获取response message字段的值
response_message = response_dict['topic_id']
# 判断message的值
self.assertEqual(response_message, '5c89021773798770589936b0', msg='topic返回值不对')

 

form-data:

# post request method
response = requests.post(url=url + path, params=params,headers=headers)
# Is the return status code 200?
self.assertEqual(response.status_code, 200, msg="The status code is not 200")
# Is the return message SUCCESS?
response_text = requests.post(url=url + path, params=params,headers=headers).text
# Convert response content into dictionary format.
response_dict = json.loads(response_text)
# Gets the value of the response message.
response_message = response_dict['message']
# Determine the value of message.
self.assertEqual(response_message, 'SUCCESS', msg='The response message is not SUCCESS')
#Print response text.
print(response.text)

 

相关文章:

  • 2021-11-14
  • 2022-12-23
猜你喜欢
  • 2022-01-22
  • 2021-07-12
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-09-22
相关资源
相似解决方案