Files
mayan-edms/mayan/apps/common/tests/runner.py
Roberto Rosario 8179c35189 Simplify test runner by adding a new option '--mayan-apps' that
automatically tests all Mayan apps that report to have tests.
Change the app flag that indicates when an app has test
from 'test' to the more explicit 'has_test'.

Signed-off-by: Roberto Rosario <roberto.rosario.gonzalez@gmail.com>
2017-03-14 23:47:40 -04:00

31 lines
957 B
Python

from __future__ import unicode_literals
from django import apps
from django.test.runner import DiscoverRunner
class MayanTestRunner(DiscoverRunner):
@classmethod
def add_arguments(cls, parser):
parser.add_argument(
'--mayan-apps', action='store_true', default=False,
dest='mayan_apps',
help='Test all Mayan apps that report to have tests.'
)
def __init__(self, *args, **kwargs):
self.mayan_apps = kwargs.pop('mayan_apps')
super(MayanTestRunner, self).__init__(*args, **kwargs)
def build_suite(self, *args, **kwargs):
# Apps that report they have tests
if self.mayan_apps:
args = list(args)
args[0] = [
app.name for app in apps.apps.get_app_configs() if getattr(
app, 'has_tests', False
)
]
return super(MayanTestRunner, self).build_suite(*args, **kwargs)