这是我的目录:
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
它说:
没有名为 CMSApp/tests/test_page 的模块
当我尝试时:
python manage.py test CMSApp/tests/test_page.py
它说 NoneType 对象不可迭代
。
最佳答案
python manage.py test CMSApp.tests.test_page
您需要在 tests
目录中有 __init__.py
才能使其成为模块。
关于python - Django 1.8 - 如何测试测试文件夹中的特定文件?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33378906/