當前位置: 首頁>>代碼示例>>Python>>正文


Python unittest.TestCase方法代碼示例

本文整理匯總了Python中django.utils.unittest.TestCase方法的典型用法代碼示例。如果您正苦於以下問題:Python unittest.TestCase方法的具體用法?Python unittest.TestCase怎麽用?Python unittest.TestCase使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在django.utils.unittest的用法示例。


在下文中一共展示了unittest.TestCase方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: build_suite

# 需要導入模塊: from django.utils import unittest [as 別名]
# 或者: from django.utils.unittest import TestCase [as 別名]
def build_suite(self, test_labels, extra_tests=None, **kwargs):
        suite = unittest.TestSuite()

        if test_labels:
            for label in test_labels:
                if '.' in label:
                    suite.addTest(build_test(label))
                else:
                    app = get_app(label)
                    suite.addTest(build_suite(app))
        else:
            for app in get_apps():
                suite.addTest(build_suite(app))

        if extra_tests:
            for test in extra_tests:
                suite.addTest(test)

        return reorder_suite(suite, (unittest.TestCase,)) 
開發者ID:znick,項目名稱:anytask,代碼行數:21,代碼來源:simple.py

示例2: _fixture_setup

# 需要導入模塊: from django.utils import unittest [as 別名]
# 或者: from django.utils.unittest import TestCase [as 別名]
def _fixture_setup(self):
        if not connections_support_transactions():
            return super(TestCase, self)._fixture_setup()

        assert not self.reset_sequences, 'reset_sequences cannot be used on TestCase instances'

        for db_name in self._databases_names():
            transaction.enter_transaction_management(using=db_name)
            transaction.managed(True, using=db_name)
        disable_transaction_methods()

        from django.contrib.sites.models import Site
        Site.objects.clear_cache()

        for db in self._databases_names(include_mirrors=False):
            if hasattr(self, 'fixtures'):
                call_command('loaddata', *self.fixtures,
                             **{
                                'verbosity': 0,
                                'commit': False,
                                'database': db,
                                'skip_validation': True,
                             }) 
開發者ID:blackye,項目名稱:luscan-devel,代碼行數:25,代碼來源:testcases.py

示例3: _fixture_teardown

# 需要導入模塊: from django.utils import unittest [as 別名]
# 或者: from django.utils.unittest import TestCase [as 別名]
def _fixture_teardown(self):
        if not connections_support_transactions():
            return super(TestCase, self)._fixture_teardown()

        restore_transaction_methods()
        for db in self._databases_names():
            transaction.rollback(using=db)
            transaction.leave_transaction_management(using=db) 
開發者ID:blackye,項目名稱:luscan-devel,代碼行數:10,代碼來源:testcases.py

示例4: _deferredSkip

# 需要導入模塊: from django.utils import unittest [as 別名]
# 或者: from django.utils.unittest import TestCase [as 別名]
def _deferredSkip(condition, reason):
    def decorator(test_func):
        if not (isinstance(test_func, type) and
                issubclass(test_func, TestCase)):
            @wraps(test_func)
            def skip_wrapper(*args, **kwargs):
                if condition():
                    raise ut2.SkipTest(reason)
                return test_func(*args, **kwargs)
            test_item = skip_wrapper
        else:
            test_item = test_func
        test_item.__unittest_skip_why__ = reason
        return test_item
    return decorator 
開發者ID:blackye,項目名稱:luscan-devel,代碼行數:17,代碼來源:testcases.py


注:本文中的django.utils.unittest.TestCase方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。