rrw*_*rw4 5 python testing django doctest nose
我在使用 django-nose 运行 django doctests 时遇到问题。添加到 /tests 目录的单元测试运行良好,但 doctests 不是。
我正在尝试在我的“季节”模块上运行 doctests:
python manage.py test season
Run Code Online (Sandbox Code Playgroud)
并得到这个输出:
nosetests --verbosity 1 season --with-doctest
Creating test database for alias 'default'...
----------------------------------------------------------------------
Ran 0 tests in 0.001s
OK
Destroying test database for alias 'default'...
Run Code Online (Sandbox Code Playgroud)
我只是在尝试一个基本的 doctest 来尝试让它工作,例如:
"""
>>> 1+1 == 2
True
"""
Run Code Online (Sandbox Code Playgroud)
这是在我的models.py 中。我已经尝试了其他 doctests 实际测试代码,但仍然没有看到任何测试运行。当我使用 --verbosity 3 运行时,我看到一行可能是问题所在:
nose.selector: INFO: <models.py path> is executable; skipped
Run Code Online (Sandbox Code Playgroud)
我找不到更多关于这意味着什么的信息。
settings.py 中的相关片段:
INSTALLED_APPS = (
'south',
'django_nose',
'season',
)
# Django-nose configuration
TEST_RUNNER = 'django_nose.NoseTestSuiteRunner'
NOSE_ARGS = ['--with-doctest']
Run Code Online (Sandbox Code Playgroud)
django_nose 位于 INSTALLED_APPS 中的 South 之后,如 django-nose 文档中所述。我正在使用此处建议的 --with-doctest 参数:Nose not running Django doctests,并按照此处的建议将我的 django-nose 更新为最新版本:Why is not django-nose running the doctests in my models?
这些是我使用的版本:
django 1.3
python 2.7.1
django-nose 0.1.3nose
1.1.2
我觉得我在这里缺少一些基本设置。如果需要任何其他信息,请告诉我。任何帮助表示赞赏,谢谢!
nosetests --verbosity 1 season --with-doctest
Usage: manage.py test [options] [appname ...]
也许你只需要移动season到终点即可。