【发布时间】:2016-01-27 12:13:48
【问题描述】:
这是我的目录:
CMSApp/tests/test_page.py
CMSApp/tests/test_user.py
CMSApp/models.py
CMSApp/views.py
我只想测试test_page.py。我可以这样做:
python manage.py test CMSApp/tests
但这将同时测试test_page.py 和test_user.py。当我尝试时
python manage.py test CMSApp/tests/test_page
上面写着:
No module named CMSApp/tests/test_page
当我尝试时:
python manage.py test CMSApp/tests/test_page.py 上面写着NoneType object is not iterable。
【问题讨论】:
-
当您尝试不使用 test_page 的扩展名 .py 时会得到什么?
-
@drabo2005 上面写着
No module named CMSApp/tests/test_page。 -
我认为问题可能是文件夹“测试”的名称,因为您可以通过执行以下操作进行测试:python manage.py test CMSAPP.
.test_page.tests 最后一个“测试”是可能与您的文件夹名称混淆的内置函数:tests -
@drabo2005
tests是测试模块的推荐名称。见docs.djangoproject.com/en/1.8/topics/testing/overview/…
标签: python django django-unittest