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 1

Project: ADL_LRS Source File: runtests.py
Function: main
def main():
    TestRunner = get_runner(settings)
    test_runner = TestRunner(verbosity=2)

    if len(sys.argv) == 2:
        test_case = '.' + sys.argv[1]
    elif len(sys.argv) == 1:
        test_case = ''
    else:
        print(usage())
        sys.exit(1)

    patch_for_test_db_setup()
    failures = test_runner.run_tests(['tests' + test_case])

    sys.exit(failures)

Example 2

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

        TestRunner = get_runner(settings, options['testrunner'])

        test_runner = TestRunner(**options)
        failures = test_runner.run_tests(test_labels)

        if failures:
            sys.exit(1)

Example 3

Project: django-revproxy Source File: run.py
Function: run_tests
def runtests():
    if django.VERSION >= (1, 7, 0):
        django.setup()

    test_runner = get_runner(settings)
    failures = test_runner(interactive=False, failfast=False).run_tests([])
    sys.exit(failures)

Example 4

Project: django-timepiece Source File: run_tests.py
def run_django_tests(settings, apps):
    os.environ['DJANGO_SETTINGS_MODULE'] = settings

    import django
    if hasattr(django, 'setup'):  # Django 1.7+
        django.setup()

    from django.conf import settings
    from django.test.utils import get_runner
    runner = get_runner(settings)(verbosity=1, interactive=True, failfast=False)
    failures = runner.run_tests(apps or DEFAULT_APPS)
    sys.exit(failures)

Example 5

Project: django-dockit Source File: setuptest.py
Function: run_tests
def runtests():
    """Test runner for setup.py test."""
    # Run you some tests.
    import django.test.utils
    runner_class = django.test.utils.get_runner(settings)
    test_runner = runner_class(verbosity=1, interactive=True)
    failures = test_runner.run_tests(['dockit'])

    # Okay, so this is a nasty hack. If this isn't here, `setup.py test` craps out
    # when generating a coverage report via Nose. I have no idea why, or what's
    # supposed to be going on here, but this seems to fix the problem, and I
    # *really* want coverage, so, unless someone can tell me *why* I shouldn't
    # do this, I'm going to just whistle innocently and keep on doing this.
    sys.exitfunc = lambda: 0

    sys.exit(failures)

Example 6

Project: django-hitcount Source File: runtests.py
def run_django_tests(args):
    """This will only work with a later version of Django (1.8?)"""
    from django.core.exceptions import ImproperlyConfigured

    try:
        from django.test.utils import get_runner
        from tests.conftest import pytest_configure

        settings = pytest_configure()
        TestRunner = get_runner(settings)
        test_runner = TestRunner()
        exit_on_failure(test_runner.run_tests(args))

    except ImproperlyConfigured:
        sys.exit('TEST #FAIL: The --django arg has only been tested with 1.8')

Example 7

Project: django-relationships Source File: runtests.py
Function: run_tests
def runtests(*test_args):
    if not test_args:
        test_args = ['relationships_tests']
    parent = dirname(abspath(__file__))
    sys.path.insert(0, parent)
    TestRunner = get_runner(settings)
    test_runner = TestRunner(verbosity=1, interactive=True)
    failures = test_runner.run_tests(test_args)
    sys.exit(failures)

Example 8

Project: Django--an-app-at-a-time Source File: test.py
Function: handle
    def handle(self, *test_labels, **options):
        from django.conf import settings
        from django.test.utils import get_runner

        TestRunner = get_runner(settings, options.get('testrunner'))

        if options.get('liveserver') is not None:
            os.environ['DJANGO_LIVE_TEST_SERVER_ADDRESS'] = options['liveserver']
            del options['liveserver']

        test_runner = TestRunner(**options)
        failures = test_runner.run_tests(test_labels)

        if failures:
            sys.exit(bool(failures))

Example 9

Project: django-macaddress Source File: runtests.py
def runtests():
    if hasattr(django, 'setup'):
        django.setup()
    TestRunner = get_runner(settings)
    test_runner = TestRunner(verbosity=1, interactive=True, failfast=False)
    apps = ['macaddress', ]
    failures = test_runner.run_tests(apps)
    sys.exit(failures)

Example 10

