django.test.utils.get_runner

Here are the examples of the python api django.test.utils.get_runner taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.

139 Examples 7

Example 101

Project: theyworkforyou Source File: test.py
Function: handle
    def handle(self, *test_labels, **options):
        from django.conf import settings
        from django.test.utils import get_runner

        verbosity = int(options.get('verbosity', 1))
        interactive = options.get('interactive', True)
        test_runner = get_runner(settings)

        failures = test_runner(test_labels, verbosity=verbosity, interactive=interactive)
        if failures:
            sys.exit(failures)

Example 102

Project: django-mail-templated Source File: run.py
Function: run_tests
def run_tests():
    # Old Django versions requires Django initialisation before we can get the
    # test runner.
    setup_django()

    from django.conf import settings
    from django.test.utils import get_runner

    TestRunner = get_runner(settings)
    test_runner = TestRunner(verbosity=1, interactive=True)
    failures = test_runner.run_tests(['mail_templated'])
    sys.exit(bool(failures))

Example 103

Project: django-easy-pdf Source File: runtests.py
def run_tests(verbosity, interactive, failfast, test_labels):
    if not test_labels:
        test_labels = ["tests"]

    if not hasattr(settings, "TEST_RUNNER"):
        settings.TEST_RUNNER = "django.test.runner.DiscoverRunner"
    TestRunner = get_runner(settings)

    test_runner = TestRunner(
        verbosity=verbosity,
        interactive=interactive,
        failfast=failfast
    )

    failures = test_runner.run_tests(test_labels)
    if failures:
        sys.exit(bool(failures))

Example 104

Project: nested-formset Source File: __init__.py
def run_tests():

    setup()

    from django.conf import settings
    from django.test.utils import get_runner

    TestRunner = get_runner(settings)
    test_runner = TestRunner()

    failures = test_runner.run_tests(
        ['nested_formset'],
    )

    sys.exit(failures)

Example 105

Project: gro-api Source File: runtests.py
def runtests():
    settings_module = 'gro_api.gro_api.test_settings'
    os.environ['DJANGO_SETTINGS_MODULE'] = settings_module
    load_env()
    # Our settings file monkey patches django.setup, so we have to force django
    # to load it before calling django.setup
    settings.INSTALLED_APPS
    from django import setup
    setup()
    test_runner = get_runner(settings)
    failures = test_runner(verbosity=1, interactive=True).run_tests(())
    sys.exit(failures)

Example 106

Project: django-performance-testing Source File: test_runner.py
def integrate_into_django_test_runner():
    utils.get_runner = get_runner_with_djpt_mixin
    test_method_qc_id = 'test method'
    DjptTestRunnerMixin.test_method_querycount_collector = QueryCollector(
        id_=test_method_qc_id)
    DjptTestRunnerMixin.test_method_querycount_limit = QueryBatchLimit(
        collector_id=test_method_qc_id, settings_based=True)

    DjptTestRunnerMixin.test_method_time_collector = TimeCollector(
        id_=test_method_qc_id)
    DjptTestRunnerMixin.test_method_time_limit = TimeLimit(
        collector_id=test_method_qc_id, settings_based=True)

Example 107

Project: django-performance-testing Source File: test_helpers.py
    def __init__(self, testcase_cls, nr_of_tests, all_should_pass=True,
                 print_bad=True, runner_options=None):
        runner_options = runner_options or {}
        self.nr_of_tests = nr_of_tests
        self.all_should_pass = all_should_pass
        self.print_bad = print_bad

        django_runner_cls = get_runner(settings)
        django_runner = django_runner_cls(**runner_options)
        self.suite = django_runner.test_suite()
        tests = django_runner.test_loader.loadTestsFromTestCase(testcase_cls)
        self.suite.addTests(tests)
        self.test_runner = django_runner.test_runner(
            resultclass=django_runner.get_resultclass(),
            stream=six.StringIO()
        )

Example 108

Project: django-s3-cache Source File: setup.py
def execute_tests():
    """
    Standalone django model test with a 'memory-only-django-installation'.
    You can play with a django model without a complete django app installation.
    http://www.djangosnippets.org/snippets/1044/
    """
    import django

    sys.exc_clear()

    os.environ["DJANGO_SETTINGS_MODULE"] = "django.conf.global_settings"
    from django.conf import global_settings

    global_settings.INSTALLED_APPS = ()
    global_settings.MIDDLEWARE_CLASSES = ()
    global_settings.SECRET_KEY = "not-very-secret"

    global_settings.DATABASES = {
            'default': {
                'ENGINE': 'django.db.backends.sqlite3',
            }
        }

    # http://django.readthedocs.org/en/latest/releases/1.7.html#standalone-scripts
    if django.VERSION >= (1,7):
        django.setup()

    from django.test.utils import get_runner
    test_runner = get_runner(global_settings)

    test_runner = test_runner()
    failures = test_runner.run_tests(['s3cache'])
    sys.exit(failures)

Example 109

Project: performant-pagination Source File: runcoverage.py
Function: main
def main():
    "Run the tests for performant_pagination and generate a coverage report."

    cov = coverage(branch=True)
    cov.erase()
    cov.start()

    from django.conf import settings
    from django.test.utils import get_runner
    TestRunner = get_runner(settings)

    if hasattr(TestRunner, 'func_name'):
        # Pre 1.2 test runners were just functions,
        # and did not support the 'failfast' option.
        import warnings
        warnings.warn(
            'Function-based test runners are deprecated. Test runners '
            'should be classes with a run_tests() method.',
            DeprecationWarning
        )
        failures = TestRunner(['tests'])
    else:
        test_runner = TestRunner()
        failures = test_runner.run_tests(['tests'])
    cov.stop()

    # Discover the list of all modules that we should test coverage for
    import performant_pagination

    project_dir = os.path.dirname(performant_pagination.__file__)
    cov_files = []

    for (path, dirs, files) in os.walk(project_dir):
        # Drop tests and runtests directories from the test coverage report
        if os.path.basename(path) in ['tests', 'runtests', 'migrations']:
            continue

        # Drop the compat and six modules from coverage, since we're not
        # interested in the coverage of modules which are specifically for
        # resolving environment dependant imports.  (Because we'll end up
        # getting different coverage reports for it for each environment)
        if 'compat.py' in files:
            files.remove('compat.py')

        if 'six.py' in files:
            files.remove('six.py')

        # Same applies to template tags module.
        # This module has to include branching on Django versions,
        # so it's never possible for it to have full coverage.
        if 'performant_pagination.py' in files:
            files.remove('performant_pagination.py')

        cov_files.extend([os.path.join(path, file)
                          for file in files if file.endswith('.py')])

    cov.report(cov_files)
    if '--html' in sys.argv:
        cov.html_report(cov_files, directory='coverage')
    if '--xml' in sys.argv:
        cov.xml_report(cov_files, outfile='coverage.xml')
    sys.exit(failures)

