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


Python setting_changed.send方法代码示例

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


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

示例1: enable

# 需要导入模块: from django.test.signals import setting_changed [as 别名]
# 或者: from django.test.signals.setting_changed import send [as 别名]
def enable(self):
        # Keep this code at the beginning to leave the settings unchanged
        # in case it raises an exception because INSTALLED_APPS is invalid.
        if 'INSTALLED_APPS' in self.options:
            try:
                apps.set_installed_apps(self.options['INSTALLED_APPS'])
            except Exception:
                apps.unset_installed_apps()
                raise
        override = UserSettingsHolder(settings._wrapped)
        for key, new_value in self.options.items():
            setattr(override, key, new_value)
        self.wrapped = settings._wrapped
        settings._wrapped = override
        for key, new_value in self.options.items():
            setting_changed.send(sender=settings._wrapped.__class__,
                                 setting=key, value=new_value, enter=True) 
开发者ID:lanbing510,项目名称:GTDWeb,代码行数:19,代码来源:utils.py

示例2: instrumented_test_render

# 需要导入模块: from django.test.signals import setting_changed [as 别名]
# 或者: from django.test.signals.setting_changed import send [as 别名]
def instrumented_test_render(self, context):
    """
    An instrumented Template render method, providing a signal
    that can be intercepted by the test system Client
    """
    template_rendered.send(sender=self, template=self, context=context)
    return self.nodelist.render(context) 
开发者ID:lanbing510,项目名称:GTDWeb,代码行数:9,代码来源:utils.py

示例3: disable

# 需要导入模块: from django.test.signals import setting_changed [as 别名]
# 或者: from django.test.signals.setting_changed import send [as 别名]
def disable(self):
        if 'INSTALLED_APPS' in self.options:
            apps.unset_installed_apps()
        settings._wrapped = self.wrapped
        del self.wrapped
        for key in self.options:
            new_value = getattr(settings, key, None)
            setting_changed.send(sender=settings._wrapped.__class__,
                                 setting=key, value=new_value, enter=False) 
开发者ID:lanbing510,项目名称:GTDWeb,代码行数:11,代码来源:utils.py

示例4: _pre_setup

# 需要导入模块: from django.test.signals import setting_changed [as 别名]
# 或者: from django.test.signals.setting_changed import send [as 别名]
def _pre_setup(self):
        """Performs any pre-test setup. This includes:

        * If the class has an 'available_apps' attribute, restricting the app
          registry to these applications, then firing post_migrate -- it must
          run with the correct set of applications for the test case.
        * If the class has a 'fixtures' attribute, installing these fixtures.
        """
        super(TransactionTestCase, self)._pre_setup()
        if self.available_apps is not None:
            apps.set_available_apps(self.available_apps)
            setting_changed.send(sender=settings._wrapped.__class__,
                                 setting='INSTALLED_APPS',
                                 value=self.available_apps,
                                 enter=True)
            for db_name in self._databases_names(include_mirrors=False):
                flush.Command.emit_post_migrate(verbosity=0, interactive=False, database=db_name)
        try:
            self._fixture_setup()
        except Exception:
            if self.available_apps is not None:
                apps.unset_available_apps()
                setting_changed.send(sender=settings._wrapped.__class__,
                                     setting='INSTALLED_APPS',
                                     value=settings.INSTALLED_APPS,
                                     enter=False)

            raise 
开发者ID:lanbing510,项目名称:GTDWeb,代码行数:30,代码来源:testcases.py

示例5: _post_teardown

