使用以下模型:
class Client(models.Model):
name = models.CharField(max_length=50, unique=True)
created_at = models.DateTimeField(auto_now_add=True, editable=False)
modified_at = models.DateTimeField(auto_now=True, editable=False)
此测试失败:
def test_no_name_error(self):
'''Ensure an Error is raised when creating a client with no name
'''
with self.assertRaises(IntegrityError):
client = Client.objects.create()
测试失败了:
FAIL: test_no_name_error (projects.tests.test_models.ClientModelTests)
Ensure an Error is raised when creating a client with no name
----------------------------------------------------------------------
client = Client.objects.create()
AssertionError: IntegrityError not raised
我正在使用mysql