Example 110

Project: Django--an-app-at-a-time Source File: test.py
Function: add_arguments
    def add_arguments(self, parser):
        parser.add_argument('args', metavar='test_label', nargs='*',
            help='Module paths to test; can be modulename, modulename.TestCase or modulename.TestCase.test_method')
        parser.add_argument('--noinput',
            action='store_false', dest='interactive', default=True,
            help='Tells Django to NOT prompt the user for input of any kind.'),
        parser.add_argument('--failfast',
            action='store_true', dest='failfast', default=False,
            help='Tells Django to stop running the test suite after first '
                 'failed test.'),
        parser.add_argument('--testrunner',
            action='store', dest='testrunner',
            help='Tells Django to use specified test runner class instead of '
                 'the one specified by the TEST_RUNNER setting.'),
        parser.add_argument('--liveserver',
            action='store', dest='liveserver', default=None,
            help='Overrides the default address where the live server (used '
                 'with LiveServerTestCase) is expected to run from. The '
                 'default value is localhost:8081.'),

        test_runner_class = get_runner(settings, self.test_runner)
        if hasattr(test_runner_class, 'option_list'):
            # Keeping compatibility with both optparse and argparse at this level
            # would be too heavy for a non-critical item
            raise RuntimeError(
                "The method to extend accepted command-line arguments by the "
                "test management command has changed in Django 1.8. Please "
                "create an add_arguments class method to achieve this.")

        if hasattr(test_runner_class, 'add_arguments'):
            test_runner_class.add_arguments(parser)

Example 111

Project: django-datatrans Source File: runtests.py
Function: run_tests
def runtests():
    test_runner = get_runner(settings)
    failures = test_runner().run_tests([])
    sys.exit(failures)

Example 112

Project: kala-app Source File: runtests.py
def runtests(verbosity, interactive, failfast, test_labels):
    from django.conf import settings
    settings.configure(
        INSTALLED_APPS=INSTALLED_APPS,
        DATABASES=DATABASES,
        AUTH_USER_MODEL='accounts.Person',
        USE_TZ=True,
        TEST_RUNNER='django_nose.NoseTestSuiteRunner',
        TEMPLATE_DEBUG=TEMPLATE_DEBUG,
        STATIC_ROOT=os.path.join(TEMP_DIR, 'static'),
        DOCUMENT_ROOT=os.path.join(TEMP_DIR, 'static'),
        PASSWORD_HASHERS=(
            'django.contrib.auth.hashers.MD5PasswordHasher',
        ),
        SECRET_KEY="kala_tests_secret_key",
        NOSE_ARGS=[
            '--with-coverage',
            '--cover-package=kala.kala,kala.accounts,kala.bc_import,kala.companies,kala.docuements,kala.projects'
        ],
        ROOT_URLCONF='kala.kala.urls',
        LOGIN_REDIRECT_URL = '/',
    )

    # Run the test suite, including the extra validation tests.
    from django.test.utils import get_runner
    TestRunner = get_runner(settings)
    print("Testing against kala installed in '{0}' against django version {1}".format(os.path.dirname(kala.__file__),
                                                                                     django.VERSION))

    test_runner = TestRunner(verbosity=verbosity, interactive=interactive, failfast=failfast)
    failures = test_runner.run_tests(test_labels)
    return failures

Example 113

Project: listy-django-cache Source File: tests.py
Function: run
def run():
    TestRunner = get_runner(settings)
    failures = TestRunner(verbosity=1, interactive=True).run_tests([])
    sys.exit(failures)

Example 114

Project: jogging Source File: tests.py
def main():
    """
    Standalone django model test with a 'memory-only-django-installation'.
    You can play with a django model without a complete django app installation.
    http://www.djangosnippets.org/snippets/1044/
    """
    os.environ["DJANGO_SETTINGS_MODULE"] = "django.conf.global_settings"
    from django.conf import global_settings

    global_settings.INSTALLED_APPS = (
        'django.contrib.auth',
        'django.contrib.contenttypes',
        APP_MODULE,
    )
    global_settings.DATABASE_ENGINE = "sqlite3"
    global_settings.DATABASE_NAME = ":memory:"
    global_settings.ROOT_URLCONF = 'jogging.tests.urls'

    global_settings.MIDDLEWARE_CLASSES = (
        'django.middleware.common.CommonMiddleware',
        'django.contrib.sessions.middleware.SessionMiddleware',
        'django.contrib.auth.middleware.AuthenticationMiddleware',
        'jogging.middleware.LoggingMiddleware',
    )

    # jogging settings must be set up here.
    from jogging.handlers import DatabaseHandler, MockHandler
    global_settings.GLOBAL_LOG_HANDLERS = []
    global_settings.GLOBAL_LOG_LEVEL = logging.INFO
    global_settings.LOGGING = {}

    from django.test.utils import get_runner
    test_runner = get_runner(global_settings)

    if django.VERSION > (1,2):
        test_runner = test_runner()
        failures = test_runner.run_tests([APP_MODULE])
    else:
        failures = test_runner([APP_MODULE], verbosity=1)
    sys.exit(failures)

Example 115

Project: django-userena Source File: runtests.py
def main():
    TestRunner = get_runner(settings)

    # Ugly parameter parsing. We probably want to improve that in future
    # or just use default django test command. This may be problematic,
    # knowing how testing in Django changes from version to version.
    if '-p' in sys.argv:
        try:
            pos = sys.argv.index('-p')
            pattern = sys.argv.pop(pos) and sys.argv.pop(pos)
        except IndexError:
            print(usage())
            sys.exit(1)
    else:
        pattern = None

    test_modules = sys.argv[1:]

    test_runner = TestRunner(verbosity=2, failfast=False, pattern=pattern)

    if len(sys.argv) > 1:
        test_modules = sys.argv[1:]
    elif len(sys.argv) == 1:
        test_modules = []
    else:
        print(usage())
        sys.exit(1)

    if  (1, 6, 0) <= django.VERSION < (1, 9, 0):
        # this is a compat hack because in django>=1.6.0 you must provide
        # module like "userena.contrib.umessages" not "umessages"
        from django.db.models import get_app
        test_modules = [
            # be more strict by adding .tests to not run umessages tests twice
            # if both userena and umessages are tested
            get_app(module_name).__name__[:-7] + ".tests"
            for module_name
            in test_modules
        ]
    elif django.VERSION >= (1, 9, 0):
        from django.apps import apps
        test_modules = [
            # be more strict by adding .tests to not run umessages tests twice
            # if both userena and umessages are tested
            apps.get_app_config(module_name).name + ".tests"
            for module_name
            in test_modules
        ]

    if django.VERSION < (1, 7, 0):
        # starting from 1.7.0 built in django migrations are run
        # for older releases this patch is required to enable testing with
        # migrations
        from south.management.commands import patch_for_test_db_setup
        patch_for_test_db_setup()

    failures = test_runner.run_tests(test_modules or ['userena'])
    sys.exit(failures)

