I'm trying to test a Django reusable app that was organized as Python packages. Here is the directory tree:
reusableapp
├── __init__.py
└── submodule
├── __init__.py
└── app
├── __init__.py
├── models.py
├── tests.py
└── views.py
My version of Django is 1.5. To pick the application for testing I have the following code based on the one exposed here:
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
Description: Execute tests from outside Django's project
"""
import os
import sys
from django.conf import settings
DIRNAME = os.path.dirname(__file__)
INSTALLED_APPS = [
"reusableapp.submodule.app"
]
settings.configure(
DEBUG=True,
DATABASES={
"default": {
"ENGINE": "django.db.backends.sqlite3",
}
},
INSTALLED_APPS=tuple(INSTALLED_APPS),
CACHES={
"default": {
"BACKEND": "django.core.cache.backends.locmem.LocMemCache",
}
},
)
if __name__ == "__main__":
from django.test.simple import DjangoTestSuiteRunner
test_runner = DjangoTestSuiteRunner(verbosity=1)
failures = test_runner.run_tests(INSTALLED_APPS)
if failures:
sys.exit(failures)
But when I execute it I got the following error (using virtualenv):
(reusableapp) $ python runtests.py
Traceback (most recent call last):
File "runtests.py", line 48, in <module>
failures = test_runner.run_tests(INSTALLED_APPS)
File "/var/lib/virtualenvs/reusableapp/local/lib/python2.7/site-packages/django/test/simple.py", line 369, in run_tests
suite = self.build_suite(test_labels, extra_tests)
File "/var/lib/virtualenvs/reusableapp/local/lib/python2.7/site-packages/django/test/simple.py", line 254, in build_suite
suite.addTest(build_test(label))
File "/var/lib/virtualenvs/reusableapp/local/lib/python2.7/site-packages/django/test/simple.py", line 102, in build_test
app_module = get_app(parts[0])
File "/var/lib/virtualenvs/reusableapp/local/lib/python2.7/site-packages/django/db/models/loading.py", line 160, in get_app
raise ImproperlyConfigured("App with label %s could not be found" % app_label)
django.core.exceptions.ImproperlyConfigured: App with label reusableapp could not be found
I've searched in the Django documentation about reusable apps and formats but it says nothing beyond "just a Python package that is specifically intended for use in a Django project. An app may also use common Django conventions, such as having a models.py file"
Do you know some explicit convention/requeriment that explicits the reusable app format? If not, have you faced this situation? Is there a way to load the app by force?
Thank you and best regards.