0 notes &
Django Tips: running tests if you have move models to a package
Some people don’t like the default behavior of django for models, which is to place all classes in one file.
A solution is to create a package. It may seem to be not really Pythonic as your directory structure looks now like in Java or PHP but it may help if you have lots of models. Probably, you should better have split your code into apps instead.
But the real problem is that you can’t run unit tests as django is looking for tests.py in the same folder as the models.py.
The answer is easy but I didn’t found any example so I post it here:
# in models/__init__.py
from gb.tests import *
Then the django test suite runner will be able to find your tests !