本文整理汇总了Python中unittest2.expectedFailure方法的典型用法代码示例。如果您正苦于以下问题:Python unittest2.expectedFailure方法的具体用法?Python unittest2.expectedFailure怎么用?Python unittest2.expectedFailure使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类unittest2
的用法示例。
在下文中一共展示了unittest2.expectedFailure方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_unexpected_success_test
# 需要导入模块: import unittest2 [as 别名]
# 或者: from unittest2 import expectedFailure [as 别名]
def test_unexpected_success_test(self):
class Succeeds(unittest.TestCase):
def test_me(self):
pass
try:
test_me = unittest.expectedFailure(test_me)
except AttributeError:
pass # Older python - just let the test pass
self.result.startTestRun()
Succeeds("test_me").run(self.result)
self.result.stopTestRun()
output = self.get_output()
expected = """<testsuite errors="0" failures="1" name="" tests="1" time="0.000">
<testcase classname="junitxml.tests.test_junitxml.Succeeds" name="test_me" time="0.000">
<failure type="unittest.case._UnexpectedSuccess"/>
</testcase>
</testsuite>
"""
expected_old = """<testsuite errors="0" failures="0" name="" tests="1" time="0.000">
<testcase classname="junitxml.tests.test_junitxml.Succeeds" name="test_me" time="0.000"/>
</testsuite>
"""
if output != expected_old:
self.assertEqual(expected, output)
示例2: test_old_testresult
# 需要导入模块: import unittest2 [as 别名]
# 或者: from unittest2 import expectedFailure [as 别名]
def test_old_testresult(self):
class Test(unittest2.TestCase):
def testSkip(self):
self.skipTest('foobar')
def testExpectedFail(self):
raise TypeError
testExpectedFail = unittest2.expectedFailure(testExpectedFail)
def testUnexpectedSuccess(self):
pass
testUnexpectedSuccess = unittest2.expectedFailure(testUnexpectedSuccess)
for test_name, should_pass in (('testSkip', True),
('testExpectedFail', True),
('testUnexpectedSuccess', False)):
test = Test(test_name)
self.assertOldResultWarning(test, int(not should_pass))
示例3: anticipate_failure
# 需要导入模块: import unittest2 [as 别名]
# 或者: from unittest2 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
示例4: expectedFailurePY3
# 需要导入模块: import unittest2 [as 别名]
# 或者: from unittest2 import expectedFailure [as 别名]
def expectedFailurePY3(func):
if not PY3:
return func
return unittest.expectedFailure(func)
示例5: expectedFailurePY26
# 需要导入模块: import unittest2 [as 别名]
# 或者: from unittest2 import expectedFailure [as 别名]
def expectedFailurePY26(func):
if not PY26:
return func
return unittest.expectedFailure(func)
示例6: expectedFailurePY27
# 需要导入模块: import unittest2 [as 别名]
# 或者: from unittest2 import expectedFailure [as 别名]
def expectedFailurePY27(func):
if not PY27:
return func
return unittest.expectedFailure(func)
示例7: expectedFailurePY2
# 需要导入模块: import unittest2 [as 别名]
# 或者: from unittest2 import expectedFailure [as 别名]
def expectedFailurePY2(func):
if not PY2:
return func
return unittest.expectedFailure(func)
# Renamed in Py3.3: