django中执行./manage.py test APP/ 时,抛出异常TypeError: init() takes 1 positional argument but 2 were given
APP/tests.py的代码如下
这是__init__()这个构造函数引发的
from django.test import TestCase
from django.test import Client
class APIUnitTest(TestCase):
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
self.client = Client()
def test_add_report_send_time(self):
url = "/mobile/tasks"
data = {
"part": "complete",
"taskId": "20200528352",
"reportSendTime": "2020-06-08"
}
resp = self.client.post(path=url, data=data)
print(str(resp.content, encoding="utf-8"))
self.assertEqual(resp.status_code, 200)
在__init__函数中参数加入*args, **kwargs 就可以解决了