我为django视图编写了一个小的单元测试。我的项目结构类似
项目名称/
apps/
module1/
tests.py
module2/
tests.py
这是我的目录结构,我正在使用以下命令执行测试:
$python manage.py test_coverage模块1模块2-v2
然后它很好地执行了测试,但现在我稍微改变了目录结构,我创建了一个新的目录tests/,我保留了所有的测试文件
项目名称/
apps/
module1/
tests/
test_basic.py
test_detail.py
现在我可以用上面的命令执行dir中的那些测试了,它们有其他方法可以执行这些测试吗?
最简单的解决方案是将__init__.py
文件添加到包含以下行的tests/
包中:
from .test_basic import *
from .test_detail import *
然后用运行所有测试
$ python manage.py test module1