Add management command to run tests from app list built dynamically.

This commit is contained in:
Roberto Rosario
2015-10-10 03:24:57 -04:00
parent 07f02b8f0b
commit 976a86947e
17 changed files with 42 additions and 0 deletions
+1
View File
@@ -63,6 +63,7 @@ class MayanAppConfig(apps.AppConfig):
class CommonApp(MayanAppConfig):
app_url = ''
name = 'common'
test = True
verbose_name = _('Common')
def ready(self):
@@ -0,0 +1,26 @@
from __future__ import unicode_literals
from optparse import make_option
from django import apps
from django.core import management
class Command(management.BaseCommand):
help = 'Run all configured tests for the project.'
option_list = management.BaseCommand.option_list + (
make_option('--nomigrations', action='store_true', dest='nomigrations', default=False,
help='Don\'t use migrations when creating the test database.'),
)
def handle(self, *args, **options):
kwargs = {}
if options.get('nomigrations'):
kwargs['nomigrations'] = True
test_apps = [app.name for app in apps.apps.get_app_configs() if getattr(app, 'test', False)]
print 'Testing: {}'.format(', '.join(test_apps))
management.call_command('test', *test_apps, interactive=False, **kwargs)