• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python commands.patch_for_test_db_setup函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中south.management.commands.patch_for_test_db_setup函数的典型用法代码示例。如果您正苦于以下问题:Python patch_for_test_db_setup函数的具体用法?Python patch_for_test_db_setup怎么用?Python patch_for_test_db_setup使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



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

示例1: __enter__

    def __enter__(self):
        try:
            patch_for_test_db_setup()
        except NameError:
            pass

        connection.creation.create_test_db(self.verbosity)
开发者ID:alekzvik,项目名称:django-tastydocs,代码行数:7,代码来源:views.py


示例2: switch_to_test_database

def switch_to_test_database():
    """
    Switching to the test database
    """
    logging.info("Setting up a test database ...\n")

    try:
        from south.management.commands import patch_for_test_db_setup
        patch_for_test_db_setup()
    except ImportError:
        pass

    world.test_runner = DjangoTestSuiteRunner(interactive=False)
    world.test_runner.setup_test_environment()
    world.test_db = world.test_runner.setup_databases()
    call_command('syncdb', **{
        'settings': settings.SETTINGS_MODULE,
        'interactive': False,
        'verbosity': 0
    })

    # Reload mongodb database
    settings.MONGODB_DATABASE = settings.MONGODB_TEST_DATABASE
    for model in [Document, Entry, Notification]:
        model.objects.load()
        model.objects.collection.remove()
开发者ID:msurguy,项目名称:dbpatterns,代码行数:26,代码来源:terrain.py


示例3: south_patch

 def south_patch(self):
     try:
         from south.management.commands import patch_for_test_db_setup
     except ImportError:
         pass
     else:
         patch_for_test_db_setup()
开发者ID:rvl,项目名称:django-test-extras,代码行数:7,代码来源:test.py


示例4: handle

   def handle(self, *test_labels, **options):
      """Trigger both south and selenium tests."""

      run_south_tests = bool(options.get('run_normal_tests', False))
      run_selenium_tests = bool(options.get('run_selenium_tests', False))

      # Check test types
      if (run_south_tests and run_selenium_tests or
         not run_south_tests and not run_selenium_tests):
         logger.error("You must specify exactly one of --selenium-tests and --normal-tests.")
         sys.exit(1)

      # Apply the south patch for syncdb, migrate commands during tests
      patch_for_test_db_setup()

      if run_south_tests:
         test_south.Command.handle(self, *test_labels, **options)
      elif run_selenium_tests:
         # We don't want to call any super handle function, because it will
         # try to run tests in addition to parsing command line options.
         # Instead, we parse the relevant options ourselves.
         verbosity = int(options.get('verbosity', 1))
         interactive = options.get('interactive', True)
         failfast = options.get('failfast', False)

         test_runner = SeleniumTestRunner(verbosity=verbosity, interactive=interactive, failfast=failfast)
         test_runner.selenium = True
         test_runner.selenium_only = True
         failures = test_runner.run_tests(test_labels)
         if failures:
            sys.exit(bool(failures))
开发者ID:learning-unlimited,项目名称:ESP-Website,代码行数:31,代码来源:seltest.py


示例5: runtests

def runtests():
    from south.management.commands import patch_for_test_db_setup
    patch_for_test_db_setup()
    test_runner = get_runner(settings)
    test_runner = test_runner(interactive=True, verbosity=1, failfast=False)
    failures = test_runner.run_tests([])
    sys.exit(bool(failures))
开发者ID:ManchesterIO,项目名称:mollyproject,代码行数:7,代码来源:runtests.py


示例6: handle

    def handle(self, *args, **options):
        USE_SOUTH = getattr(settings, "SOUTH_TESTS_MIGRATE", True)
        try:
            if USE_SOUTH:
                from south.management.commands import patch_for_test_db_setup
                patch_for_test_db_setup()
        except:
            USE_SOUTH = False

        self._test_runner = DjangoTestSuiteRunner(interactive=False)
        DjangoTestSuiteRunner.setup_test_environment(self._test_runner)
        self._created_db = DjangoTestSuiteRunner.setup_databases(self._test_runner)
        call_command('syncdb', verbosity=0, interactive=False,)

        if USE_SOUTH:
            call_command('migrate', verbosity=0, interactive=False,)

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

        verbosity = int(options.get('verbosity', 4))
        apps_to_run = tuple(options.get('apps', '').split(","))
        apps_to_avoid = tuple(options.get('avoid_apps', '').split(","))
        run_server = not options.get('no_server', False)
        tags = options.get('tags', None)
        server = Server(port=options['port'])

        paths = self.get_paths(args, apps_to_run, apps_to_avoid)
        if run_server:
            try:
                server.start()
            except LettuceServerException, e:
                raise SystemExit(e)
