【问题标题】:Does django need to set TEST_RUNNER first to run doctest?django 是否需要先设置 TEST_RUNNER 才能运行 doctest?
【发布时间】:2015-05-12 09:30:38
【问题描述】:

我开始了一个致命的简单 django 项目来尝试 django 的 doctest:

# models.py
"""
>>> 1+1 == 2
True
"""

然后运行 ​​python manage.py test 获取:

Creating test database for alias 'default'...

----------------------------------------------------------------------
Ran 0 tests in 0.000s

OK
Destroying test database for alias 'default'...

与运行 python manage.py play 相同。

我通过设置解决了这个问题:

INSTALLED_APPS = (
...
'django_nose',
)
TEST_RUNNER = 'django_nose.NoseTestSuiteRunner'
NOSE_ARGS = ['--with-doctest']

我的问题是我的设置是否需要?因为文档中没有提到它:https://docs.djangoproject.com/en/1.4/topics/testing/

我的django版本是1.7,是1.4和1.7的区别吗?

【问题讨论】:

    标签: python django testing doctest test-runner


    【解决方案1】:

    从 1.6 开始,Django 不再自动发现文档测试。您将在1.6 release documentation 中找到更多关于如何集成文档测试的信息。

    【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2019-01-05
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-09-04
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多