python – 没有运行Django doctests的鼻子


this question类似.但是,就我而言,我的模型的doctest都没有运行.

我正在使用Django 1.3 beta 1.

# settings.py
TEST_RUNNER = 'django_nose.NoseTestSuiteRunner'

INSTALLED_APPS = (
    ##...a bunch of django apps
    'django_nose',
    'south',
    'my_project.my_app',
)

我的模特的一个doctest:

class ItemType(models.Model):
    '''
    >>> temType.objects.all().count() == 0
    True
    '''
    name = models.CharField(max_length=32)

    def __unicode__(self):
        return self.name

应该因为initial_data fixture而失败,但为了以防万一,我尝试了以下内容:

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测试运行器,我只需键入以下内容即可处理我的doctests:

./manage.py test my_app

有什么建议?

最佳答案 在您的设置中,只需包含此设置:

NOSE_ARGS = ['--with-doctest', other_nose_args]

请参阅django-nose documentation以了解更多选项

点赞