如同这个问题 https://stackoverflow.com/questions/2614363/why-isnt-django-nose-running-the-doctests-in-my-models。然而,就我而言,我的模型都没有doctest
正在跑步。
我在用着Django 1.3 测试版 1 http://www.djangoproject.com/weblog/2010/dec/22/13-beta-1/.
# settings.py
TEST_RUNNER = 'django_nose.NoseTestSuiteRunner'
INSTALLED_APPS = (
##...a bunch of django apps
'django_nose',
'south',
'my_project.my_app',
)
我的模型的文档测试之一:
class ItemType(models.Model):
'''
>>> temType.objects.all().count() == 0
True
'''
name = models.CharField(max_length=32)
def __unicode__(self):
return self.name
应该会失败,因为initial_data
但为了以防万一,我尝试了以下方法:
class ItemType(models.Model):
'''
>>> ItemType.objects.all().count() == -1
True
'''
name = models.CharField(max_length=32)
def __unicode__(self):
return self.name
我尝试运行以下命令:
./manage.py test --with-doctest my_app
使用 Django 测试运行程序,我只需输入以下内容即可处理我的文档测试:
./manage.py test my_app
有什么建议么?