开发者ID:skoczen,项目名称:lettuce,代码行数:32,代码来源:harvest.py


示例7: __init__

    def __init__(self, *args, **kwargs):
        self.configure()
        self.cov = coverage()
        self.cov.start()
        self.packages = self.resolve_packages()

        parser = argparse.ArgumentParser()
        parser.add_argument('-a', '--autoreload', dest='autoreload',
                action='store_const', const=True, default=False,)
        parser.add_argument('-f', '--failfast', dest='failfast',
                action='store_const', const=True, default=False,)
        parser.add_argument('-l', '--label', dest='label')
        self.options = vars(parser.parse_args(sys.argv[2:]))
        sys.argv = sys.argv[:2]

        super(SetupTestSuite, self).__init__(tests=self.build_tests(),
                *args, **kwargs)

        # Setup testrunner.
        from django.test.simple import DjangoTestSuiteRunner
        self.test_runner = DjangoTestSuiteRunner(
            verbosity=1,
            interactive=True,
            failfast=False
        )
        # South patches the test management command to handle the
        # SOUTH_TESTS_MIGRATE setting. Apply that patch if South is installed.
        try:
            from south.management.commands import patch_for_test_db_setup
            patch_for_test_db_setup()
        except ImportError:
            pass
        self.test_runner.setup_test_environment()
        self.old_config = self.test_runner.setup_databases()
开发者ID:hoatle,项目名称:django-setuptest,代码行数:34,代码来源:setuptest.py


示例8: django_tests

def django_tests(verbosity, interactive, failfast, test_labels):
    import django
    from django.conf import settings

    if hasattr(django, 'setup'):
        # Django >= 1.7 requires this for setting up the application.
        django.setup()

    if django.VERSION < (1, 7):
        # must be imported after settings are set up
        from south.management.commands import patch_for_test_db_setup
        patch_for_test_db_setup()

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

    if not test_labels:
        # apps to test
        test_labels = CORE_TEST_MODULES + get_contrib_test_modules()

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

    teardown()
    return failures
开发者ID:urbanfalcon,项目名称:django-widgy,代码行数:26,代码来源:runtests.py


示例9: main

def main():
    TestRunner = get_runner(settings)
    test_runner = TestRunner(verbosity=2, failfast=False)

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

    if django.VERSION >= (1, 6, 0):
        # this is a compat hack because in django>=1.6.0 you must provide
        # module like "userena.contrib.umessages" not "umessages"
        test_modules = [
            get_app(module_name).__name__[:-7] 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)
开发者ID:behappytester,项目名称:PythonSampleCodes,代码行数:28,代码来源:runtests.py


示例10: _handle_south

def _handle_south():
    from django.conf import settings
    if 'south' in settings.INSTALLED_APPS:
        # Handle south.
        from django.core import management

        try:
            # if `south` >= 0.7.1 we can use the test helper
            from south.management.commands import patch_for_test_db_setup
        except ImportError:
            # if `south` < 0.7.1 make sure it's migrations are disabled
            management.get_commands()
            management._commands['syncdb'] = 'django.core'
        else:
            # Monkey-patch south.hacks.django_1_0.SkipFlushCommand to load
            # initial data.
            # Ref: http://south.aeracode.org/ticket/1395#comment:3
            import south.hacks.django_1_0
            from django.core.management.commands.flush import (
                Command as FlushCommand)

            class SkipFlushCommand(FlushCommand):
                def handle_noargs(self, **options):
                    # Reinstall the initial_data fixture.
                    from django.core.management import call_command
                    # `load_initial_data` got introduces with Django 1.5.
                    load_initial_data = options.get('load_initial_data', None)
                    if load_initial_data or load_initial_data is None:
                        # Reinstall the initial_data fixture.
                        call_command('loaddata', 'initial_data', **options)
                    # no-op to avoid calling flush
                    return
            south.hacks.django_1_0.SkipFlushCommand = SkipFlushCommand

            patch_for_test_db_setup()