Example 116

Project: cgstudiomap Source File: test.py
Function: add_arguments
    def add_arguments(self, parser):
        parser.add_argument('args', metavar='test_label', nargs='*',
            help='Module paths to test; can be modulename, modulename.TestCase or modulename.TestCase.test_method')
        parser.add_argument('--noinput', '--no-input',
            action='store_false', dest='interactive', default=True,
            help='Tells Django to NOT prompt the user for input of any kind.'),
        parser.add_argument('--failfast',
            action='store_true', dest='failfast', default=False,
            help='Tells Django to stop running the test suite after first '
                 'failed test.'),
        parser.add_argument('--testrunner',
            action='store', dest='testrunner',
            help='Tells Django to use specified test runner class instead of '
                 'the one specified by the TEST_RUNNER setting.'),
        parser.add_argument('--liveserver',
            action='store', dest='liveserver', default=None,
            help='Overrides the default address where the live server (used '
                 'with LiveServerTestCase) is expected to run from. The '
                 'default value is localhost:8081-8179.'),

        test_runner_class = get_runner(settings, self.test_runner)
        if hasattr(test_runner_class, 'option_list'):
            # Keeping compatibility with both optparse and argparse at this level
            # would be too heavy for a non-critical item
            raise RuntimeError(
                "The method to extend accepted command-line arguments by the "
                "test management command has changed in Django 1.8. Please "
                "create an add_arguments class method to achieve this.")

        if hasattr(test_runner_class, 'add_arguments'):
            test_runner_class.add_arguments(parser)

Example 117

Project: django-storages-py3 Source File: tests.py
def main():
    """
    Standalone django model test with a 'memory-only-django-installation'.
    You can play with a django model without a complete django app installation.
    http://www.djangosnippets.org/snippets/1044/
    """
    os.environ["DJANGO_SETTINGS_MODULE"] = "django.conf.global_settings"
    from django.conf import global_settings

    global_settings.INSTALLED_APPS = (
        'django.contrib.auth',
        'django.contrib.sessions',
        'django.contrib.contenttypes',
        'storages',
    )
    if django.VERSION > (1,2):
        global_settings.DATABASES = {
            'default': {
                'ENGINE': 'django.db.backends.sqlite3',
                'NAME': os.path.join(BASE_PATH, 'connpass.sqlite'),
                'USER': '',
                'PASSWORD': '',
                'HOST': '',
                'PORT': '',
            }
        }
    else:
        global_settings.DATABASE_ENGINE = "sqlite3"
        global_settings.DATABASE_NAME = ":memory:"

    global_settings.ROOT_URLCONF='beproud.django.authutils.tests.test_urls'
    global_settings.MIDDLEWARE_CLASSES = (
        'django.middleware.common.CommonMiddleware',
        'django.contrib.sessions.middleware.SessionMiddleware',
        'django.middleware.csrf.CsrfViewMiddleware',
        'django.contrib.auth.middleware.AuthenticationMiddleware',
        'django.contrib.messages.middleware.MessageMiddleware',
        'beproud.django.authutils.middleware.AuthMiddleware',
    )
    global_settings.DEFAULT_FILE_STORAGE = 'backends.s3boto.S3BotoStorage'
    global_settings.AWS_IS_GZIPPED = True
    global_settings.SECRET_KEY = "tralala"

    from django.test.utils import get_runner
    test_runner = get_runner(global_settings)

    if django.VERSION > (1,2):
        test_runner = test_runner()
        failures = test_runner.run_tests(['storages'])
    else:
        failures = test_runner(['storages'], verbosity=1)
    sys.exit(failures)

Example 118

Project: drf-nested-routers Source File: runcoverage.py
Function: main
def main():
    """Run the tests for rest_framework and generate a coverage report."""

    cov = coverage()
    cov.erase()
    cov.start()

    from django.conf import settings
    from django.test.utils import get_runner
    TestRunner = get_runner(settings)

    if hasattr(TestRunner, 'func_name'):
        # Pre 1.2 test runners were just functions,
        # and did not support the 'failfast' option.
        import warnings
        warnings.warn(
            'Function-based test runners are deprecated. Test runners should be classes with a run_tests() method.',
            DeprecationWarning
        )
        failures = TestRunner(['tests'])
    else:
        test_runner = TestRunner()
        failures = test_runner.run_tests(['tests'])
    cov.stop()

    # Discover the list of all modules that we should test coverage for
    import rest_framework

    project_dir = os.path.dirname(rest_framework.__file__)
    cov_files = []

    for (path, dirs, files) in os.walk(project_dir):
        # Drop tests and runtests directories from the test coverage report
        if os.path.basename(path) in ['tests', 'runtests', 'migrations']:
            continue

        # Drop the compat and six modules from coverage, since we're not interested in the coverage
        # of modules which are specifically for resolving environment dependant imports.
        # (Because we'll end up getting different coverage reports for it for each environment)
        if 'compat.py' in files:
            files.remove('compat.py')

        if 'six.py' in files:
            files.remove('six.py')

        # Same applies to template tags module.
        # This module has to include branching on Django versions,
        # so it's never possible for it to have full coverage.
        if 'rest_framework.py' in files:
            files.remove('rest_framework.py')

        cov_files.extend([os.path.join(path, file) for file in files if file.endswith('.py')])

    cov.report(cov_files)
    if '--html' in sys.argv:
        cov.html_report(cov_files, directory='coverage')
    sys.exit(failures)

Example 119

