【发布时间】:2010-09-07 14:10:19
【问题描述】:
我创建了 test.py 模块,里面装满了
from django.test import TestCase
from django.test.client import Client
from django.contrib.auth.models import User
from django.contrib.sites.models import Site
from forum.models import *
class SimpleTest(TestCase):
def setUp(self):
u = User.objects.create_user("ak", "ak@abc.org", "pwd")
Forum.objects.create(title="forum")
Site.objects.create(domain="test.org", name="test.org")
def content_test(self, url, values):
"""Get content of url and test that each of items in `values` list is present."""
r = self.c.get(url)
self.assertEquals(r.status_code, 200)
for v in values:
self.assertTrue(v in r.content)
def test(self):
self.c = Client()
self.c.login(username="ak", password="pwd")
self.content_test("/forum/", ['<a href="/forum/forum/1/">forum</a>'])
....
并将其与我的应用程序一起放在文件夹中。 当我运行测试时
python manage.py test forum
创建测试数据库后,我得到一个答案“在 0.000 秒内运行 0 个测试”
我做错了什么?
附: 这是我的项目层次结构:
MyProj:
forum (it's my app):
manage.py
models.py
views.py
tests.py
...
我将 test.py 重命名为 tests.py。 Eclipse 知道这个模块有测试,但答案仍然是“在 0.000 秒内运行 0 次测试”
【问题讨论】:
标签: python django testing client