本文整理匯總了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()