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


Python unittest.TestResult方法代码示例

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


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

示例1: test_undecorated_coroutine

# 需要导入模块: from tornado.test.util import unittest [as 别名]
# 或者: from tornado.test.util.unittest import TestResult [as 别名]
def test_undecorated_coroutine(self):
        namespace = exec_test(globals(), locals(), """
        class Test(AsyncTestCase):
            async def test_coro(self):
                pass
        """)

        test_class = namespace['Test']
        test = test_class('test_coro')
        result = unittest.TestResult()

        # Silence "RuntimeWarning: coroutine 'test_coro' was never awaited".
        with warnings.catch_warnings():
            warnings.simplefilter('ignore')
            test.run(result)

        self.assertEqual(len(result.errors), 1)
        self.assertIn("should be decorated", result.errors[0][1]) 
开发者ID:DirceuSilvaLabs,项目名称:noc-orchestrator,代码行数:20,代码来源:testing_test.py

示例2: test_undecorated_generator

# 需要导入模块: from tornado.test.util import unittest [as 别名]
# 或者: from tornado.test.util.unittest import TestResult [as 别名]
def test_undecorated_generator(self):
        class Test(AsyncTestCase):
            def test_gen(self):
                yield
        test = Test('test_gen')
        result = unittest.TestResult()
        test.run(result)
        self.assertEqual(len(result.errors), 1)
        self.assertIn("should be decorated", result.errors[0][1]) 
开发者ID:DirceuSilvaLabs,项目名称:noc-orchestrator,代码行数:11,代码来源:testing_test.py

示例3: test_undecorated_generator_with_skip

# 需要导入模块: from tornado.test.util import unittest [as 别名]
# 或者: from tornado.test.util.unittest import TestResult [as 别名]
def test_undecorated_generator_with_skip(self):
        class Test(AsyncTestCase):
            @unittest.skip("don't run this")
            def test_gen(self):
                yield
        test = Test('test_gen')
        result = unittest.TestResult()
        test.run(result)
        self.assertEqual(len(result.errors), 0)
        self.assertEqual(len(result.skipped), 1) 
开发者ID:DirceuSilvaLabs,项目名称:noc-orchestrator,代码行数:12,代码来源:testing_test.py

示例4: test_other_return

# 需要导入模块: from tornado.test.util import unittest [as 别名]
# 或者: from tornado.test.util.unittest import TestResult [as 别名]
def test_other_return(self):
        class Test(AsyncTestCase):
            def test_other_return(self):
                return 42
        test = Test('test_other_return')
        result = unittest.TestResult()
        test.run(result)
        self.assertEqual(len(result.errors), 1)
        self.assertIn("Return value from test method ignored", result.errors[0][1]) 
开发者ID:DirceuSilvaLabs,项目名称:noc-orchestrator,代码行数:11,代码来源:testing_test.py

示例5: test_set_up_tear_down

# 需要导入模块: from tornado.test.util import unittest [as 别名]
# 或者: from tornado.test.util.unittest import TestResult [as 别名]
def test_set_up_tear_down(self):
        """
        This test makes sure that AsyncTestCase calls super methods for
        setUp and tearDown.

        InheritBoth is a subclass of both AsyncTestCase and
        SetUpTearDown, with the ordering so that the super of
        AsyncTestCase will be SetUpTearDown.
        """
        events = []
        result = unittest.TestResult()

        class SetUpTearDown(unittest.TestCase):
            def setUp(self):
                events.append('setUp')

            def tearDown(self):
                events.append('tearDown')

        class InheritBoth(AsyncTestCase, SetUpTearDown):
            def test(self):
                events.append('test')

        InheritBoth('test').run(result)
        expected = ['setUp', 'test', 'tearDown']
        self.assertEqual(expected, events) 
开发者ID:DirceuSilvaLabs,项目名称:noc-orchestrator,代码行数:28,代码来源:testing_test.py


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