unittest(22)- p2p项目实战(2)-http_request

2021-04-24 23:26

阅读:309

标签:nbsp   erro   exception   bsp   res   format   err   unittest   cookie   

 

# 2. http_request.py

import requests
from learn_logging_5.write_log_class import MyLog


my_logger = MyLog()


class HttpRequest:
    def http_request(self, url, method, data=None, cookie=None):
        try:
            if method.upper() == "GET":
                res = requests.get(url, data, cookies=cookie)
            elif method.upper() == "POST":
                res = requests.post(url, data, cookies=cookie)
            else:
                my_logger.info("请输入正确的参数")
        except Exception as e:
            my_logger.error("请求报错了:{}".format(e))
            raise e
        return res

 

unittest(22)- p2p项目实战(2)-http_request

标签:nbsp   erro   exception   bsp   res   format   err   unittest   cookie   

原文地址:https://www.cnblogs.com/come202011/p/12232168.html


评论


亲,登录后才可以留言!