当前位置: 首页>>代码示例>>Python>>正文


Python runner.DiscoverRunner方法代码示例

本文整理汇总了Python中django.test.runner.DiscoverRunner方法的典型用法代码示例。如果您正苦于以下问题:Python runner.DiscoverRunner方法的具体用法?Python runner.DiscoverRunner怎么用?Python runner.DiscoverRunner使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在django.test.runner的用法示例。


在下文中一共展示了runner.DiscoverRunner方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: _tests

# 需要导入模块: from django.test import runner [as 别名]
# 或者: from django.test.runner import DiscoverRunner [as 别名]
def _tests(self):
        settings.configure(
            DEBUG=True,
            DATABASES={
                'default': {
                    'ENGINE': 'django.db.backends.sqlite3',
                    'NAME': os.path.join(self.DIRNAME, 'database.db'),
                }
            },
            INSTALLED_APPS=self.INSTALLED_APPS + self.apps,
            MIDDLEWARE=self.MIDDLEWARE,
            ROOT_URLCONF='django_classified.tests.urls',
            STATIC_URL='/static/',
            TEMPLATES=self.TEMPLATES,
            SITE_ID=1
        )

        from django.test.runner import DiscoverRunner
        test_runner = DiscoverRunner()
        django.setup()

        failures = test_runner.run_tests(self.apps)
        if failures:
            sys.exit(failures) 
开发者ID:slyapustin,项目名称:django-classified,代码行数:26,代码来源:quicktest.py

示例2: setUp

# 需要导入模块: from django.test import runner [as 别名]
# 或者: from django.test.runner import DiscoverRunner [as 别名]
def setUp(self):
        self.dr = DiscoverRunner()
        self.old_config = self.dr.setup_databases()

        self.updatedb = UpdateDBPipeline(
            images_store='tests/fixtures/images')
        source = Source.objects.create(
            name='source',
            spider='spider',
            url='http://example.com'
        )
        SourceLanguage.objects.create(
            language='EN',
            source=source
        )
        self.spider = Spider()
        self.spider.name = 'Spider' 
开发者ID:aplanas,项目名称:kmanga,代码行数:19,代码来源:test_updatedb.py

示例3: _test_output

# 需要导入模块: from django.test import runner [as 别名]
# 或者: from django.test.runner import DiscoverRunner [as 别名]
def _test_output(self, verbosity):
        runner = DiscoverRunner(debug_sql=True, verbosity=0)
        suite = runner.test_suite()
        suite.addTest(self.FailingTest())
        suite.addTest(self.ErrorTest())
        suite.addTest(self.PassingTest())
        suite.addTest(self.PassingSubTest())
        suite.addTest(self.FailingSubTest())
        suite.addTest(self.ErrorSubTest())
        old_config = runner.setup_databases()
        stream = StringIO()
        resultclass = runner.get_resultclass()
        runner.test_runner(
            verbosity=verbosity,
            stream=stream,
            resultclass=resultclass,
        ).run(suite)
        runner.teardown_databases(old_config)

        return stream.getvalue() 
开发者ID:nesdis,项目名称:djongo,代码行数:22,代码来源:test_debug_sql.py

示例4: test_transaction_support

# 需要导入模块: from django.test import runner [as 别名]
# 或者: from django.test.runner import DiscoverRunner [as 别名]
def test_transaction_support(self):
        """Ticket #16329: sqlite3 in-memory test databases"""
        for option_key, option_value in (
                ('NAME', ':memory:'), ('TEST', {'NAME': ':memory:'})):
            tested_connections = db.ConnectionHandler({
                'default': {
                    'ENGINE': 'django.db.backends.sqlite3',
                    option_key: option_value,
                },
                'other': {
                    'ENGINE': 'django.db.backends.sqlite3',
                    option_key: option_value,
                },
            })
            with mock.patch('django.db.connections', new=tested_connections):
                with mock.patch('django.test.testcases.connections', new=tested_connections):
                    other = tested_connections['other']
                    DiscoverRunner(verbosity=0).setup_databases()
                    msg = ("DATABASES setting '%s' option set to sqlite3's ':memory:' value "
                           "shouldn't interfere with transaction support detection." % option_key)
                    # Transaction support should be properly initialized for the 'other' DB
                    self.assertTrue(other.features.supports_transactions, msg)
                    # And all the DBs should report that they support transactions
                    self.assertTrue(connections_support_transactions(), msg) 
