0

我为 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()
        self.assertEqual(cnt.text, 'hello world again!')

我通过在 myapp/ 下创建一个 tests/ 文件夹来使其工作。然后我将 test.py 移动到 myapp/tests/,我也将一个__init__.py放到同一个文件夹中。然后它工作。

谢谢。

4

0 回答 0