Project: django-systemjs Source File: runtests.py
def runtests(*tests):
    test_dir = os.path.dirname(__file__)
    sys.path.insert(0, test_dir)
    os.environ['DJANGO_SETTINGS_MODULE'] = 'tests.settings'

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

    django.setup()

    TestRunner = get_runner(settings)
    test_runner = TestRunner(verbosity=1, interactive=True)

    if not tests:
        tests = (['.'],)
    failures = test_runner.run_tests(*tests)
    sys.exit(failures)

Example 11

Project: django-scribbler Source File: runtests.py
def runtests():
    if hasattr(django, 'setup'):
        django.setup()
    TestRunner = get_runner(settings)
    test_runner = TestRunner(verbosity=1, interactive=True, failfast=False)
    failures = test_runner.run_tests(['scribbler', ])
    sys.exit(failures)

Example 12

Project: drf-to-s3 Source File: runtests.py
def main():
    TestRunner = get_runner(settings)

    test_runner = TestRunner()
    if len(sys.argv) == 2:
        test_case = sys.argv[1]
    elif len(sys.argv) == 1:
        test_case = 'tests'
    else:
        print(usage())
        sys.exit(1)
    test_module_name = 'drf_to_s3.'
    if django.VERSION[0] == 1 and django.VERSION[1] < 6:
        test_module_name = ''

    failures = test_runner.run_tests([test_module_name + test_case])

    sys.exit(failures)

Example 13

Project: django-celery-ses Source File: runtests.py
Function: run_tests
def runtests(**test_args):
    from django.test.utils import get_runner

    parent = dirname(abspath(__file__))
    sys.path.insert(0, parent)

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

Example 14

Project: rapidsms-appointments Source File: runtests.py
Function: run_tests
def runtests():
    TestRunner = get_runner(settings)
    test_runner = TestRunner(verbosity=1, interactive=True, failfast=False)
    args = sys.argv[1:] or ['appointments', ]
    failures = test_runner.run_tests(args)
    sys.exit(failures)

Example 15

Project: performant-pagination Source File: runtests.py
Function: main
def main():
    TestRunner = get_runner(settings)

    test_runner = TestRunner()
    if len(sys.argv) == 2:
        test_case = '.' + sys.argv[1]
    elif len(sys.argv) == 1:
        test_case = ''
    else:
        print(usage())
        sys.exit(1)
    test_module_name = 'performant_pagination.tests'
    if django.VERSION[0] == 1 and django.VERSION[1] < 6:
        test_module_name = 'tests'

    failures = test_runner.run_tests([test_module_name + test_case])

    sys.exit(failures)

Example 16

Project: django-generic-aggregation Source File: runtests.py
Function: run_tests
def runtests(*test_args):
    if not test_args:
        test_args = [app_to_test]
    parent = dirname(abspath(__file__))
    sys.path.insert(0, parent)
    TestRunner = get_runner(settings)
    test_runner = TestRunner(verbosity=1, interactive=True)
    try:
        from django import setup
        setup()
    except ImportError:
        pass
    failures = test_runner.run_tests(test_args)
    sys.exit(failures)

Example 17

Project: ion Source File: test_suite.py
def run_tests():
    """Wrapper for ./setup.py test."""
    os.environ.setdefault("DJANGO_SETTINGS_MODULE", "intranet.settings")
    django.setup()
    test_runner = get_runner(settings)()
    failures = test_runner.run_tests([])
    sys.exit(failures)

Example 18

Project: django-wysihtml5 Source File: __init__.py
Function: run_tests
def run_tests():
    if not os.environ.get("DJANGO_SETTINGS_MODULE", False):
        setup_django_settings()

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

    runner = get_runner(settings, "django.test.simple.DjangoTestSuiteRunner")
    test_suite = runner(verbosity=2, interactive=True, failfast=False)
    test_suite.run_tests(["wysihtml5"])

Example 19

Project: dj-ango Source File: runtests.py
Function: run_tests
def run_tests(*test_args):
    if not test_args:
        test_args = ['tests']

    # Run tests
    TestRunner = get_runner(settings)
    test_runner = TestRunner()

    failures = test_runner.run_tests(test_args)

    if failures:
        sys.exit(bool(failures))

Example 20

Project: queued_search Source File: runtests.py
Function: run_tests
def runtests(*test_args):
    import django.test.utils

    runner_class = django.test.utils.get_runner(settings)
    test_runner = runner_class(verbosity=1, interactive=True, failfast=False)
    failures = test_runner.run_tests(['tests'])
    sys.exit(failures)

Example 21

