It's a shame that Django decided to ignore custom apps in the INSTALLED_APPS that are not in the project tree. See this post https://groups.google.com/forum/#!topic/django-users/gGfVhfrfE10 for their reasoning.
My real-world case does of course does not fall in the three mentioned use cases (big suprise!): We have a site that we deploy with a different collection of tightly coupled custom apps for client / group of clients. We don't want these apps nested under the project tree, because each is in its own git repo. In the past, we've used git submodules, fake submodules and subtrees; all had their issues in our setup. On the other hand, having each app as its own package on the same level as the site satisfies most of our requirements.
Of course each app has its own tests, but I would like to be able to run the full test suite (including the site and all custom apps) for each specific differently constituted site.
Our workaround is the following:
In settings/test.py
I have:
ATA_BLACKLIST = ['scary_mod1', 'scary_mod2']
ADD_TEST_APPS = [i for i in INSTALLED_APPS
if '.' not in i and i not in ATA_BLACKLIST]
ATA_STR = " ".join(ADD_TEST_APPS)
I have a run_tests.sh
script at top-level which looks more or less like this:
#!/bin/bash
MYDIR=`dirname $0`
cd $MYDIR
DJANGO_SETTINGS_MODULE=kmxng.settings.test
ATA_STR=`python -c "from django.conf import settings; print settings.ATA_STR"`
coverage run --omit "*lib/python*" ./manage.py test . $ATA_STR
coverage report
In short, in my test settings I generate a list of extra modules that should be added to testing. I invoke the django test
command with that list in addition to the default .
.
(I did have a look at overriding DiscoverRunner
-- it has a relatively long build_suite
method that could be overridden. The work-around above is a less-invasive option.)