本文整理汇总了Python中django.test.TransactionTestCase方法的典型用法代码示例。如果您正苦于以下问题:Python test.TransactionTestCase方法的具体用法?Python test.TransactionTestCase怎么用?Python test.TransactionTestCase使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类django.test
的用法示例。
在下文中一共展示了test.TransactionTestCase方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: _pre_setup
# 需要导入模块: from django import test [as 别名]
# 或者: from django.test import TransactionTestCase [as 别名]
def _pre_setup(self):
"""Disable transaction methods, and clear some globals."""
# Repeat stuff from TransactionTestCase, because I'm not calling its
# _pre_setup, because that would load fixtures again.
cache.cache.clear()
settings.TEMPLATE_DEBUG = settings.DEBUG = False
self.client = self.client_class()
#self._fixture_setup()
self._urlconf_setup()
mail.outbox = []
# Clear site cache in case somebody's mutated Site objects and then
# cached the mutated stuff:
from django.contrib.sites.models import Site
Site.objects.clear_cache()
示例2: setUp
# 需要导入模块: from django import test [as 别名]
# 或者: from django.test import TransactionTestCase [as 别名]
def setUp(self):
# Required to create root collection because the TransactionTestCase
# does not make initial data loaded in migrations available and
# serialized_rollback=True causes other problems in the test suite.
# ref: https://docs.djangoproject.com/en/1.10/topics/testing/overview/#rollback-emulation
Collection.objects.get_or_create(
name="Root",
path='0001',
depth=1,
numchild=0,
)
#: Sadly signal receivers only get connected when starting django.
#: We will re-attach them here to mimic the django startup behavior
#: and get the signals connected to our custom model..
signal_handlers.register_signal_handlers()
示例3: build_suite
# 需要导入模块: from django import test [as 别名]
# 或者: from django.test import TransactionTestCase [as 别名]
def build_suite(self, *args, **kwargs):
"""
Check if any of the tests to run subclasses TransactionTestCase.
"""
suite = super(NoDatabaseMixin, self).build_suite(*args, **kwargs)
self._needs_db = any([isinstance(test, TransactionTestCase) for test in suite])
return suite
示例4: __init__
# 需要导入模块: from django import test [as 别名]
# 或者: from django.test import TransactionTestCase [as 别名]
def __init__(self, *args, **kargs):
super(TransactionTestCase, self).__init__(*args, **kargs)
self.client = NetworkAPITestClient()