Project: unittest-xml-reporting Source File: django_test.py
    def test_django_verbose(self):
        self._override_settings(
            TEST_OUTPUT_VERBOSE=True,
            TEST_RUNNER='xmlrunner.extra.djangotestrunner.XMLTestRunner')
        runner_class = get_runner(settings)
        runner = runner_class()
        self._check_runner(runner)

Example 22

Project: unittest-xml-reporting Source File: django_test.py
    def test_django_single_report(self):
        self._override_settings(
            TEST_OUTPUT_DIR=self.tmpdir,
            TEST_OUTPUT_FILE_NAME='results.xml',
            TEST_OUTPUT_VERBOSE=0,
            TEST_RUNNER='xmlrunner.extra.djangotestrunner.XMLTestRunner')
        apps.populate(settings.INSTALLED_APPS)
        runner_class = get_runner(settings)
        runner = runner_class()
        suite = runner.build_suite()
        runner.run_suite(suite)
        expected_file = path.join(self.tmpdir, 'results.xml')
        self.assertTrue(path.exists(expected_file),
                        'did not generate xml report where expected.')

Example 23

Project: rapidsms Source File: run_tests.py
Function: run_tests
def run_tests(options, args):
    if django.VERSION > (1, 7):
        # http://django.readthedocs.org/en/latest/releases/1.7.html#standalone-scripts
        django.setup()

    TestRunner = get_runner(settings)
    test_runner = TestRunner(verbosity=int(options.verbosity),
                             interactive=options.interactive,
                             failfast=False)
    if not args:
        args = ['rapidsms']
    failures = test_runner.run_tests(args)
    sys.exit(failures)

Example 24

Project: django-hyperadmin Source File: runtests.py
Function: run_tests
def runtests():
    """Test runner for setup.py test."""
    # Run you some tests.
    import django.test.utils
    runner_class = django.test.utils.get_runner(settings)
    test_runner = runner_class(verbosity=1, interactive=True)
    failures = test_runner.run_tests(['hyperadmin'])

    # Okay, so this is a nasty hack. If this isn't here, `setup.py test` craps out
    # when generating a coverage report via Nose. I have no idea why, or what's
    # supposed to be going on here, but this seems to fix the problem, and I
    # *really* want coverage, so, unless someone can tell me *why* I shouldn't
    # do this, I'm going to just whistle innocently and keep on doing this.
    sys.exitfunc = lambda: 0

    sys.exit(failures)

Example 25

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

    module_name = 'rest_utils.tests'
    if django.VERSION[0] == 1 and django.VERSION[1] < 6:
        module_name = 'rest_utils'

    failures = test_runner.run_tests([module_name])
    sys.exit(failures)

Example 26

Project: django-email-bandit Source File: runtests.py
def runtests():
    if django.VERSION > (1, 7):
        # http://django.readthedocs.org/en/latest/releases/1.7.html#standalone-scripts
        django.setup()
    from django.test.utils import get_runner
    TestRunner = get_runner(settings)
    test_runner = TestRunner(verbosity=1, interactive=True, failfast=False)
    failures = test_runner.run_tests(['bandit', ])
    sys.exit(failures)

Example 27

Project: django-seed Source File: runtests.py
def runtests():
    django.setup()
    TestRunner = get_runner(settings)
    test_runner = TestRunner(verbosity=1, interactive=True, failfast=False)
    failures = test_runner.run_tests(['django_seed', ])
    sys.exit(failures)

Example 28

Project: django-ticketing Source File: runtests.py
Function: run_tests
def runtests(*test_args):
    if 'south' in settings.INSTALLED_APPS:
        from south.management.commands import patch_for_test_db_setup
        patch_for_test_db_setup()
    
    if not test_args:
        test_args = ['ticketing']
    parent = dirname(abspath(__file__))
    sys.path.insert(0, parent)
    
    from django.test.utils import get_runner
    TestRunner = get_runner(settings)
    
    test_runner = TestRunner(verbosity=0, interactive=True, failfast=True)
    failures = test_runner.run_tests(test_args)
    sys.exit(bool(failures))

Example 29

Project: django-sticky-uploads Source File: runtests.py
def runtests():
    if hasattr(django, 'setup'):
        django.setup()
    TestRunner = get_runner(settings)
    test_runner = TestRunner(verbosity=1, interactive=True, failfast=False)
    failures = test_runner.run_tests(['stickyuploads', ])
    sys.exit(failures)

Example 30

