6
You need to put from tests import *
in your __init__.py
file
Django will look in your app for a package/module called tests, and then interrogate its namespace for test cases. In this case it will look at the namespace of your tests package (from the init.py file), and discover nothing there. By doing the import in the __init__.py
file then you will import the testcases from your tests module into the namespace of the tests package, and django will be able to locate them and run them.
2
Another solution to this problem is to use more inteligent tests runner. You can try nose
and django_nose
โ it will discover tests in this case. If you donโt want to install aditional apps, @Ctrlspc solution is the only way to solve this problem.
- [Django]-Django forms custom validation on two fields one or the other
- [Django]-Setting up router with APIView and viewset in Django Rest Framework
- [Django]-Checkboxes and Radio buttons in Django ModelForm
0
you can add a models.py
file inside the app, add the new app to the installed apps and django will find the tests.py file without having to add anything to the __init__.py
.
I guess both @Ctrlspc approach and this one are sort of dirty. so any choice is ok