开发者ID:nesdis,项目名称:djongo,代码行数:26,代码来源:tests.py

示例5: test_setup_aliased_default_database

# 需要导入模块: from django.test import runner [as 别名]
# 或者: from django.test.runner import DiscoverRunner [as 别名]
def test_setup_aliased_default_database(self):
        """
        setup_datebases() doesn't fail when 'default' is aliased
        """
        tested_connections = db.ConnectionHandler({
            'default': {
                'NAME': 'dummy'
            },
            'aliased': {
                'NAME': 'dummy'
            }
        })
        with mock.patch('django.test.utils.connections', new=tested_connections):
            runner_instance = DiscoverRunner(verbosity=0)
            old_config = runner_instance.setup_databases()
            runner_instance.teardown_databases(old_config) 
开发者ID:nesdis,项目名称:djongo,代码行数:18,代码来源:tests.py

示例6: test_run_checks_passes_and_teardown_raises

# 需要导入模块: from django.test import runner [as 别名]
# 或者: from django.test.runner import DiscoverRunner [as 别名]
def test_run_checks_passes_and_teardown_raises(self):
        """
        Exceptions on teardown are surfaced if no exceptions happen during
        run_checks().
        """
        with mock.patch('django.test.runner.DiscoverRunner.setup_test_environment'), \
                mock.patch('django.test.runner.DiscoverRunner.setup_databases'), \
                mock.patch('django.test.runner.DiscoverRunner.build_suite'), \
                mock.patch('django.test.runner.DiscoverRunner.run_checks'), \
                mock.patch('django.test.runner.DiscoverRunner.teardown_databases', side_effect=ValueError) \
                as teardown_databases, \
                mock.patch('django.test.runner.DiscoverRunner.teardown_test_environment') as teardown_test_environment:
            runner = DiscoverRunner(verbosity=0, interactive=False)
            with self.assertRaises(ValueError):
                # Suppress the output when running TestDjangoTestCase.
                with mock.patch('sys.stderr'):
                    runner.run_tests(['test_runner_apps.sample.tests_sample.TestDjangoTestCase'])
            self.assertTrue(teardown_databases.called)
            self.assertFalse(teardown_test_environment.called) 
开发者ID:nesdis,项目名称:djongo,代码行数:21,代码来源:tests.py

示例7: main

# 需要导入模块: from django.test import runner [as 别名]
# 或者: from django.test.runner import DiscoverRunner [as 别名]
def main(args):
    # Since this test suite is designed to be ran outside of ./manage.py test, we need to do some setup first.
    import django
    from django.conf import settings
    settings.configure(INSTALLED_APPS=['testapp'], DATABASES=DATABASES_FOR_DB[args.db], DB_NAME=args.db)
    django.setup()

    from django.test.runner import DiscoverRunner
    test_runner = DiscoverRunner(top_level=TESTS_DIR, interactive=False, keepdb=False)
    if args.testpaths:
        paths = ['tests.' + p for p in args.testpaths]
        failures = test_runner.run_tests(paths)
    else:
        failures = test_runner.run_tests(['tests'])
    if failures:
        sys.exit(1) 
开发者ID:mattiaslinnap,项目名称:django-partial-index,代码行数:18,代码来源:runner.py

示例8: setup

# 需要导入模块: from django.test import runner [as 别名]
# 或者: from django.test.runner import DiscoverRunner [as 别名]
def setup():
    global test_runner
    global old_config

    try:
        # DjangoTestSuiteRunner was deprecated in django 1.8:
        # https://docs.djangoproject.com/en/1.8/internals/deprecation/#deprecation-removed-in-1-8
        from django.test.runner import DiscoverRunner as TestSuiteRunner
    except ImportError:
        from django.test.simple import DjangoTestSuiteRunner as TestSuiteRunner

    test_runner = TestSuiteRunner()
    test_runner.setup_test_environment()
    test_runner.setup_databases() 
开发者ID:Arello-Mobile,项目名称:py2swagger,代码行数:16,代码来源:__init__.py

示例9: runtests

# 需要导入模块: from django.test import runner [as 别名]
# 或者: from django.test.runner import DiscoverRunner [as 别名]
def runtests():
    test_runner = TestRunner(verbosity=1)
    failures = test_runner.run_tests([APP])
    sys.exit(failures) 