Project: django-test-plus Source File: runtests.py
Function: run_tests
def runtests(*test_args):
    import django.test.utils
    if django.VERSION[0:2] >= (1, 7):
        django.setup()
    runner_class = django.test.utils.get_runner(settings)
    test_runner = runner_class(verbosity=1, interactive=True)
    failures = test_runner.run_tests(['test_app'])
    sys.exit(failures)

Example 31

Project: django-treenav Source File: runtests.py
def runtests():
    if django.VERSION > (1, 7):
        # http://django.readthedocs.org/en/latest/releases/1.7.html#standalone-scripts
        django.setup()
    TestRunner = get_runner(settings)
    test_runner = TestRunner(verbosity=1, interactive=True, failfast=False)
    failures = test_runner.run_tests(['treenav', ])
    sys.exit(failures)

Example 32

Project: django-password-policies Source File: tests.py
def runtests(*test_args):
    os.environ['DJANGO_SETTINGS_MODULE'] = 'password_policies.tests.test_settings'
    django.setup()
    TestRunner = get_runner(settings)
    test_runner = TestRunner()
    failures = test_runner.run_tests(["password_policies.tests"])
    sys.exit(bool(failures))

Example 33

Project: rapidsms-twilio Source File: runtests.py
def runtests():
    django.setup()
    TestRunner = get_runner(settings)
    test_runner = TestRunner(verbosity=1, interactive=True, failfast=False)
    failures = test_runner.run_tests(['rtwilio', ])
    sys.exit(failures)

Example 34

Project: django-konfera Source File: runtests.py
Function: run_tests
def run_tests(*test_args):
    if not test_args:
        test_args = ['konfera.tests', 'payments.tests']

    # Run tests
    TestRunner = get_runner(settings)
    test_runner = TestRunner()

    failures = test_runner.run_tests(test_args)

    if failures:
        sys.exit(bool(failures))

Example 35

Project: django-translation-manager Source File: runtests.py
def run_tests():
    import django
    from django.test.utils import get_runner
    from django.conf import settings

    django.setup()
    test_runner = get_runner(settings)()
    failures = test_runner.run_tests(["tests"])
    sys.exit(bool(failures))

Example 36

Project: django-rest-auth Source File: runtests.py
def runtests():
    TestRunner = get_runner(settings)
    test_runner = TestRunner(verbosity=1, interactive=True)
    if hasattr(django, 'setup'):
        django.setup()
    failures = test_runner.run_tests(['rest_auth'])
    sys.exit(bool(failures))

Example 37

Project: django-generic-m2m Source File: runtests.py
Function: run_tests
def runtests(*test_args):
    if not test_args:
        if sys.version_info[0] > 2:
            test_args = ['genericm2m.genericm2m_tests']
        else:
            test_args = ["genericm2m_tests"]
    parent = dirname(abspath(__file__))
    sys.path.insert(0, parent)
    TestRunner = get_runner(settings)
    test_runner = TestRunner(verbosity=1, interactive=True)
    failures = test_runner.run_tests(test_args)
    sys.exit(failures)

Example 38

Project: django-fancy-cronfield Source File: runtests.py
def main(*test_args):
    if not test_args:
        test_args = ['fancy_cronfield']

    os.environ['DJANGO_SETTINGS_MODULE'] = 'fancy_cronfield.tests.settings'
    from django.test.utils import get_runner

    if not (DJANGO_1_5 or DJANGO_1_6):
        django.setup()

    test_runner_class = get_runner(settings)
    test_runner = test_runner_class()
    failures = test_runner.run_tests(test_args)
    sys.exit(bool(failures))

Example 39

Project: django-comments-xtd Source File: runtests.py
def run_tests():
    if not os.environ.get("DJANGO_SETTINGS_MODULE", False):
        setup_django_settings()

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

    if django.VERSION[1] >= 7: # Django 1.7.x or above
        django.setup()
        runner = get_runner(settings,"django.test.runner.DiscoverRunner")
    else:
        runner = get_runner(settings,"django.test.simple.DjangoTestSuiteRunner")
    test_suite = runner(verbosity=2, interactive=True, failfast=False)
    return test_suite.run_tests(["django_comments_xtd"])

Example 40

Project: django-subdomains Source File: __init__.py
def run():
    import sys

    import django
    from django.test.utils import get_runner

    if django.VERSION >= (1, 7):
        django.setup()

    runner = get_runner(settings)()
    failures = runner.run_tests(('subdomains',))
    sys.exit(failures)