# 需要导入模块: from django.test.signals import setting_changed [as 别名]
# 或者: from django.test.signals.setting_changed import send [as 别名]
def _post_teardown(self):
        """Performs any post-test things. This includes:

        * Flushing the contents of the database, to leave a clean slate. If
          the class has an 'available_apps' attribute, post_migrate isn't fired.
        * Force-closing the connection, so the next test gets a clean cursor.
        """
        try:
            self._fixture_teardown()
            super(TransactionTestCase, self)._post_teardown()
            if self._should_reload_connections():
                # Some DB cursors include SQL statements as part of cursor
                # creation. If you have a test that does a rollback, the effect
                # of these statements is lost, which can affect the operation of
                # tests (e.g., losing a timezone setting causing objects to be
                # created with the wrong time). To make sure this doesn't
                # happen, get a clean connection at the start of every test.
                for conn in connections.all():
                    conn.close()
        finally:
            if self.available_apps is not None:
                apps.unset_available_apps()
                setting_changed.send(sender=settings._wrapped.__class__,
                                     setting='INSTALLED_APPS',
                                     value=settings.INSTALLED_APPS,
                                     enter=False) 
开发者ID:lanbing510,项目名称:GTDWeb,代码行数:28,代码来源:testcases.py

示例6: instrumented_test_render

# 需要导入模块: from django.test.signals import setting_changed [as 别名]
# 或者: from django.test.signals.setting_changed import send [as 别名]
def instrumented_test_render(self, context):
    """
    An instrumented Template render method, providing a signal that can be
    intercepted by the test Client.
    """
    template_rendered.send(sender=self, template=self, context=context)
    return self.nodelist.render(context) 
开发者ID:reBiocoder,项目名称:bioforum,代码行数:9,代码来源:utils.py

示例7: _pre_setup

# 需要导入模块: from django.test.signals import setting_changed [as 别名]
# 或者: from django.test.signals.setting_changed import send [as 别名]
def _pre_setup(self):
        """
        Perform pre-test setup:
        * If the class has an 'available_apps' attribute, restrict the app
          registry to these applications, then fire the post_migrate signal --
          it must run with the correct set of applications for the test case.
        * If the class has a 'fixtures' attribute, install those fixtures.
        """
        super()._pre_setup()
        if self.available_apps is not None:
            apps.set_available_apps(self.available_apps)
            setting_changed.send(
                sender=settings._wrapped.__class__,
                setting='INSTALLED_APPS',
                value=self.available_apps,
                enter=True,
            )
            for db_name in self._databases_names(include_mirrors=False):
                emit_post_migrate_signal(verbosity=0, interactive=False, db=db_name)
        try:
            self._fixture_setup()
        except Exception:
            if self.available_apps is not None:
                apps.unset_available_apps()
                setting_changed.send(
                    sender=settings._wrapped.__class__,
                    setting='INSTALLED_APPS',
                    value=settings.INSTALLED_APPS,
                    enter=False,
                )
            raise
        # Clear the queries_log so that it's less likely to overflow (a single
        # test probably won't execute 9K queries). If queries_log overflows,
        # then assertNumQueries() doesn't work.
        for db_name in self._databases_names(include_mirrors=False):
            connections[db_name].queries_log.clear() 
开发者ID:reBiocoder,项目名称:bioforum,代码行数:38,代码来源:testcases.py

示例8: _post_teardown

# 需要导入模块: from django.test.signals import setting_changed [as 别名]
# 或者: from django.test.signals.setting_changed import send [as 别名]
def _post_teardown(self):
        """
        Perform post-test things:
        * Flush the contents of the database to leave a clean slate. If the
          class has an 'available_apps' attribute, don't fire post_migrate.
        * Force-close the connection so the next test gets a clean cursor.
        """
        try:
            self._fixture_teardown()
            super()._post_teardown()
            if self._should_reload_connections():
                # Some DB cursors include SQL statements as part of cursor
                # creation. If you have a test that does a rollback, the effect
                # of these statements is lost, which can affect the operation of
                # tests (e.g., losing a timezone setting causing objects to be
                # created with the wrong time). To make sure this doesn't
                # happen, get a clean connection at the start of every test.
                for conn in connections.all():
                    conn.close()
        finally:
            if self.available_apps is not None:
                apps.unset_available_apps()
                setting_changed.send(sender=settings._wrapped.__class__,
                                     setting='INSTALLED_APPS',
                                     value=settings.INSTALLED_APPS,
                                     enter=False) 