开发者ID:kidig,项目名称:django-mailjet,代码行数:6,代码来源:runtests.py

示例10: setup_django

# 需要导入模块: from django.test import runner [as 别名]
# 或者: from django.test.runner import DiscoverRunner [as 别名]
def setup_django():
    """Provide a test database and django configuration"""
    from yawn.worker.models import Queue

    manager = runner.DiscoverRunner(verbosity=1, interactive=False)
    old_config = manager.setup_databases()

    # create the default queue outside the transaction
    Queue.get_default_queue()

    yield

    manager.teardown_databases(old_config) 
开发者ID:aclowes,项目名称:yawn,代码行数:15,代码来源:conftest.py

示例11: setup

# 需要导入模块: from django.test import runner [as 别名]
# 或者: from django.test.runner import DiscoverRunner [as 别名]
def setup():
    global test_runner
    global old_config

    from django.test.runner import DiscoverRunner
    test_runner = DiscoverRunner()
    test_runner.setup_test_environment()
    old_config = test_runner.setup_databases() 
开发者ID:ImperialCollegeLondon,项目名称:django-drf-filepond,代码行数:10,代码来源:__init__.py

示例12: run_tests

# 需要导入模块: from django.test import runner [as 别名]
# 或者: from django.test.runner import DiscoverRunner [as 别名]
def run_tests(reverse=False):
    sys.stdout.write(
        "\nRunning spirit test suite, using settings %(settings)r\n\n" %
        {"settings": os.environ['DJANGO_SETTINGS_MODULE']})
    return DiscoverRunner(reverse=reverse).run_tests([]) 
开发者ID:nitely,项目名称:Spirit,代码行数:7,代码来源:runtests.py

示例13: test_setup_databases

# 需要导入模块: from django.test import runner [as 别名]
# 或者: from django.test.runner import DiscoverRunner [as 别名]
def test_setup_databases(self):
        """
        setup_databases() doesn't fail with dummy database backend.
        """
        tested_connections = db.ConnectionHandler({})
        with mock.patch('django.test.utils.connections', new=tested_connections):
            runner_instance = DiscoverRunner(verbosity=0)
            old_config = runner_instance.setup_databases()
            runner_instance.teardown_databases(old_config) 
开发者ID:nesdis,项目名称:djongo,代码行数:11,代码来源:tests.py

示例14: setUp

# 需要导入模块: from django.test import runner [as 别名]
# 或者: from django.test.runner import DiscoverRunner [as 别名]
def setUp(self):
        self.runner_instance = DiscoverRunner(verbosity=0) 
开发者ID:nesdis,项目名称:djongo,代码行数:4,代码来源:tests.py

示例15: test_transaction_support

# 需要导入模块: from django.test import runner [as 别名]
# 或者: from django.test.runner import DiscoverRunner [as 别名]
def test_transaction_support(self):
        # Assert connections mocking is appropriately applied by preventing
        # any attempts at calling create_test_db on the global connection
        # objects.
        for connection in db.connections.all():
            create_test_db = mock.patch.object(
                connection.creation,
                'create_test_db',
                side_effect=AssertionError("Global connection object shouldn't be manipulated.")
            )
            create_test_db.start()
            self.addCleanup(create_test_db.stop)
        for option_key, option_value in (
                ('NAME', ':memory:'), ('TEST', {'NAME': ':memory:'})):
            tested_connections = db.ConnectionHandler({
                'default': {
                    'ENGINE': 'django.db.backends.sqlite3',
                    option_key: option_value,
                },
                'other': {
                    'ENGINE': 'django.db.backends.sqlite3',
                    option_key: option_value,
                },
            })
            with mock.patch('django.test.utils.connections', new=tested_connections):
                other = tested_connections['other']
                DiscoverRunner(verbosity=0).setup_databases()
                msg = (
                    "DATABASES setting '%s' option set to sqlite3's ':memory:' value "
                    "shouldn't interfere with transaction support detection." % option_key
                )
                # Transaction support is properly initialized for the 'other' DB.
                self.assertTrue(other.features.supports_transactions, msg)
                # And all the DBs report that they support transactions.
                self.assertTrue(connections_support_transactions(), msg) 
开发者ID:nesdis,项目名称:djongo,代码行数:37,代码来源:tests.py


注:本文中的django.test.runner.DiscoverRunner方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。