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.

200 Examples 7

Example 1

Project: django-fancy-cache
Source File: runtests.py
View license
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 2

Project: GAE-Bulk-Mailer
Source File: test.py
View license
    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 3

Project: GAE-Bulk-Mailer
Source File: test.py
View license
    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 4

Project: PyClassLessons
Source File: test.py
View license
    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 5

Project: PyClassLessons
Source File: test.py
View license
    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 6

Project: django-konfera
Source File: runtests.py
View license
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 7

Project: dj-ango
Source File: runtests.py
View license
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 8

Project: dj-spam
Source File: runtests.py
View license
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 9

Project: dj-paginator
Source File: runtests.py
View license
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 10

Project: rapidsms
Source File: run_tests.py
View license
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 11

Project: django-friendship
Source File: runtests.py
View license
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 12

Project: django-test-plus
Source File: runtests.py
View license
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 13

Project: performant-pagination
Source File: runtests.py
View license
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 14

Project: django-fancy-cronfield
Source File: runtests.py
View license
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 15

Project: Django--an-app-at-a-time
Source File: test.py
View license
    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 16

Project: django_uncertainty
Source File: runtests.py
View license
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 17

Project: django-systemjs
Source File: runtests.py
View license
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 18

Project: callisto-core
Source File: runtests.py
View license
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 19

Project: django-rest-utils
Source File: runtests.py
View license
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 20

Project: splunk-webframework
Source File: test.py
View license
    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 21

Project: splunk-webframework
Source File: test.py
View license
    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 22

Project: xadmin
Source File: runtests.py
View license
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 23

Project: django-ticketing
Source File: runtests.py
View license
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 24

Project: django-celery-ses
Source File: runtests.py
View license
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 25

Project: django-password-policies
Source File: tests.py
View license
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 26

Project: django-hitcount
Source File: runtests.py
View license
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 27

Project: django-rest-auth
Source File: runtests.py
View license
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 28

Project: votes
Source File: runtests.py
View license
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 29

Project: ion
Source File: test_suite.py
View license
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 30

Project: django-subdomains
Source File: __init__.py
View license
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 31

Project: django-revproxy
Source File: run.py
View license
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 32

View license
    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 33

View license
    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 34

View license
    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 35

Project: django-dockit
Source File: setuptest.py
View license
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 36

Project: django-hyperadmin
Source File: runtests.py
View license
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 37

Project: drf-to-s3
Source File: runtests.py
View license
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 38

Project: django-seed
Source File: runtests.py
View license
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 39

Project: django-input-mask
Source File: runtests.py
View license
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))

Example 40

Project: django-email-bandit
Source File: runtests.py
View license
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 41

Project: django-scribbler
Source File: runtests.py
View license
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 42

Project: django-sticky-uploads
Source File: runtests.py
View license
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 43

Project: django-timepiece
Source File: run_tests.py
View license
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 44

Project: django-treenav
Source File: runtests.py
View license
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 45

Project: rapidsms-appointments
Source File: runtests.py
View license
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 46

Project: rapidsms-twilio
Source File: runtests.py
View license
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 47

Project: cgstudiomap
Source File: test.py
View license
    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 48

Project: ADL_LRS
Source File: runtests.py
View license
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 49

Project: hue
Source File: test.py
View license
    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 50

Project: hue
Source File: test.py
View license
    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))