Project: django-optimizations Source File: runtests.py
def main():
    # Parse the command-line options.
    parser = OptionParser()
    parser.add_option("-v", "--verbosity",
        action = "store",
        dest = "verbosity",
        default = "1",
        type = "choice",
        choices = ["0", "1", "2", "3"],
        help = "Verbosity level; 0=minimal output, 1=normal output, 2=all output",
    )
    parser.add_option("--noinput",
        action = "store_false",
        dest = "interactive",
        default = True,
        help = "Tells Django to NOT prompt the user for input of any kind.",
    )
    parser.add_option("--failfast",
        action = "store_true",
        dest = "failfast",
        default = False,
        help = "Tells Django to stop running the test suite after first failed test.",
    )
    options, args = parser.parse_args()
    # Configure Django.
    from django.conf import settings
    settings.configure(
        DEBUG = False,
        DATABASES = {
            "default": {
                "ENGINE": "django.db.backends.sqlite3",
            }
        },
        ROOT_URLCONF = "urls",
        INSTALLED_APPS = (
            "django.contrib.staticfiles",
            "optimizations",
            "test_optimizations",
        ),
        MIDDLEWARE_CLASSES = (
            "django.middleware.common.CommonMiddleware",
            "django.contrib.sessions.middleware.SessionMiddleware",
            "django.contrib.auth.middleware.AuthenticationMiddleware",
            "django.contrib.messages.middleware.MessageMiddleware",
        ),
        STATIC_URL = "/static/",
        STATIC_ROOT = os.path.join(os.path.dirname(__file__), "static"),
        MEDIA_URL = "/media/",
        MEDIA_ROOT = os.path.join(os.path.dirname(__file__), "media"),
        USE_TZ = True,
        TEST_RUNNER = "django.test.runner.DiscoverRunner",
    )
    # Run Django setup (1.7+).
    import django
    try:
        django.setup()
    except AttributeError:
        pass  # This is Django < 1.7
    # Configure the test runner.
    from django.test.utils import get_runner
    from django.core.management import call_command
    call_command("collectstatic", interactive=False)
    TestRunner = get_runner(settings)
    test_runner = TestRunner(
        verbosity = int(options.verbosity),
        interactive = options.interactive,
        failfast = options.failfast,
    )
    # Run the tests.
    failures = test_runner.run_tests(["test_optimizations"])
    if failures:
        sys.exit(failures)

Example 120

Project: django-watson Source File: runtests.py
def main():
    # Parse the command-line options.
    parser = OptionParser()
    parser.add_option(
        "-v", "--verbosity",
        action="store",
        dest="verbosity",
        default="1",
        type="choice",
        choices=["0", "1", "2", "3"],
        help="Verbosity level; 0=minimal output, 1=normal output, 2=all output",
    )
    parser.add_option(
        "--noinput",
        action="store_false",
        dest="interactive",
        default=True,
        help="Tells Django to NOT prompt the user for input of any kind.",
    )
    parser.add_option(
        "--failfast",
        action="store_true",
        dest="failfast",
        default=False,
        help="Tells Django to stop running the test suite after first failed test.",
    )
    parser.add_option(
        "-d", "--database",
        action="store",
        dest="database",
        default="sqlite",
        type="choice",
        choices=list(AVAILABLE_DATABASES.keys()),
        help="Select database backend for tests. Available choices: {}".format(
            ', '.join(AVAILABLE_DATABASES.keys())),
    )
    options, args = parser.parse_args()
    # Configure Django.
    from django.conf import settings

    # database settings
    if options.database:
        database_setting = AVAILABLE_DATABASES[options.database]
        if options.database == "sqlite":
            database_default_name = os.path.join(os.path.dirname(__file__), "db.sqlite3")
        else:
            database_default_name = "test_project"
        database_setting.update(dict(
            NAME=os.environ.get("DB_NAME", database_default_name),
            USER=os.environ.get("DB_USER", ""),
            PASSWORD=os.environ.get("DB_PASSWORD", "")))
    else:
        database_setting = dict(
            ENGINE=os.environ.get("DB_ENGINE", 'django.db.backends.sqlite3'),
            NAME=os.environ.get("DB_NAME", os.path.join(os.path.dirname(__file__), "db.sqlite3")),
            USER=os.environ.get("DB_USER", ""),
            PASSWORD=os.environ.get("DB_PASSWORD", ""))

    settings.configure(
        DEBUG=False,
        DATABASES={
            "default": database_setting
        },
        ROOT_URLCONF='test_watson.urls',
        INSTALLED_APPS=(
            "django.contrib.auth",
            "django.contrib.contenttypes",
            "django.contrib.sessions",
            "django.contrib.sites",
            "django.contrib.messages",
            "django.contrib.staticfiles",
            "django.contrib.admin",
            "watson",
            "test_watson",
        ),
        MIDDLEWARE_CLASSES=(
            "django.middleware.common.CommonMiddleware",
            "django.contrib.sessions.middleware.SessionMiddleware",
            "django.contrib.auth.middleware.AuthenticationMiddleware",
            "django.contrib.messages.middleware.MessageMiddleware",
        ),
        USE_TZ=True,
        STATIC_URL="/static/",
        TEST_RUNNER="django.test.runner.DiscoverRunner",
        TEMPLATES=[{
            'BACKEND': 'django.template.backends.django.DjangoTemplates',
            'DIRS': ['templates'],
            'APP_DIRS': True,
        }],
    )

    # Run Django setup (1.7+).
    import django
    try:
        django.setup()
    except AttributeError:
        pass  # This is Django < 1.7
    # Configure the test runner.
    from django.test.utils import get_runner
    TestRunner = get_runner(settings)
    test_runner = TestRunner(
        verbosity=int(options.verbosity),
        interactive=options.interactive,
        failfast=options.failfast,
    )
    # Run the tests.
    failures = test_runner.run_tests(["test_watson"])
    if failures:
        sys.exit(failures)

Example 121

Project: django-sniplates Source File: runtests.py
def runtests(args=None):
    test_dir = os.path.dirname(__file__)
    sys.path.insert(0, test_dir)

    import django
    from django.test.utils import get_runner
    from django.conf import settings

    if not settings.configured:
        settings.configure(
            DATABASES={
                'default': {
                    'ENGINE': 'django.db.backends.sqlite3',
                }
            },
            INSTALLED_APPS=(
                'sniplates',
                'tests',
            ),
            MIDDLEWARE_CLASSES=[],
            TEMPLATES=[
                {
                    'BACKEND': 'django.template.backends.django.DjangoTemplates',
                    'DIRS': [],
                    'APP_DIRS': True,
                    'OPTIONS': {
                        'debug': True
                    }
                },
            ]
        )

    django.setup()

    cov = coverage.Coverage()
    cov.start()

    TestRunner = get_runner(settings)
    test_runner = TestRunner(verbosity=1, interactive=True)
    args = args or ['.']
    failures = test_runner.run_tests(args)

    cov.stop()
    cov.save()
    if os.getenv('HTML_REPORT'):
        cov.html_report()

    sys.exit(failures)

