重载方法写delete请求

Posted lanyy

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了重载方法写delete请求相关的知识,希望对你有一定的参考价值。

#encoding=utf-8
#__author__="Lanyangyang"

import unittest
import requests
import json

# This is a public delete method.
def test_public_delete(self, url, path, params):

# delete request method
response = requests.delete(url=url + path, params=params)

# Is the return status code 200?
self.assertEqual(response.status_code, 200, msg="状态码不是200")
# 判断返回文本
response_text = requests.delete(url=url + path, params=params).text
# 将响应内容转换成字典格式
response_dict = json.loads(response_text)
# 获取response message字段的值
response_message = response_dict[‘message‘]
# 判断message的值
self.assertEqual(response_message, ‘SUCCESS‘, msg=‘返回值不是SUCCESS‘)
print(response.text)

# 以json格式输出返回文本
response2 = requests.delete(url=url + path, params=params).json()
r = json.dumps(response2, indent=2, sort_keys=True)
print("返回信息如下:")
print(r)

print("test_public_delete调用成功")




#或者换种写法,先转换成文本,在取code和message,这样只需要请求一次
response_text = requests.delete(url=url + path, params=params).text

#将响应内容转换成字典格式
response_dict2=json.loads(response_text)

#获取字典中的code和message值
response_code2=response_dict2[‘code‘]
response_message2=response_dict2[‘message‘]

#断言判断
self.assertEqual(response_code2,200,msg="code不是200")
self.assertEqual(response_message2,‘SUCCESS‘,msg="msg不是SUCCESS")






















































以上是关于重载方法写delete请求的主要内容,如果未能解决你的问题,请参考以下文章

c++ primer19.1.1重载new和delete

[原] inline operator delete & DLL boundary

重载delete时的那点事

C++学习32 重载new和delete运算符

重载类的new和delete运算符成员函数

问题是在具有-02或以上优化的框架中重载运算符new和delete [关闭]