2024-04-25 17:11:29 发布
网友
使用传统的单元测试,我可以使用以下命令为已安装的Django应用程序运行测试:python manage.py test <name_of_the_installed_app>
python manage.py test <name_of_the_installed_app>
但当使用pytest作为测试运行程序时,情况并非如此
如何使用pytest运行Django设置中包含的第三方应用程序的测试
阿菲安,我给你的建议有两个步骤:
cd /my/app/dir/
pytest -c /my/django-project/dir/pytest.ini rootdir /my/django-project/dir/
在pytest.ini文件上,您必须设置DJANGO_SETTINGS_MODULE,也可以按如下操作,而不是设置pytest.ini文件:
pytest.ini
DJANGO_SETTINGS_MODULE
DJANGO_SETTINGS_MODULE="myproject.settings" pytest rootdir /my/django-project
阿菲安,我给你的建议有两个步骤:
cd /my/app/dir/
pytest -c /my/django-project/dir/pytest.ini rootdir /my/django-project/dir/
在
pytest.ini
文件上,您必须设置DJANGO_SETTINGS_MODULE
,也可以按如下操作,而不是设置pytest.ini
文件:相关问题 更多 >
编程相关推荐