Example 122

Project: lettuce Source File: harvest.py
    def handle(self, *args, **options):
        setup_test_environment()

        verbosity = options['verbosity']
        no_color = options.get('no_color', False)
        apps_to_run = tuple(options['apps'].split(","))
        apps_to_avoid = tuple(options['avoid_apps'].split(","))
        run_server = not options['no_server']
        test_database = options['test_database']
        smtp_queue = options['smtp_queue']
        tags = options['tags']
        failfast = options['failfast']
        auto_pdb = options['auto_pdb']
        threading = options['use_threading']

        if test_database:
            migrate_south = getattr(settings, "SOUTH_TESTS_MIGRATE", True)
            try:
                from south.management.commands import patch_for_test_db_setup
                patch_for_test_db_setup()
            except:
                migrate_south = False
                pass

            from django.test.utils import get_runner
            self._testrunner = get_runner(settings)(interactive=False)
            self._testrunner.setup_test_environment()
            self._old_db_config = self._testrunner.setup_databases()

            if DJANGO_VERSION < StrictVersion('1.7'):
                call_command('syncdb', verbosity=0, interactive=False,)
                if migrate_south:
                   call_command('migrate', verbosity=0, interactive=False,)
            else:
                call_command('migrate', verbosity=0, interactive=False,)

        settings.DEBUG = options.get('debug', False)

        paths = self.get_paths(args, apps_to_run, apps_to_avoid)
        server = get_server(port=options['port'], threading=threading)

        if run_server:
            try:
                server.start()
            except LettuceServerException as e:
                raise CommandError("Couldn't start Django server: %s" % e)

        os.environ['SERVER_NAME'] = str(server.address)
        os.environ['SERVER_PORT'] = str(server.port)

        failed = False

        registry.call_hook('before', 'harvest', locals())
        results = []
        try:
            for path in paths:
                app_module = None
                if isinstance(path, tuple) and len(path) is 2:
                    path, app_module = path

                if app_module is not None:
                    registry.call_hook('before_each', 'app', app_module)

                runner = Runner(path, options.get('scenarios'),
                                verbosity, no_color,
                                enable_xunit=options.get('enable_xunit'),
                                enable_subunit=options.get('enable_subunit'),
                                enable_jsonreport=options.get('enable_jsonreport'),
                                xunit_filename=options.get('xunit_file'),
                                subunit_filename=options.get('subunit_file'),
                                jsonreport_filename=options.get('jsonreport_file'),
                                tags=tags, failfast=failfast, auto_pdb=auto_pdb,
                                smtp_queue=smtp_queue)

                result = runner.run()
                if app_module is not None:
                    registry.call_hook('after_each', 'app', app_module, result)

                results.append(result)
                if not result or result.steps != result.steps_passed:
                    failed = True
        except LettuceRunnerError:
            failed = True

        except Exception as e:
            failed = True
            traceback.print_exc(e)

        finally:
            summary = SummaryTotalResults(results)
            summary.summarize_all()
            registry.call_hook('after', 'harvest', summary)

            if test_database:
                self._testrunner.teardown_databases(self._old_db_config)

            teardown_test_environment()
            server.stop(failed)

            if failed:
                raise CommandError("Lettuce tests failed.")

Example 123

Project: django-test-without-migrations Source File: nose_tests.py
    def test_is_nose_runner(self):
        TestRunner = get_runner(settings)
        from django_nose.runner import NoseTestSuiteRunner as expected
        assert TestRunner is expected

Example 124

Project: django-lifestream Source File: tests.py
def main():
    """
    Standalone django model test with a 'memory-only-django-installation'.
    You can play with a django model without a complete django app installation.
    http://www.djangosnippets.org/snippets/1044/
    """
    os.environ["DJANGO_SETTINGS_MODULE"] = "django.conf.global_settings"
    from django.conf import global_settings

    global_settings.INSTALLED_APPS = (
        'django.contrib.auth',
        'django.contrib.sites',
        'django.contrib.contenttypes',
        APP_MODULE,
    )
    global_settings.DATABASES = {
        'default': {
            'ENGINE': 'django.db.backends.sqlite3',
            'NAME': ':memory:',
        }
    }

    global_settings.MIDDLEWARE_CLASSES = (
        'django.middleware.common.CommonMiddleware',
        'django.contrib.sessions.middleware.SessionMiddleware',
        'django.contrib.auth.middleware.AuthenticationMiddleware',
    )

    from django.test.utils import get_runner
    test_runner = get_runner(global_settings)

    if django.VERSION > (1,2):
        test_runner = test_runner()
        failures = test_runner.run_tests([APP_MODULE])
    else:
        failures = test_runner([APP_MODULE], verbosity=1)
    sys.exit(failures)

Example 125

Project: django-oauthost Source File: runtests.py
def main():
    current_dir = os.path.dirname(__file__)
    app_name = os.path.basename(current_dir)
    sys.path.insert(0, os.path.join(current_dir, '..'))

    if not settings.configured:
        configure_kwargs = dict(
            INSTALLED_APPS=('django.contrib.auth', 'django.contrib.contenttypes', 'django.contrib.sessions', app_name),
            DATABASES={'default': {'ENGINE': 'django.db.backends.sqlite3'}},
            ROOT_URLCONF='oauthost.urls',
            MIDDLEWARE_CLASSES=(
                'django.middleware.common.CommonMiddleware',
                'django.contrib.sessions.middleware.SessionMiddleware',
                'django.contrib.auth.middleware.AuthenticationMiddleware',
            ),
        )

        try:
            configure_kwargs['TEMPLATE_CONTEXT_PROCESSORS'] = tuple(global_settings.TEMPLATE_CONTEXT_PROCESSORS) + (
                'django.core.context_processors.request',
            )

        except AttributeError:

            # Django 1.8+
            configure_kwargs['TEMPLATES'] = [
                {
                    'BACKEND': 'django.template.backends.django.DjangoTemplates',
                    'APP_DIRS': True,
                },
            ]

        settings.configure(**configure_kwargs)

    try:  # Django 1.7 +
        from django import setup
        setup()
    except ImportError:
        pass

    from django.test.utils import get_runner
    runner = get_runner(settings)()
    failures = runner.run_tests((app_name,))

    sys.exit(failures)

