Django写作测试
我为Django编写了一个小测试。它总是返回不正确的true。代码附在下面。我不明白为什么?谢谢你的帮助Django写作测试,django,testing,Django,Testing,我为Django编写了一个小测试。它总是返回不正确的true。代码附在下面。我不明白为什么?谢谢你的帮助 from django.tests import TestCase from myapp.models import Content class SimpleTest(TestCase): def test_add_user(self): cnt = Content('en', 'hello world!') cnt.save()
from django.tests import TestCase
from myapp.models import Content
class SimpleTest(TestCase):
def test_add_user(self):
cnt = Content('en', 'hello world!')
cnt.save()
self.assertEqual(cnt.text, 'hello world again!')
我通过在myapp/下创建一个tests/文件夹来实现它。然后我将test.py移动到myapp/tests/,我还将\uuuu init\uuuu.py
放在同一个文件夹中。然后它就起作用了
谢谢。您如何定义您的
内容模型?您的代码不正确<代码>django.tests
不是django的模块之一。