开发者ID:saxix,项目名称:pytest_django,代码行数:35,代码来源:fixtures.py


示例11: setUp

    def setUp(self):
        # Set up the django test framework.
        os.environ['DJANGO_SETTINGS_MODULE'] = 'website.settings'
        from django.conf import settings
        from django.test.utils import setup_test_environment
        from django.db import connection
        from south.management.commands import patch_for_test_db_setup

        # If DEBUG = True, django will sometimes take different code paths.
        settings.DEBUG = False

        self.django_db = settings.DATABASE_NAME
        setup_test_environment()
        patch_for_test_db_setup()
        connection.creation.create_test_db(verbosity=0)

        # A fake cardstories service just to benefit from settings directories.
        class FakeService:
            def __init__(self, settings):
                self.settings = settings

        # Instantiate our test subject.
        self.auth = djangoauth.Plugin(FakeService({'plugins-libdir': '.',
                                                   'plugins-confdir': '../fixture'}), [])

        # Use the fake client in the plugin instead of twisted's getPage.
        self.auth.getPage = FakeTwistedWebClient().getPage
开发者ID:B-Rich,项目名称:cardstories,代码行数:27,代码来源:test_djangoauth.py


示例12: handle

	def handle(self, *fixture_labels, **options):
		from django.core.management import call_command
		from django.db import connection
		from south.management.commands import patch_for_test_db_setup

		patch_for_test_db_setup()

		verbosity = int(options.get('verbosity'))
		interactive = options.get('interactive')
		addrport = options.get('addrport')

		# Create a test database.
		db_name = connection.creation.create_test_db(verbosity=verbosity, autoclobber=not interactive)

		# Import the fixture data into the test database.
		call_command('loaddata', *fixture_labels, **{'verbosity': verbosity})

		# Run the development server. Turn off auto-reloading because it causes
		# a strange error -- it causes this handle() method to be called
		# multiple times.
		shutdown_message = '\nServer stopped.\nNote that the test database, %r, has not been deleted. You can explore it on your own.' % db_name
		use_threading = connection.features.test_db_allows_multiple_connections
		call_command('runserver',
			addrport=addrport,
			shutdown_message=shutdown_message,
			use_reloader=False,
			use_ipv6=options['use_ipv6'],
			use_threading=use_threading
		)
开发者ID:supervacuo,项目名称:data-hack-day,代码行数:29,代码来源:testserver.py


示例13: setup_databases

 def setup_databases(self):
     if 'south' in settings.INSTALLED_APPS:
         from south.management.commands import (
             patch_for_test_db_setup  # pylint: disable=F0401
         )
         patch_for_test_db_setup()
     return super(CITestSuiteRunner, self).setup_databases()
开发者ID:chriscabral,项目名称:django-jenkins,代码行数:7,代码来源:runner.py


示例14: handle

 def handle(self, *args, **options):
     
     # Replace the DB name with test DB name in main settings
     # since this is what destroy_test_db looks for to determine
     # the name of the test_db.
     for alias in connections:
         connection = connections[alias]
         original_name = connection.settings_dict['NAME']
         if connection.settings_dict['TEST_NAME']:
             test_database_name = connection.settings_dict['TEST_NAME']
         else:
             test_database_name = TEST_DATABASE_PREFIX + connection.settings_dict['NAME']
         connection.settings_dict['NAME'] = test_database_name
         
         # try to delete db if it already exists, so we can recreate.
         try:
             connection.creation.destroy_test_db(original_name)
         except Exception, e:
             pass
         
         # check if we have south installed, and so overide syncdb so 
         # we also run migrations. Uses same method as south's test 
         # command override.
         try:
             from south.management.commands import patch_for_test_db_setup
         except ImportError:
             patch_for_test_db_setup = lambda: None
         
         patch_for_test_db_setup()
         connection.creation.create_test_db()
开发者ID:kanevski,项目名称:django_testfast,代码行数:30,代码来源:testfast_reset.py


