python使用delete方法时报错

delete方法:后端没有返回值,我觉得和这个有关系

 def test_delete(self):
        print(self.organization.delete(158))
 def send(self, data):
        # allure.attach(str(data), attachment_type=allure.attachment_type.TEXT)
        data["url"] = str(data["url"]).replace("192.168.2.153:31001", self.env["testing-studio"][self.env["default"]])
        res = requests.request(**data)
        print(res.text)
        return res.json()
  def delete(self, cid):
        data = {
            "method": "delete",
            "url": f"http://192.168.2.153:31001/ims/api/v1/bmims-hrm/departments/{cid}/",
            "headers": {
                "Authorization": "Token *******"
            }
        }
        return self.send(data)

4.报错信息:

test_organization.py::TestOrganization::test_delete 
FAILED
testcase/test_organization.py:26 (TestOrganization.test_delete)
self = <testcase.test_organization.TestOrganization object at 0x7fa182d58e48>

    def test_delete(self):
>       print(self.organization.delete(158))

test_organization.py:28: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
../api/organization.py:57: in delete
    return self.send(data)
../api/base_api.py:14: in send
    return res.json()
../env/lib/python3.7/site-packages/requests/models.py:898: in json
    return complexjson.loads(self.text, **kwargs)
../env/lib/python3.7/site-packages/simplejson/__init__.py:525: in loads
    return _default_decoder.decode(s)
../env/lib/python3.7/site-packages/simplejson/decoder.py:370: in decode
    obj, end = self.raw_decode(s)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

self = <simplejson.decoder.JSONDecoder object at 0x7fa182f64240>, s = ''
idx = 0, _w = <built-in method match of re.Pattern object at 0x7fa18297dcf0>
_PY3 = True

    def raw_decode(self, s, idx=0, _w=WHITESPACE.match, _PY3=PY3):
        """Decode a JSON document from ``s`` (a ``str`` or ``unicode``
        beginning with a JSON document) and return a 2-tuple of the Python
        representation and the index in ``s`` where the document ended.
        Optionally, ``idx`` can be used to specify an offset in ``s`` where
        the JSON document begins.
    
        This can be used to decode a JSON document from a string that may
        have extraneous data at the end.
    
        """
        if idx < 0:
            # Ensure that raw_decode bails on negative indexes, the regex
            # would otherwise mask this behavior. #98
            raise JSONDecodeError('Expecting value', s, idx)
        if _PY3 and not isinstance(s, str):
            raise TypeError("Input string must be text, not bytes")
        # strip UTF-8 bom
        if len(s) > idx:
            ord0 = ord(s[idx])
            if ord0 == 0xfeff:
                idx += 1
            elif ord0 == 0xef and s[idx:idx + 3] == '\xef\xbb\xbf':
                idx += 3
>       return self.scan_once(s, idx=_w(s, idx).end())
E       simplejson.errors.JSONDecodeError: Expecting value: line 1 column 1 (char 0)

../env/lib/python3.7/site-packages/simplejson/decoder.py:400: JSONDecodeError

Assertion failed

Assertion failed


=================================== FAILURES ===================================
_________________________ TestOrganization.test_delete _________________________

self = <testcase.test_organization.TestOrganization object at 0x7fa182d58e48>

    def test_delete(self):
>       print(self.organization.delete(158))

test_organization.py:28: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
../api/organization.py:57: in delete
    return self.send(data)
../api/base_api.py:14: in send
    return res.json()
../env/lib/python3.7/site-packages/requests/models.py:898: in json
    return complexjson.loads(self.text, **kwargs)
../env/lib/python3.7/site-packages/simplejson/__init__.py:525: in loads
    return _default_decoder.decode(s)
../env/lib/python3.7/site-packages/simplejson/decoder.py:370: in decode
    obj, end = self.raw_decode(s)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

self = <simplejson.decoder.JSONDecoder object at 0x7fa182f64240>, s = ''
idx = 0, _w = <built-in method match of re.Pattern object at 0x7fa18297dcf0>
_PY3 = True

    def raw_decode(self, s, idx=0, _w=WHITESPACE.match, _PY3=PY3):
        """Decode a JSON document from ``s`` (a ``str`` or ``unicode``
        beginning with a JSON document) and return a 2-tuple of the Python
        representation and the index in ``s`` where the document ended.
        Optionally, ``idx`` can be used to specify an offset in ``s`` where
        the JSON document begins.
    
        This can be used to decode a JSON document from a string that may
        have extraneous data at the end.
    
        """
        if idx < 0:
            # Ensure that raw_decode bails on negative indexes, the regex
            # would otherwise mask this behavior. #98
            raise JSONDecodeError('Expecting value', s, idx)
        if _PY3 and not isinstance(s, str):
            raise TypeError("Input string must be text, not bytes")
        # strip UTF-8 bom
        if len(s) > idx:
            ord0 = ord(s[idx])
            if ord0 == 0xfeff:
                idx += 1
            elif ord0 == 0xef and s[idx:idx + 3] == '\xef\xbb\xbf':
                idx += 3
>       return self.scan_once(s, idx=_w(s, idx).end())
E       simplejson.errors.JSONDecodeError: Expecting value: line 1 column 1 (char 0)

../env/lib/python3.7/site-packages/simplejson/decoder.py:400: JSONDecodeError
=========================== short test summary info ============================
FAILED test_organization.py::TestOrganization::test_delete - simplejson.error...
============================== 1 failed in 0.48s ===============================

Process finished with exit code 0

Assertion failed

Assertion failed

请转移到答疑区提问,还有要格式化一下你的代码哦,这样看着太费劲了
使用markdown语法的代码块格式

```python
你写的python代码
```

首先,也不知道organization是个什么类型。不同的delete封装会有不同的效果。
个人理解,delete的作用应该大致都类似del,功能是让一个对象的引用计数-1,它没有任何返回值,其实这里和有没有返回值没什么关系。它既不新增对象结果也不操作对象,所以打印自然是不行的。这应该是底层的设计就是这样