Example 126

Project: django-siteblocks Source File: runtests.py
def main():
    current_dir = os.path.dirname(__file__)
    app_name = os.path.basename(current_dir)
    sys.path.insert(0, os.path.join(current_dir, '..'))

    if not settings.configured:
        configure_kwargs = dict(
            INSTALLED_APPS=('django.contrib.auth', 'django.contrib.contenttypes', app_name),
            DATABASES={'default': {'ENGINE': 'django.db.backends.sqlite3'}},
            MIDDLEWARE_CLASSES=global_settings.MIDDLEWARE_CLASSES,  # Prevents Django 1.7 warning.
            ROOT_URLCONF = 'siteblocks.tests',
        )

        try:
            configure_kwargs['TEMPLATE_CONTEXT_PROCESSORS'] = tuple(global_settings.TEMPLATE_CONTEXT_PROCESSORS) + (
                'django.core.context_processors.request',
            )

        except AttributeError:

            # Django 1.8+
            configure_kwargs['TEMPLATES'] = [
                {
                    'BACKEND': 'django.template.backends.django.DjangoTemplates',
                    'APP_DIRS': True,
                },
            ]

        settings.configure(**configure_kwargs)

    try:  # Django 1.7 +
        from django import setup
        setup()
    except ImportError:
        pass

    from django.test.utils import get_runner
    runner = get_runner(settings)()
    failures = runner.run_tests((app_name,))

    sys.exit(failures)

Example 127

Project: django-sitecats Source File: runtests.py
def main():
    current_dir = os.path.dirname(__file__)
    app_name = os.path.basename(current_dir)
    sys.path.insert(0, os.path.join(current_dir, '..'))

    if not settings.configured:
        configure_kwargs = dict(
            INSTALLED_APPS=('django.contrib.auth', 'django.contrib.contenttypes', app_name, '%s.tests' % app_name),
            DATABASES={'default': {'ENGINE': 'django.db.backends.sqlite3'}},
            MIDDLEWARE_CLASSES=global_settings.MIDDLEWARE_CLASSES,  # Prevents Django 1.7 warning.
        )

        try:
            configure_kwargs['TEMPLATE_CONTEXT_PROCESSORS'] = tuple(global_settings.TEMPLATE_CONTEXT_PROCESSORS) + (
                'django.core.context_processors.request',
            )

        except AttributeError:

            # Django 1.8+
            configure_kwargs['TEMPLATES'] = [
                {
                    'BACKEND': 'django.template.backends.django.DjangoTemplates',
                    'APP_DIRS': True,
                },
            ]

        settings.configure(**configure_kwargs)

    try:  # Django 1.7 +
        from django import setup
        setup()
    except ImportError:
        pass

    from django.test.utils import get_runner
    runner = get_runner(settings)()
    failures = runner.run_tests((app_name,))

    sys.exit(failures)

Example 128

Project: django-sitegate Source File: runtests.py
def main():
    sys.path.insert(0, os.path.join(os.path.dirname(__file__), '..'))

    if not settings.configured:
        configure_kwargs = dict(
            INSTALLED_APPS=(
                'django.contrib.auth',
                'django.contrib.contenttypes',
                'django.contrib.sessions',
                'etc',
                APP_NAME,
            ),
            DATABASES={'default': {'ENGINE': 'django.db.backends.sqlite3'}},
            MIDDLEWARE_CLASSES=(
                'django.middleware.common.CommonMiddleware',
                'django.contrib.sessions.middleware.SessionMiddleware',
                'django.contrib.auth.middleware.AuthenticationMiddleware',
                'django.contrib.messages.middleware.MessageMiddleware',
            ),
            ROOT_URLCONF='sitegate.tests',
            MIGRATION_MODULES={
                'auth': 'django.contrib.auth.tests.migrations',
            },
            AUTH_USER_MODEL=os.environ.get('DJANGO_AUTH_USER_MODEL', 'auth.User')
        )

        try:
            configure_kwargs['TEMPLATE_CONTEXT_PROCESSORS'] = tuple(global_settings.TEMPLATE_CONTEXT_PROCESSORS) + (
                'django.core.context_processors.request',
            )

        except AttributeError:

            # Django 1.8+
            configure_kwargs['TEMPLATES'] = [
                {
                    'BACKEND': 'django.template.backends.django.DjangoTemplates',
                    'APP_DIRS': True,
                },
            ]

        settings.configure(**configure_kwargs)

    try:  # Django 1.7 +
        from django import setup
        setup()
    except ImportError:
        pass

    from django.test.utils import get_runner
    runner = get_runner(settings)()
    failures = runner.run_tests((APP_NAME,))

    sys.exit(failures)

Example 129

Project: django-sitemetrics Source File: runtests.py
def main():
    current_dir = os.path.dirname(__file__)
    app_name = os.path.basename(current_dir)
    sys.path.insert(0, os.path.join(current_dir, '..'))

    if not settings.configured:
        configure_kwargs = dict(
            INSTALLED_APPS=('django.contrib.sites', app_name),
            DATABASES={'default': {'ENGINE': 'django.db.backends.sqlite3'}},
            MIDDLEWARE_CLASSES=global_settings.MIDDLEWARE_CLASSES,  # Prevents Django 1.7 warning.
        )

        try:
            configure_kwargs['TEMPLATE_CONTEXT_PROCESSORS'] = tuple(global_settings.TEMPLATE_CONTEXT_PROCESSORS) + (
                'django.core.context_processors.request',
            )

        except AttributeError:  # Django 1.10+
            configure_kwargs['TEMPLATES'] = [
                {
                    'BACKEND': 'django.template.backends.django.DjangoTemplates',
                    'APP_DIRS': True,
                },
            ]

        settings.configure(**configure_kwargs)

    try:  # Django 1.7 +
        from django import setup
        setup()
    except ImportError:
        pass

    from django.test.utils import get_runner
    runner = get_runner(settings)()
    failures = runner.run_tests((app_name,))

    sys.exit(failures)

Example 130