开发者ID:reBiocoder,项目名称:bioforum,代码行数:28,代码来源:testcases.py

示例9: _pre_setup

# 需要导入模块: from django.test.signals import setting_changed [as 别名]
# 或者: from django.test.signals.setting_changed import send [as 别名]
def _pre_setup(self):
        """Performs any pre-test setup. This includes:

        * If the class has an 'available_apps' attribute, restricting the app
          registry to these applications, then firing post_migrate -- it must
          run with the correct set of applications for the test case.
        * If the class has a 'fixtures' attribute, installing these fixtures.
        """
        super(TransactionTestCase, self)._pre_setup()
        if self.available_apps is not None:
            apps.set_available_apps(self.available_apps)
            setting_changed.send(
                sender=settings._wrapped.__class__,
                setting='INSTALLED_APPS',
                value=self.available_apps,
                enter=True,
            )
            for db_name in self._databases_names(include_mirrors=False):
                emit_post_migrate_signal(verbosity=0, interactive=False, db=db_name)
        try:
            self._fixture_setup()
        except Exception:
            if self.available_apps is not None:
                apps.unset_available_apps()
                setting_changed.send(
                    sender=settings._wrapped.__class__,
                    setting='INSTALLED_APPS',
                    value=settings.INSTALLED_APPS,
                    enter=False,
                )
            raise 
开发者ID:Yeah-Kun,项目名称:python,代码行数:33,代码来源:testcases.py

示例10: enable

# 需要导入模块: from django.test.signals import setting_changed [as 别名]
# 或者: from django.test.signals.setting_changed import send [as 别名]
def enable(self):
        override = UserSettingsHolder(settings._wrapped)
        for key, new_value in self.options.items():
            setattr(override, key, new_value)
        settings._wrapped = override
        for key, new_value in self.options.items():
            setting_changed.send(sender=settings._wrapped.__class__,
                                 setting=key, value=new_value) 
开发者ID:blackye,项目名称:luscan-devel,代码行数:10,代码来源:utils.py

示例11: disable

# 需要导入模块: from django.test.signals import setting_changed [as 别名]
# 或者: from django.test.signals.setting_changed import send [as 别名]
def disable(self):
        settings._wrapped = self.wrapped
        for key in self.options:
            new_value = getattr(settings, key, None)
            setting_changed.send(sender=settings._wrapped.__class__,
                                 setting=key, value=new_value) 
开发者ID:blackye,项目名称:luscan-devel,代码行数:8,代码来源:utils.py

示例12: _pre_setup

# 需要导入模块: from django.test.signals import setting_changed [as 别名]
# 或者: from django.test.signals.setting_changed import send [as 别名]
def _pre_setup(self):
        """Performs any pre-test setup. This includes:

        * If the class has an 'available_apps' attribute, restricting the app
          registry to these applications, then firing post_migrate -- it must
          run with the correct set of applications for the test case.
        * If the class has a 'fixtures' attribute, installing these fixtures.
        """
        super(TransactionTestCase, self)._pre_setup()
        if self.available_apps is not None:
            apps.set_available_apps(self.available_apps)
            setting_changed.send(sender=settings._wrapped.__class__,
                                 setting='INSTALLED_APPS',
                                 value=self.available_apps,
                                 enter=True)
            for db_name in self._databases_names(include_mirrors=False):
                emit_post_migrate_signal(verbosity=0, interactive=False, db=db_name)
        try:
            self._fixture_setup()
        except Exception:
            if self.available_apps is not None:
                apps.unset_available_apps()
                setting_changed.send(sender=settings._wrapped.__class__,
                                     setting='INSTALLED_APPS',
                                     value=settings.INSTALLED_APPS,
                                     enter=False)

            raise 
开发者ID:drexly,项目名称:openhgsenti,代码行数:30,代码来源:testcases.py


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