【发布时间】:2011-06-07 16:04:05
【问题描述】:
在运行一些测试时,我的 setUp 函数开始出现 IntegrityError。这是我的代码:
def setUp(self):
self.client = Client()
self.emplUser = User.objects.create_user('employee@email.com', 'employee@email.com', 'nothing')
self.servUser1 = User.objects.create_user('thebestcompany@email.com', 'thebestcompany@email.com', 'nothing')
self.servUser2 = User.objects.create_user('theothercompany@email.com', 'theothercompany@email.com', 'nothing')
self.custUser1 = User.objects.create_user('john@email.com', 'john@email.com', 'nothing')
self.custUser2 = User.objects.create_user('marcus@email.com', 'marcus@email.com', 'nothing')
... save users here ...
我想知道这个 IntegrityError 是如何不断提高的。我删除了 tearDown 函数中的所有用户,并使用 sqlite3 作为我的数据库后端。我没有看到有冲突的用户名,并且在生产中,使用电子邮件作为用户名没有任何问题。
这只是半小时前才开始发生的,出乎意料。有没有人遇到过这个问题的解决方案?
【问题讨论】: