from django.test.simple import DjangoTestSuiteRunner
from django.conf import settings


class AppsTestSuiteRunner(DjangoTestSuiteRunner):
    """ Override the default django 'test' command, include only
        apps that are part of this project
        (unless the apps are specified explicitly)
    """

def run_tests(self, test_labels, extra_tests=None, **kwargs):
    if not test_labels:
        PROJECT_PREFIX = 'my_project.'
test_labels = [app.replace(PROJECT_PREFIX, '') for app in settings.
    INSTALLED_APPS if app.startswith(PROJECT_PREFIX)]
return super(AppsTestSuiteRunner, self).run_tests(test_labels, extra_tests,
    **kwargs)
Testing specific apps in Django