避坑:TypeError: XXXXXX() missing 1 required positional argument: ‘XXXX‘

题目这种错误一般就是初始化参数少传了
再者就是没有实例化直接调用了方法

如下就是我找了半天问题的代码,最后就栽在了调用http_request方法前没有实例化直接调用了方法,哭死!

记录下来,引以为戒!!!

def test_ddt_api(self, item):
        res = HttpRequest.http_request(item['method'],item['url'],eval(item['data']))
        try:
            self.assertIn(res.json()['message'], item['excepted'])
        except AssertionError as e:
            print("登录异常,异常信息:{}".format(e))
            raise e
        print(res.json())

猜你喜欢

转载自blog.csdn.net/weixin_46761622/article/details/125609140
今日推荐