Example 41

Project: django-mailviews Source File: __main__.py
Function: run
def run():
    from django.conf import settings
    from django.test.utils import get_runner

    runner = get_runner(settings)()
    return runner.run_tests(('mailviews',))

Example 42

Project: GAE-Bulk-Mailer Source File: test.py
Function: create_parser
    def create_parser(self, prog_name, subcommand):
        test_runner_class = get_runner(settings, self.test_runner)
        options = self.option_list + getattr(
            test_runner_class, 'option_list', ())
        return OptionParser(prog=prog_name,
                            usage=self.usage(subcommand),
                            version=self.get_version(),
                            option_list=options)

Example 43

Project: django-dbbackup Source File: runtests.py
def main(argv=None):
    os.environ['DJANGO_SETTINGS_MODULE'] = 'dbbackup.tests.settings'
    argv = argv or []
    if len(argv) <= 1:
        from django.test.utils import get_runner
        if django.VERSION >= (1, 7):
            django.setup()
        TestRunner = get_runner(settings)
        test_runner = TestRunner()
        result = test_runner.run_tests(["dbbackup.tests"])
        return result
    execute_from_command_line(argv)

Example 44

Project: unittest-xml-reporting Source File: django_test.py
    def test_django_xmlrunner(self):
        self._override_settings(
            TEST_RUNNER='xmlrunner.extra.djangotestrunner.XMLTestRunner')
        runner_class = get_runner(settings)
        runner = runner_class()
        self._check_runner(runner)

Example 45

Project: django_uncertainty Source File: runtests.py
def runtests():
    os.environ['DJANGO_SETTINGS_MODULE'] = 'uncertainty.tests.settings'
    django.setup()
    sys.path.insert(0, os.path.dirname(__file__))
    test_runner = get_runner(settings)()
    failures = test_runner.run_tests([], verbosity=1, interactive=True)
    sys.exit(bool(failures))

Example 46

Project: django-fancy-cache Source File: runtests.py
def runtests():
    test_dir = os.path.join(os.path.dirname(__file__), 'fancy_tests/tests')
    sys.path.insert(0, test_dir)

    os.environ['DJANGO_SETTINGS_MODULE'] = 'settings'
    django.setup()

    TestRunner = get_runner(settings)
    test_runner = TestRunner(interactive=False, failfast=False)
    failures = test_runner.run_tests(['fancy_tests.tests'])

    sys.exit(bool(failures))

Example 47

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

        TestRunner = get_runner(settings, options.get('testrunner'))
        options['verbosity'] = int(options.get('verbosity'))

        if options.get('liveserver') is not None:
            os.environ['DJANGO_LIVE_TEST_SERVER_ADDRESS'] = options['liveserver']
            del options['liveserver']

        test_runner = TestRunner(**options)
        failures = test_runner.run_tests(test_labels)

        if failures:
            sys.exit(bool(failures))

Example 48

Project: django-friendship Source File: runtests.py
Function: run_tests
def runtests(*test_args):
    import django.test.utils

    if django.VERSION[0:2] >= (1, 7):
        django.setup()

    runner_class = django.test.utils.get_runner(settings)
    test_runner = runner_class(verbosity=1, interactive=True, failfast=False)
    failures = test_runner.run_tests(['friendship'])
    sys.exit(failures)

Example 49

Project: xadmin Source File: runtests.py
def django_tests(verbosity, interactive, failfast, test_labels):
    from django.conf import settings
    state = setup(verbosity, test_labels)
    extra_tests = []

    # Run the test suite, including the extra validation tests.
    from django.test.utils import get_runner
    if not hasattr(settings, 'TEST_RUNNER'):
        settings.TEST_RUNNER = 'django.test.simple.DjangoTestSuiteRunner'
    TestRunner = get_runner(settings)

    test_runner = TestRunner(verbosity=verbosity, interactive=interactive,
        failfast=failfast)
    failures = test_runner.run_tests(test_labels or get_test_modules(), extra_tests=extra_tests)

    teardown(state)
    return failures

Example 50

Project: django-input-mask Source File: runtests.py
def runtests():
    from django.test.utils import get_runner
    from django.conf import settings

    TestRunner = get_runner(settings)
    test_runner = TestRunner(verbosity=1, interactive=True)

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

    sys.exit(bool(failures))
See More Examples - Go to Next Page
Page 1 Selected Page 2 Page 3