Project: django-sitetree Source File: runtests.py
def main():
    sys.path.insert(0, os.path.join(os.path.dirname(__file__), '..'))

    if not settings.configured:

        configure_kwargs = dict(
            INSTALLED_APPS=('django.contrib.auth', 'django.contrib.contenttypes', APP_NAME),
            DATABASES={'default': {'ENGINE': 'django.db.backends.sqlite3'}},
            ROOT_URLCONF='sitetree.tests',
            MIDDLEWARE_CLASSES=global_settings.MIDDLEWARE_CLASSES,  # Prevents Django 1.7 warning.
        )

        try:
            configure_kwargs['TEMPLATE_CONTEXT_PROCESSORS'] = tuple(global_settings.TEMPLATE_CONTEXT_PROCESSORS) + (
                'django.core.context_processors.request',
            )

        except AttributeError:

            # Django 1.8+
            configure_kwargs['TEMPLATES'] = [
                {
                    'BACKEND': 'django.template.backends.django.DjangoTemplates',
                    'APP_DIRS': True,
                },
            ]

        settings.configure(**configure_kwargs)

    try:  # Django 1.7 +
        from django import setup
        setup()
    except ImportError:
        pass

    from django.test.utils import get_runner
    runner = get_runner(settings)()
    failures = runner.run_tests((APP_NAME,))

    sys.exit(failures)

Example 131

Project: django-googlecharts Source File: runtests.py
Function: run_tests
def runtests():
    test_runner = get_runner(settings)
    failures = test_runner(['googlecharts'], verbosity=1, interactive=True)
    sys.exit(failures)

Example 132

Project: django-s3-folder-storage Source File: tests.py
def main():
    """
    Standalone django model test with a 'memory-only-django-installation'.
    You can play with a django model without a complete django app installation
    http://www.djangosnippets.org/snippets/1044/
    """
    sys.exc_clear()

    os.environ["DJANGO_SETTINGS_MODULE"] = "django.conf.global_settings"
    from django.conf import global_settings

    global_settings.INSTALLED_APPS = (
        'django.contrib.auth',
        'django.contrib.sessions',
        'django.contrib.contenttypes',
        's3_folder_storage',
        's3_folder_storage.tests.testapp',
    )
    if django.VERSION > (1, 2):
        global_settings.DATABASES = {
            'default': {
                'ENGINE': 'django.db.backends.sqlite3',
                'NAME': os.path.join(BASE_PATH, 'connpass.sqlite'),
                'USER': '',
                'PASSWORD': '',
                'HOST': '',
                'PORT': '',
            }
        }
    else:
        global_settings.DATABASE_ENGINE = "sqlite3"
        global_settings.DATABASE_NAME = ":memory:"

    global_settings.MIDDLEWARE_CLASSES = (
        'django.middleware.common.CommonMiddleware',
        'django.contrib.sessions.middleware.SessionMiddleware',
        'django.middleware.csrf.CsrfViewMiddleware',
        'django.contrib.auth.middleware.AuthenticationMiddleware',
        'django.contrib.messages.middleware.MessageMiddleware',
    )

    # custom settings for tests
    global_settings.DEFAULT_FILE_STORAGE = 's3_folder_storage.s3.DefaultStorage'
    global_settings.DEFAULT_S3_PATH = "media"
    global_settings.STATICFILES_STORAGE = 's3_folder_storage.s3.StaticStorage'
    global_settings.STATIC_S3_PATH = "static"
    global_settings.AWS_QUERYSTRING_AUTH = False  # Prefer unsigned S3 URLs.

    # requires some envifonment variables
    global_settings.AWS_ACCESS_KEY_ID = os.environ.get(
        'AWS_ACCESS_KEY_ID', None)
    global_settings.AWS_SECRET_ACCESS_KEY = os.environ.get(
        'AWS_SECRET_ACCESS_KEY', None)
    global_settings.AWS_STORAGE_BUCKET_NAME = os.environ.get(
        'AWS_STORAGE_BUCKET_NAME', None)

    global_settings.MEDIA_ROOT = '/%s/' % global_settings.DEFAULT_S3_PATH
    global_settings.MEDIA_URL = 'https://s3.amazonaws.com/%s/media/' % (
        global_settings.AWS_STORAGE_BUCKET_NAME)
    global_settings.STATIC_ROOT = "/%s/" % global_settings.STATIC_S3_PATH
    global_settings.STATIC_URL = 'https://s3.amazonaws.com/%s/static/' % (
        global_settings.AWS_STORAGE_BUCKET_NAME)
    global_settings.ADMIN_MEDIA_PREFIX = global_settings.STATIC_URL + 'admin/'

    # global_settings.DEFAULT_FILE_STORAGE = 'backends.s3boto.S3BotoStorage'
    # global_settings.AWS_IS_GZIPPED = True
    global_settings.SECRET_KEY = "blahblah"

    from django.test.utils import get_runner
    test_runner = get_runner(global_settings)

    if django.VERSION > (1, 7):
        print "running 1.7+ tests"
        django.setup()
        from django.test.runner import DiscoverRunner
        test_runner = DiscoverRunner()
        failures = test_runner.run_tests(['s3_folder_storage', ])
    elif django.VERSION > (1, 2):
        test_runner = test_runner()
        failures = test_runner.run_tests(['s3_folder_storage', ])
    else:
        failures = test_runner(['s3_folder_storage', ], verbosity=1)
    sys.exit(failures)

Example 133

Project: django-enumfield Source File: run_tests.py
def main():
    import warnings
    warnings.filterwarnings('error', category=DeprecationWarning)

    delete_migrations()

    if not settings.configured:
        # Dynamically configure the Django settings with the minimum necessary to
        # get Django running tests
        settings.configure(
            INSTALLED_APPS=[
                'django.contrib.auth',
                'django.contrib.contenttypes',
                'django.contrib.admin',
                'django.contrib.sessions',
                'django_enumfield',
                'django_enumfield.tests',
            ],
            # Django replaces this, but it still wants it. *shrugs*
            DATABASE_ENGINE='django.db.backends.sqlite3',
            DATABASES={
                'default': {
                    'ENGINE': 'django.db.backends.sqlite3',
                }
            },
            MEDIA_ROOT='/tmp/django_enums/',
            MEDIA_PATH='/media/',
            ROOT_URLCONF='django_enumfield.tests.urls',
            DEBUG=True,
            TEMPLATE_DEBUG=True,
        )

    # Compatibility with Django 1.7's stricter initialization
    if hasattr(django, 'setup'):
        django.setup()

    from django.test.utils import get_runner
    test_runner = get_runner(settings)(verbosity=2, interactive=True)
    if '--failfast' in sys.argv:
        test_runner.failfast = True

    failures = test_runner.run_tests(['django_enumfield'])

    delete_migrations()

    sys.exit(failures)

Example 134

