本文整理匯總了Python中django.test.signals.template_rendered.connect方法的典型用法代碼示例。如果您正苦於以下問題:Python template_rendered.connect方法的具體用法?Python template_rendered.connect怎麽用?Python template_rendered.connect使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類django.test.signals.template_rendered
的用法示例。
在下文中一共展示了template_rendered.connect方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: create_test_databases
# 需要導入模塊: from django.test.signals import template_rendered [as 別名]
# 或者: from django.test.signals.template_rendered import connect [as 別名]
def create_test_databases(worker_id: int) -> None:
database_id = get_database_id(worker_id)
for alias in connections:
connection = connections[alias]
connection.creation.clone_test_db(
suffix=database_id,
keepdb=True,
)
settings_dict = connection.creation.get_test_db_clone_settings(database_id)
# connection.settings_dict must be updated in place for changes to be
# reflected in django.db.connections. If the following line assigned
# connection.settings_dict = settings_dict, new threads would connect
# to the default database instead of the appropriate clone.
connection.settings_dict.update(settings_dict)
connection.close()
示例2: __enter__
# 需要導入模塊: from django.test.signals import template_rendered [as 別名]
# 或者: from django.test.signals.template_rendered import connect [as 別名]
def __enter__(self):
template_rendered.connect(self.on_template_render)
return self
示例3: __init__
# 需要導入模塊: from django.test.signals import template_rendered [as 別名]
# 或者: from django.test.signals.template_rendered import connect [as 別名]
def __init__(self, *args: Any, **kwargs: Any) -> None:
DiscoverRunner.__init__(self, *args, **kwargs)
# `templates_rendered` holds templates which were rendered
# in proper logical tests.
self.templates_rendered: Set[str] = set()
# `shallow_tested_templates` holds templates which were rendered
# in `zerver.tests.test_templates`.
self.shallow_tested_templates: Set[str] = set()
template_rendered.connect(self.on_template_rendered)
示例4: __exit__
# 需要導入模塊: from django.test.signals import template_rendered [as 別名]
# 或者: from django.test.signals.template_rendered import connect [as 別名]
def __exit__(self, exc_type, exc_value, traceback):
self.connection.use_debug_cursor = self.old_debug_cursor
request_started.connect(reset_queries)
if exc_type is not None:
return
final_queries = len(self.connection.queries)
executed = final_queries - self.starting_queries
self.test_case.assertEqual(
executed, self.num, "%d queries executed, %d expected" % (
executed, self.num
)
)
示例5: __init__
# 需要導入模塊: from django.test.signals import template_rendered [as 別名]
# 或者: from django.test.signals.template_rendered import connect [as 別名]
def __init__(self, *args, **kwargs):
super(self.__class__, self).__init__(*args, **kwargs)
self.templates = []
template_rendered.connect(self._store_template_info)