我在试图运行django测试时收到了错误消息,这是我为模型文件编写的代码
class MountPoint(models.Model):
name = models.CharField(max_length=100)
backend = models.CharField(max_length=200,default=DEFAULT_BACKEND)
path = models.CharField(max_length=300)
def __unicode__(self):
return self.name这是我参加考试的课程
class MountPoint(TestCase):
def create_mountpoint(self):
name = "test"
backend = "test"
path = user_root
return MountPoint(name, backend, path)
def test_mountpoint_creation(self):
m = self.create_mountpoint()
self.assertTrue(isinstance(m, MountPoint))
self.assertEqual(m.__unicode(), m.name)我得到的错误信息如下。上面说我有比预期更多的投入。
回溯(最近一次调用):文件"/Users/xihui/Documents/WebProgramming/django/ece264site/filesystem/tests.py",第18行,在test_mountpoint_creation m= self.create_mountpoint() File "/Users/xihui/Documents/WebProgramming/django/ece264site/filesystem/tests.py",第15行中,在create_mountpoint返回MountPoint(名称、后端、路径) TypeError:init()最多取2个参数(4个给定)
在0.009秒内进行1次测试
失败(errors=1)
发布于 2015-11-03 10:14:21
我认为您必须使用关键字args:
return MountPoint(name=name, backend=backend, path=path)https://stackoverflow.com/questions/33492596
复制相似问题