示例15: setup_databases

    def setup_databases(self, verbosity, autoclobber, **kwargs):
        # Taken from Django 1.2 code, (C) respective Django authors. Modified for backward compatibility by me
        connections = self._get_databases()
        old_names = []
        mirrors = []

        from django.conf import settings
        if 'south' in settings.INSTALLED_APPS:
            from south.management.commands import patch_for_test_db_setup

            settings.SOUTH_TESTS_MIGRATE = getattr(settings, 'DST_RUN_SOUTH_MIGRATIONS', True)
            patch_for_test_db_setup()

        for alias in connections:
            connection = connections[alias]
            # If the database is a test mirror, redirect it's connection
            # instead of creating a test database.
            if 'TEST_MIRROR' in connection.settings_dict and connection.settings_dict['TEST_MIRROR']:
                mirrors.append((alias, connection))
                mirror_alias = connection.settings_dict['TEST_MIRROR']
                connections._connections[alias] = connections[mirror_alias]
            else:
                if 'NAME' in connection.settings_dict:
                    old_names.append((connection, connection.settings_dict['NAME']))
                else:
                    old_names.append((connection, connection.settings_dict['DATABASE_NAME']))
                connection.creation.create_test_db(verbosity=verbosity, autoclobber=autoclobber)
        return old_names, mirrors
开发者ID:akaihola,项目名称:django-sane-testing,代码行数:28,代码来源:noseplugins.py


示例16: handle

    def handle(self, *test_labels, **options):
        from django.conf import settings
        from django.test.utils import get_runner
        patch_for_test_db_setup()
        
        test_labels = ('locations', 'parsed_xforms', \
                    'nga_districts', 'phone_manager', 'surveyor_manager', \
                    'xform_manager', 'map_xforms', 'submission_qr',)
        
        verbosity = int(options.get('verbosity', 1))
        interactive = options.get('interactive', True)
        failfast = options.get('failfast', False)
        TestRunner = get_runner(settings)
        
        if hasattr(TestRunner, 'func_name'):
            # Pre 1.2 test runners were merely 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.',
                PendingDeprecationWarning
            )
            failures = TestRunner(test_labels, verbosity=verbosity, interactive=interactive)
        else:
            test_runner = TestRunner(verbosity=verbosity, interactive=interactive, failfast=failfast)
            failures = test_runner.run_tests(test_labels)

        if failures:
            sys.exit(bool(failures))
开发者ID:mvpdev,项目名称:nmis,代码行数:29,代码来源:test_all.py


示例17: runtests

def runtests(verbosity=1, interactive=False, failfast=False, *test_args):
    if 'south' in settings.INSTALLED_APPS:
        from south.management.commands import patch_for_test_db_setup
        patch_for_test_db_setup()


    test_runner = UnaccentDjangoTestSuiteRunner(verbosity=verbosity, interactive=interactive, failfast=failfast)
    return test_runner.run_tests(test_labels=None, extra_tests=None)
开发者ID:afatless,项目名称:django-unaccent,代码行数:8,代码来源:runtests_with_settings.py


示例18: setup_django_test_database

def setup_django_test_database():
    from django.test.simple import DjangoTestSuiteRunner
    from django.test.utils import setup_test_environment
    from south.management.commands import patch_for_test_db_setup
    runner = DjangoTestSuiteRunner(verbosity=0, failfast=False)
    patch_for_test_db_setup()
    setup_test_environment()
    return runner, runner.setup_databases()
开发者ID:mangroveorg,项目名称:vumi,代码行数:8,代码来源:utils.py


示例19: main

def main():
    if 'south' in settings.INSTALLED_APPS:
        from south.management.commands import patch_for_test_db_setup
        patch_for_test_db_setup()

    test_runner = get_runner(settings)(interactive=False, verbosity=2)
    failures = test_runner.run_tests(['peavy'])
    sys.exit(failures)
开发者ID:facconi,项目名称:django-peavy,代码行数:8,代码来源:tests.py


示例20: main

def main():
    from django.test.utils import get_runner
    from south.management.commands import patch_for_test_db_setup

    patch_for_test_db_setup()
    test_runner = get_runner(settings)(interactive=False)
    failures = test_runner.run_tests([app.split('.')[-1] for app in TEST_APPS])
    sys.exit(failures)
开发者ID:ForkLab,项目名称:lemon,代码行数:8,代码来源:tests.py



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python migration.migrate_app函数代码示例发布时间:2022-05-27
下一篇:
Python db.start_transaction函数代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap