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


Python unittest.expectedFailure方法代码示例

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


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

示例1: testOldTestResult

# 需要导入模块: import unittest [as 别名]
# 或者: from unittest import expectedFailure [as 别名]
def testOldTestResult(self):
        class Test(unittest.TestCase):
            def testSkip(self):
                self.skipTest('foobar')
            @unittest.expectedFailure
            def testExpectedFail(self):
                raise TypeError
            @unittest.expectedFailure
            def testUnexpectedSuccess(self):
                pass

        for test_name, should_pass in (('testSkip', True),
                                       ('testExpectedFail', True),
                                       ('testUnexpectedSuccess', False)):
            test = Test(test_name)
            self.assertOldResultWarning(test, int(not should_pass)) 
开发者ID:war-and-code,项目名称:jawfish,代码行数:18,代码来源:test_result.py

示例2: test_unittest_expected_failure_for_failing_test_is_xfail

# 需要导入模块: import unittest [as 别名]
# 或者: from unittest import expectedFailure [as 别名]
def test_unittest_expected_failure_for_failing_test_is_xfail(testdir, runner):
    script = testdir.makepyfile(
        """
        import unittest
        class MyTestCase(unittest.TestCase):
            @unittest.expectedFailure
            def test_failing_test_is_xfail(self):
                assert False
        if __name__ == '__main__':
            unittest.main()
    """
    )
    if runner == "pytest":
        result = testdir.runpytest("-rxX")
        result.stdout.fnmatch_lines(
            ["*XFAIL*MyTestCase*test_failing_test_is_xfail*", "*1 xfailed*"]
        )
    else:
        result = testdir.runpython(script)
        result.stderr.fnmatch_lines(["*1 test in*", "*OK*(expected failures=1)*"])
    assert result.ret == 0 
开发者ID:pytest-dev,项目名称:pytest,代码行数:23,代码来源:test_unittest.py

示例3: test_unittest_expected_failure_for_passing_test_is_fail

# 需要导入模块: import unittest [as 别名]
# 或者: from unittest import expectedFailure [as 别名]
def test_unittest_expected_failure_for_passing_test_is_fail(testdir, runner):
    script = testdir.makepyfile(
        """
        import unittest
        class MyTestCase(unittest.TestCase):
            @unittest.expectedFailure
            def test_passing_test_is_fail(self):
                assert True
        if __name__ == '__main__':
            unittest.main()
    """
    )

    if runner == "pytest":
        result = testdir.runpytest("-rxX")
        result.stdout.fnmatch_lines(
            ["*MyTestCase*test_passing_test_is_fail*", "*1 failed*"]
        )
    else:
        result = testdir.runpython(script)
        result.stderr.fnmatch_lines(["*1 test in*", "*(unexpected successes=1)*"])

    assert result.ret == 1 
开发者ID:pytest-dev,项目名称:pytest,代码行数:25,代码来源:test_unittest.py

示例4: test_no_exception_leak

# 需要导入模块: import unittest [as 别名]
# 或者: from unittest import expectedFailure [as 别名]
def test_no_exception_leak(self):
        # Issue #19880: TestCase.run() should not keep a reference
        # to the exception
        class MyException(Exception):
            ninstance = 0

            def __init__(self):
                MyException.ninstance += 1
                Exception.__init__(self)

            def __del__(self):
                MyException.ninstance -= 1

        class TestCase(unittest.TestCase):
            def test1(self):
                raise MyException()

            @unittest.expectedFailure
            def test2(self):
                raise MyException()

        for method_name in ('test1', 'test2'):
            testcase = TestCase(method_name)
            testcase.run()
            self.assertEqual(MyException.ninstance, 0) 
开发者ID:Microvellum,项目名称:Fluid-Designer,代码行数:27,代码来源:test_case.py

示例5: test_expected_failure_with_wrapped_subclass

# 需要导入模块: import unittest [as 别名]
# 或者: from unittest import expectedFailure [as 别名]
def test_expected_failure_with_wrapped_subclass(self):
        class Foo(unittest.TestCase):
            def test_1(self):
                self.assertTrue(False)

        @unittest.expectedFailure
        class Bar(Foo):
            pass

        events = []
        result = LoggingResult(events)
        test = Bar("test_1")
        test.run(result)
        self.assertEqual(events,
                         ['startTest', 'addExpectedFailure', 'stopTest'])
        self.assertEqual(result.expectedFailures[0][0], test)
        self.assertTrue(result.wasSuccessful()) 
开发者ID:Microvellum,项目名称:Fluid-Designer,代码行数:19,代码来源:test_skipping.py

示例6: test_unexpected_success_subtests

# 需要导入模块: import unittest [as 别名]
# 或者: from unittest import expectedFailure [as 别名]
def test_unexpected_success_subtests(self):
        # Success in all subtests counts as the unexpected success of
        # the whole test.
        class Foo(unittest.TestCase):
            @unittest.expectedFailure
            def test_die(self):
                with self.subTest():
                    # This one succeeds
                    pass
                with self.subTest():
                    # So does this one
                    pass
        events = []
        result = LoggingResult(events)
        test = Foo("test_die")
        test.run(result)
        self.assertEqual(events,
                         ['startTest',
                          'addSubTestSuccess', 'addSubTestSuccess',
                          'addUnexpectedSuccess', 'stopTest'])
        self.assertFalse(result.failures)
        self.assertEqual(result.unexpectedSuccesses, [test])
        self.assertFalse(result.wasSuccessful()) 
开发者ID:Microvellum,项目名称:Fluid-Designer,代码行数:25,代码来源:test_skipping.py

示例7: test_expected_failure

# 需要导入模块: import unittest [as 别名]
# 或者: from unittest import expectedFailure [as 别名]
def test_expected_failure(self):
        class Foo(unittest.TestCase):
            @unittest.expectedFailure
            def test_die(self):
                self.fail("help me!")
        events = []
        result = LoggingResult(events)
        test = Foo("test_die")
        test.run(result)
        self.assertEqual(events,
                         ['startTest', 'addExpectedFailure', 'stopTest'])
        self.assertEqual(result.expectedFailures[0][0], test)
        self.assertTrue(result.wasSuccessful()) 
开发者ID:war-and-code,项目名称:jawfish,代码行数:15,代码来源:test_skipping.py

示例8: test_unexpected_success

# 需要导入模块: import unittest [as 别名]
# 或者: from unittest import expectedFailure [as 别名]
def test_unexpected_success(self):
        class Foo(unittest.TestCase):
            @unittest.expectedFailure
            def test_die(self):
                pass
        events = []
        result = LoggingResult(events)
        test = Foo("test_die")
        test.run(result)
        self.assertEqual(events,
                         ['startTest', 'addUnexpectedSuccess', 'stopTest'])
        self.assertFalse(result.failures)
        self.assertEqual(result.unexpectedSuccesses, [test])
        self.assertTrue(result.wasSuccessful()) 
开发者ID:war-and-code,项目名称:jawfish,代码行数:16,代码来源:test_skipping.py

示例9: anticipate_failure

# 需要导入模块: import unittest [as 别名]
# 或者: from unittest import expectedFailure [as 别名]
def anticipate_failure(condition):
    """Decorator to mark a test that is known to be broken in some cases

       Any use of this decorator should have a comment identifying the
       associated tracker issue.
    """
    if condition:
        return unittest.expectedFailure
    return lambda f: f 
开发者ID:war-and-code,项目名称:jawfish,代码行数:11,代码来源:support.py

示例10: setUpClass

# 需要导入模块: import unittest [as 别名]
# 或者: from unittest import expectedFailure [as 别名]
def setUpClass(cls):
        # Because edge out-c has a native width, we expect it to fail
        #  the base test_mark_edge. The test_mark_edge_pass case has been
        #  developed to test correct functionality
        cls.test_mark_edge = unittest.expectedFailure(cls.test_mark_edge) 
开发者ID:jsexauer,项目名称:networkx_viewer,代码行数:7,代码来源:tests.py

示例11: expectedFailurePY3

# 需要导入模块: import unittest [as 别名]
# 或者: from unittest import expectedFailure [as 别名]
def expectedFailurePY3(func):
    if not PY3:
        return func
    return unittest.expectedFailure(func) 
开发者ID:Soft8Soft,项目名称:verge3d-blender-addon,代码行数:6,代码来源:base.py

示例12: expectedFailurePY26

# 需要导入模块: import unittest [as 别名]
# 或者: from unittest import expectedFailure [as 别名]
def expectedFailurePY26(func):
    if not PY26:
        return func
    return unittest.expectedFailure(func) 
开发者ID:Soft8Soft,项目名称:verge3d-blender-addon,代码行数:6,代码来源:base.py

示例13: expectedFailurePY27

# 需要导入模块: import unittest [as 别名]
# 或者: from unittest import expectedFailure [as 别名]
def expectedFailurePY27(func):
    if not PY27:
        return func
    return unittest.expectedFailure(func) 
开发者ID:Soft8Soft,项目名称:verge3d-blender-addon,代码行数:6,代码来源:base.py

示例14: expectedFailurePY2

# 需要导入模块: import unittest [as 别名]
# 或者: from unittest import expectedFailure [as 别名]
def expectedFailurePY2(func):
    if not PY2:
        return func
    return unittest.expectedFailure(func)


# Renamed in Py3.3: 
开发者ID:Soft8Soft,项目名称:verge3d-blender-addon,代码行数:9,代码来源:base.py


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