Project: django-viewlet Source File: run_tests.py
def main():
    conf = {'DEBUG': True,
            'TEMPLATE_DEBUG': True,
            'INSTALLED_APPS': ['viewlet', 'viewlet.tests'],
            'MEDIA_ROOT': '/tmp/viewlet/media',
            'STATIC_ROOT': '/tmp/viewlet/static',
            'MEDIA_URL': '/media/',
            'STATIC_URL': '/static/',
            'ROOT_URLCONF': 'viewlet.tests.urls',
            'SECRET_KEY': "iufoj=mibkpdz*%bob952x(%49rqgv8gg45k36kjcg76&-y5=!",
            'JINJA2_ENVIRONMENT_OPTIONS': {
                'optimized': False  # Coffin config
            },
            'JINJA_CONFIG': {
                'autoescape': True  # Jingo config
            }
    }

    if django.VERSION[:2] >= (1, 3):
        conf.update(DATABASES={
            'default': {
                'ENGINE': 'django.db.backends.sqlite3',
                'NAME': ':memory:',
            }
        })

        conf.update(CACHES={
            'default': {
                'BACKEND': 'django.core.cache.backends.locmem.LocMemCache'
            }
        })
    else:
        conf.update(DATABASE_ENGINE='sqlite3')
        conf.update(CACHE_BACKEND='locmem://')

    settings.configure(**conf)

    from django.test.utils import get_runner
    if django.VERSION < (1, 2):
        failures = get_runner(settings)(['viewlet'], verbosity=2, interactive=True)
    else:
        test_runner = get_runner(settings)(verbosity=2, interactive=True)
        failures = test_runner.run_tests(['viewlet'])

    sys.exit(failures)

Example 135

Project: django-tabular-export Source File: run_tests.py
Function: get_test_runner
def get_test_runner():
    TestRunner = get_runner(settings)
    return TestRunner()

Example 136

Project: django-experiments Source File: testrunner.py
def runtests():
    test_dir = os.path.dirname(os.path.abspath(__file__))
    sys.path.insert(0, test_dir)

    settings.configure(
        DEBUG=True,
        DATABASES={
            'default': {
                'ENGINE': 'django.db.backends.sqlite3',
            }
        },
        INSTALLED_APPS=('django.contrib.auth',
                        'django.contrib.contenttypes',
                        'django.contrib.sessions',
                        'django.contrib.admin',
                        'experiments',),
        ROOT_URLCONF='experiments.tests.urls',
        MIDDLEWARE_CLASSES = (
            'django.contrib.sessions.middleware.SessionMiddleware',
            'django.middleware.csrf.CsrfViewMiddleware',
            'django.contrib.auth.middleware.AuthenticationMiddleware',
            'django.contrib.auth.middleware.SessionAuthenticationMiddleware',
        ),
        TEMPLATES = [
            {
                'BACKEND': 'django.template.backends.django.DjangoTemplates',
                'DIRS': [],
                'APP_DIRS': True,
                'OPTIONS': {},
            },
        ],
    )
    django.setup()


    from django.test.utils import get_runner
    TestRunner = get_runner(settings)
    test_runner = TestRunner(verbosity=1, failfast=False)
    failures = test_runner.run_tests(['experiments', ])
    sys.exit(bool(failures))

Example 137

Project: django-speedbar Source File: testrunner.py
def runtests():
    test_dir = os.path.dirname(os.path.abspath(__file__))
    sys.path.insert(0, test_dir)

    settings.configure(
        DEBUG=True,
        DATABASES={
            'default': {
                'ENGINE': 'django.db.backends.sqlite3',
            }
        },
        INSTALLED_APPS=('django.contrib.auth',
                        'django.contrib.contenttypes',
                        'django.contrib.sessions',
                        'django.contrib.admin',
                        'speedbar',
                        'tests'),
        ROOT_URLCONF='tests.urls',
        MIDDLEWARE_CLASSES = (
            'speedbar.middleware.SpeedbarMiddleware',
            'django.contrib.sessions.middleware.SessionMiddleware',
            'django.middleware.csrf.CsrfViewMiddleware',
            'django.contrib.auth.middleware.AuthenticationMiddleware',
            'django.contrib.auth.middleware.SessionAuthenticationMiddleware',
        ),
    )
    django.setup()


    from django.test.utils import get_runner
    TestRunner = get_runner(settings)
    test_runner = TestRunner(verbosity=1, failfast=False)
    failures = test_runner.run_tests(['tests', ])
    sys.exit(bool(failures))

Example 138

Project: django-hstore-flattenfields Source File: runtests.py
Function: get_runner
def get_runner(settings):
    from django.test.utils import get_runner
    TestRunner = get_runner(settings)
    return TestRunner(verbosity=1, interactive=True, failfast=False)

Example 139

Project: django-performance-testing Source File: test_integrates_with_django_testrunner.py
@pytest.mark.parametrize('runner_cls_name,test_runner_cls,test_suite_cls', [
    ('django.test.runner.DiscoverRunner',
        unittest.TextTestRunner, unittest.TestSuite),
    (to_dotted_name(MyDjangoTestRunner),
        MyTestRunner, MyTestSuite),
], ids=['vanilla runner', 'custom runner'])
def test_runner_keeps_default_classes_in_inheritance_chain(
        settings, runner_cls_name, test_runner_cls, test_suite_cls):
    settings.TEST_RUNNER = runner_cls_name
    django_runner_cls = get_runner(settings)

    def assert_is_djpt_mixin(cls, base_cls, mixin_base_name):
        fullname = 'django_performance_testing.test_runner.{}'.format(
            mixin_base_name)
        mixin_cls_name = '{}Mixin'.format(mixin_base_name)
        mixin_cls = getattr(djpt_test_runner_module, mixin_cls_name)
        assert fullname == to_dotted_name(cls)
        assert issubclass(cls, mixin_cls)
        assert cls.__mro__[1] == mixin_cls
        if any(isinstance(base_cls, str_tp) for str_tp in six.string_types):
            assert base_cls == to_dotted_name(cls.__mro__[2])
        elif isinstance(base_cls, type):
            assert issubclass(cls, base_cls)
            assert cls.__mro__[2] == base_cls
        else:
            raise NotImplementedError(
                'Cannot handle type {}'.format(type(base_cls)))

    assert_is_djpt_mixin(
        cls=django_runner_cls, base_cls=runner_cls_name,
        mixin_base_name='DjptDjangoTestRunner')
    assert_is_djpt_mixin(
        cls=django_runner_cls.test_runner, base_cls=test_runner_cls,
        mixin_base_name='DjptTestRunner')
    assert django_runner_cls.test_suite == test_suite_cls
See More Examples - Go to Next Page
Page 1 Page 2 Page 3 Selected