Can I launch tests for my reusable Django app without incorporating this app into a project?
My app uses some models, so it is necessary to provide (TEST_)DATABASE_* settings. Where should I store them and how should I launch tests?
For a Django project, I can run tests with manage.py test; when I use django-admin.py test with my standalone app, I get:
Error: Settings cannot be imported,
because environment variable
DJANGO_SETTINGS_MODULE is undefined.
What are the best practises here?
I’ve ended with such solution (it was inspired by solution found in django-voting):
Create file eg. ‘runtests.py’ in tests dir containing:
It allows to run tests by
python runtests.pycommand.It doesn’t require installed dependencies (eg. buildout) and it doesn’t harm tests run when app is incorporated into bigger project.