求助 使用pytest.mark.parametrize 接口报错

求助大佬帮忙分析分析

代码

    @pytest.mark.parametrize("name,sort",[
        ["励志短片11","10"]
    ])
    def test_classification_list(self,name,sort):

        addlistR=self.baseSelect.classificationadd(name=name,sort=sort)
        listR = self.baseSelect.classificationlist()

        assert addlistR == 200
    def classificationadd(self,name,sort):
        data = {
            "method": "post",
            "url": "http://daily-recommend-staging.yunzuoye.net/api/v1/classification",

            "json": {
                "name": name,
                "sort": sort
                     }
        }

        r = self.send(data)
        return r

报错日志

在elf = <Response [200]>, kwargs = {}

    def json(self, **kwargs):
        r"""Returns the json-encoded content of a response, if any.
    
        :param \*\*kwargs: Optional arguments that ``json.loads`` takes.
        :raises requests.exceptions.JSONDecodeError: If the response body does not
            contain valid json.
        """
    
        if not self.encoding and self.content and len(self.content) > 3:
            # No encoding set. JSON RFC 4627 section 3 states we should expect
            # UTF-8, -16 or -32. Detect which one to use; If the detection or
            # decoding fails, fall back to `self.text` (using charset_normalizer to make
            # a best guess).
            encoding = guess_json_utf(self.content)
            if encoding is not None:
                try:
                    return complexjson.loads(
                        self.content.decode(encoding), **kwargs
                    )
                except UnicodeDecodeError:
                    # Wrong UTF codec detected; usually because it's not UTF-8
                    # but some other 8-bit codec.  This is an RFC violation,
                    # and the server didn't bother to tell us what codec *was*
                    # used.
                    pass
    
        try:
            return complexjson.loads(self.text, **kwargs)
        except JSONDecodeError as e:
            # Catch JSON-related errors and raise as requests.JSONDecodeError
            # This aliases json.JSONDecodeError and simplejson.JSONDecodeError
            if is_py2: # e is a ValueError
                raise RequestsJSONDecodeError(e.message)
            else:
>               raise RequestsJSONDecodeError(e.msg, e.doc, e.pos)
E               requests.exceptions.JSONDecodeError: [Errno Expecting value] : 0

这个send方法是怎么写的?看报错是发送的数据结构不太对

老师帮忙看 这个send方法

class BaseApi:
def init(self):
self.token = self.get_token()

def send(self, kwargs):
    r = requests.request(**kwargs)
    print(json.dumps(r.json(), indent=2))
    return r

在send方法里打印一下kwargs的值 看看传入的数据是什么
看起来是其中的json的值里面有不能序列化的数据,但是从前面代码看应该传入的是两个字符串

关闭