简体   繁体   English

如何在不提供 app_name 的情况下测试 django 应用程序

[英]How to test django app without giving an app_name

My project structure looks like this: backend/src/apps/app_name/tests/foo.py and when I'm trying to run the tests by entering a command python manage.py test it runs 0 tests.我的项目结构如下所示: backend/src/apps/app_name/tests/foo.py当我尝试通过输入命令python manage.py test运行测试时,它运行 0 个测试。 The only correct way to test is python manage.py test src.apps.app_name but I'm to lazy to do it with every app.唯一正确的测试方法是python manage.py test src.apps.app_name但我懒得对每个应用程序都这样做。

Change改变

backend/src/apps/app_name/tests/foo.py

to

backend/src/apps/app_name/tests/test_foo.py

Make sure all your test files and functions start with test确保所有测试文件和函数都以test开头

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM