當前位置: 首頁>>代碼示例>>Python>>正文


Python utils.get_runner方法代碼示例

本文整理匯總了Python中django.test.utils.get_runner方法的典型用法代碼示例。如果您正苦於以下問題:Python utils.get_runner方法的具體用法?Python utils.get_runner怎麽用?Python utils.get_runner使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在django.test.utils的用法示例。


在下文中一共展示了utils.get_runner方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: runtests

# 需要導入模塊: from django.test import utils [as 別名]
# 或者: from django.test.utils import get_runner [as 別名]
def runtests():
    os.environ['DJANGO_SETTINGS_MODULE'] = 'tests.test_settings'
    django.setup()

    TestRunner = get_runner(settings)
    test_runner = TestRunner()

    # By default, run all of the tests
    tests = ['tests']

    # Allow running a subset of tests via the command line.
    if len(sys.argv) > 1:
        tests = sys.argv[1:]

    failures = test_runner.run_tests(tests, verbosity=3)
    if failures:
        sys.exit(failures) 
開發者ID:TAXIIProject,項目名稱:django-taxii-services,代碼行數:19,代碼來源:runtests.py

示例2: run_tests

# 需要導入模塊: from django.test import utils [as 別名]
# 或者: from django.test.utils import get_runner [as 別名]
def run_tests(self):
        import django
        django.setup()

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

        TestRunner = get_runner(settings, self.testrunner)

        test_runner = TestRunner(
            pattern=self.pattern,
            top_level=self.top_level_directory,
            verbosity=self.verbose,
            interactive=(not self.noinput),
            failfast=self.failfast,
            keepdb=self.keepdb,
            reverse=self.reverse,
            debug_sql=self.debug_sql,
            output_dir=self.output_dir)
        failures = test_runner.run_tests(self.test_labels)

        sys.exit(bool(failures)) 
開發者ID:georgemarshall,項目名稱:django-cryptography,代碼行數:24,代碼來源:setup.py

示例3: run_tests_coverage

# 需要導入模塊: from django.test import utils [as 別名]
# 或者: from django.test.utils import get_runner [as 別名]
def run_tests_coverage():
    if __name__ == "__main__":
        os.environ['DJANGO_SETTINGS_MODULE'] = 'tests.settings'
        django.setup()
        TestRunner = get_runner(settings)
        test_runner = TestRunner()

        # Setup Coverage
        cov = coverage(source=["rest_framework_docs"], omit=["rest_framework_docs/__init__.py"])
        cov.start()

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

        if bool(failures):
            cov.erase()
            sys.exit("Tests Failed. Coverage Cancelled.")

        # If success show coverage results
        cov.stop()
        cov.save()
        cov.report()
        cov.html_report(directory='covhtml') 
開發者ID:manosim,項目名稱:django-rest-framework-docs,代碼行數:24,代碼來源:runtests.py

示例4: run_tests

# 需要導入模塊: from django.test import utils [as 別名]
# 或者: from django.test.utils import get_runner [as 別名]
def run_tests():
    # Making Django run this way is a two-step process. First, call
    # settings.configure() to give Django settings to work with:
    from django.conf import settings

    settings.configure(**SETTINGS_DICT)

    # Then, call django.setup() to initialize the application registry
    # and other bits:
    import django

    django.setup()

    # Now we instantiate a test runner...
    from django.test.utils import get_runner

    TestRunner = get_runner(settings)

    # And then we run tests and return the results.
    test_runner = TestRunner(verbosity=2, interactive=True)
    failures = test_runner.run_tests(["tests"])
    sys.exit(failures) 
開發者ID:ubernostrum,項目名稱:pwned-passwords-django,代碼行數:24,代碼來源:runtests.py

示例5: run

# 需要導入模塊: from django.test import utils [as 別名]
# 或者: from django.test.utils import get_runner [as 別名]
def run():
    """Run tests with Django setup."""
    os.environ['DJANGO_SETTINGS_MODULE'] = 'tests.settings'
    from django.conf import settings

    # Will only work in 1.7
    try:
        from django import setup
    except ImportError:
        pass
    else:
        setup()

    from django.test.utils import get_runner

    TestRunner = get_runner(settings)
    test_runner = TestRunner()
    failures = test_runner.run_tests(["tests"])
    sys.exit(bool(failures)) 
開發者ID:JamesRitchie,項目名稱:django-rest-framework-expiring-tokens,代碼行數:21,代碼來源:runtests.py

示例6: run_tests

# 需要導入模塊: from django.test import utils [as 別名]
# 或者: from django.test.utils import get_runner [as 別名]
def run_tests():
    # First configure settings, then call django.setup() to initialise
    from django.conf import settings

    settings.configure(**SETTINGS_DICT)
    import django

    django.setup()

    # Now create the test runner
    from django.test.utils import get_runner

    TestRunner = get_runner(settings)

    # And then we run tests and return the results.
    test_runner = TestRunner(verbosity=2, interactive=True)
    failures = test_runner.run_tests(["tests"])
    sys.exit(failures) 
開發者ID:kogan,項目名稱:django-subscriptions,代碼行數:20,代碼來源:runtests.py

示例7: main

# 需要導入模塊: from django.test import utils [as 別名]
# 或者: from django.test.utils import get_runner [as 別名]
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) 
開發者ID:metabolize,項目名稱:drf-to-s3,代碼行數:20,代碼來源:runtests.py

示例8: run_tests

# 需要導入模塊: from django.test import utils [as 別名]
# 或者: from django.test.utils import get_runner [as 別名]
def run_tests(*args, **kwargs):
    os.environ['DJANGO_SETTINGS_MODULE'] = 'tests.settings'
    django.setup()
    TestRunner = get_runner(settings)
    test_runner = TestRunner(**kwargs)
    failures = test_runner.run_tests(args)
    try:
        os.remove('./celerybeat-schedule.bak')
    except Exception:
        pass

    try:
        os.remove('./celerybeat-schedule.dat')
    except Exception:
        pass

    try:
        os.remove('./celerybeat-schedule.dir')
    except Exception:
        pass
        
    sys.exit(bool(failures)) 
開發者ID:vintasoftware,項目名稱:django-celerybeat-status,代碼行數:24,代碼來源:runtests.py

示例9: handle

# 需要導入模塊: from django.test import utils [as 別名]
# 或者: from django.test.utils import get_runner [as 別名]
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)) 
開發者ID:blackye,項目名稱:luscan-devel,代碼行數:18,代碼來源:test.py

示例10: runtests

# 需要導入模塊: from django.test import utils [as 別名]
# 或者: from django.test.utils import get_runner [as 別名]
def runtests():
    """
    The test runner for setup.py test usage. This sets up
    a memory database with sqlite3 and runs the tests via
    the django test command.
    """
    from conf import settings
    settings = settings(
        DATABASE_ENGINE='sqlite3',
        DATABASE_NAME=':memory:',
    )

    from django.test.utils import get_runner
    test_runner = get_runner(settings)
    failures = test_runner([], verbosity=1, interactive=True)
    raise SystemExit(failures) 
開發者ID:blackye,項目名稱:luscan-devel,代碼行數:18,代碼來源:runtests.py

示例11: main

# 需要導入模塊: from django.test import utils [as 別名]
# 或者: from django.test.utils import get_runner [as 別名]
def main():
    settings.configure(
        ROOT_URLCONF='wsrequest.tests',
        INSTALLED_APPS=[
            'django.contrib.auth',
            'django.contrib.contenttypes',
            'django.contrib.sessions',
        ],
        DATABASES={
            'default': {
                'ENGINE': 'django.db.backends.sqlite3',
                'NAME':  'db.sqlite3',
            }
        }
    )

    from django.test.utils import get_runner

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

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

    sys.exit(failures) 
開發者ID:GetBlimp,項目名稱:django-websocket-request,代碼行數:25,代碼來源:run_tests.py

示例12: make_test_runner

# 需要導入模塊: from django.test import utils [as 別名]
# 或者: from django.test.utils import get_runner [as 別名]
def make_test_runner(verbosity, interactive, failfast, keepdb, reverse,
                     debug_sql, parallel, tags, exclude_tags):
    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,
        keepdb=keepdb,
        reverse=reverse,
        debug_sql=debug_sql,
        parallel=actual_test_processes(parallel),
        tags=tags,
        exclude_tags=exclude_tags,
    )
    return test_runner 
開發者ID:nesdis,項目名稱:djongo,代碼行數:20,代碼來源:setup_tests.py

示例13: runDjangoTest

# 需要導入模塊: from django.test import utils [as 別名]
# 或者: from django.test.utils import get_runner [as 別名]
def runDjangoTest():
    cleanMedia()
    verbosity = 1
    if "-v" in sys.argv or "--verbose" in sys.argv:
        verbosity = 2
    django.setup()
    TestRunner = get_runner(settings)
    test_runner = TestRunner(top_level="ls/joyous",
                             verbosity=verbosity,
                             keepdb=True)
    labels = ["ls.joyous.tests."+arg for arg in sys.argv[1:]
              if not arg.startswith("-")]
    if not labels:
        labels = ["ls.joyous.tests"]
    failures = test_runner.run_tests(labels)
    return failures 
開發者ID:linuxsoftware,項目名稱:ls.joyous,代碼行數:18,代碼來源:runtests.py

示例14: main

# 需要導入模塊: from django.test import utils [as 別名]
# 或者: from django.test.utils import get_runner [as 別名]
def main():
    try:
        django.setup()
    except AttributeError:
        pass
    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 = 'unsubscribe.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], verbosity=1, interactive=True)

    sys.exit(failures) 
開發者ID:theskumar,項目名稱:django-unsubscribe,代碼行數:27,代碼來源:runtests.py

示例15: run_tests

# 需要導入模塊: from django.test import utils [as 別名]
# 或者: from django.test.utils import get_runner [as 別名]
def run_tests(*test_args):
    if not test_args:
        test_args = ['tests']

    os.environ['DJANGO_SETTINGS_MODULE'] = 'tests.settings'
    django.setup()
    TestRunner = get_runner(settings)
    test_runner = TestRunner()
    failures = test_runner.run_tests(test_args)
    sys.exit(bool(failures)) 
開發者ID:jmrivas86,項目名稱:django-json-widget,代碼行數:12,代碼來源:runtests.py


注:本文中的django.test.utils.get_runner方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。