鼻子没有运行Django doctests [英] Nose not running Django doctests

查看:72
本文介绍了鼻子没有运行Django doctests的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

类似于此问题.但是,就我而言,我的模型的doctest都没有运行.

Similar to this question. However, in my case, none of my models' doctest are running.

我正在使用 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',
)

我的模型的文档测试之一:

One of my model's 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固定装置而失败,但以防万一,我尝试使用以下方法:

Should fail because of initial_data fixture but just in case, I tried it with the following:

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

With the Django test runner, I just type the following for my doctests to be processed:

./manage.py test my_app

有什么建议吗?

推荐答案

在您的设置中,只需包括以下设置即可:

In your settings, just include this setting:

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

有关更多选项,请参见 django-nose文档

See django-nose documentation to more options

这篇关于鼻子没有运行Django doctests的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