本文整理汇总了Python中unittest2.skip方法的典型用法代码示例。如果您正苦于以下问题:Python unittest2.skip方法的具体用法?Python unittest2.skip怎么用?Python unittest2.skip使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类unittest2
的用法示例。
在下文中一共展示了unittest2.skip方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: setUp
# 需要导入模块: import unittest2 [as 别名]
# 或者: from unittest2 import skip [as 别名]
def setUp(self):
info_cinfo = patch('lib.client.node.Node._info_cinfo')
getfqdn = patch('lib.client.node.getfqdn')
getaddrinfo = patch('socket.getaddrinfo')
self.addCleanup(patch.stopall)
lib.client.node.Node._info_cinfo = info_cinfo.start()
lib.client.node.getfqdn = getfqdn.start()
socket.getaddrinfo = getaddrinfo.start()
Node._info_cinfo.return_value = ""
lib.client.node.getfqdn.return_value = "host.domain.local"
socket.getaddrinfo.return_value = [(2, 1, 6, '', ('192.1.1.1', 3000))]
#@unittest.skip("Known Failure")
示例2: test_skip_test
# 需要导入模块: import unittest2 [as 别名]
# 或者: from unittest2 import skip [as 别名]
def test_skip_test(self):
class Skips(unittest.TestCase):
def test_me(self):
self.skipTest("yo")
self.result.startTestRun()
test = Skips("test_me")
self.run_test_or_simulate(test, 'skipTest', self.result.addSkip, 'yo')
self.result.stopTestRun()
output = self.get_output()
expected = """<testsuite errors="0" failures="0" name="" tests="1" time="0.000">
<testcase classname="junitxml.tests.test_junitxml.Skips" name="test_me" time="0.000">
<skip>yo</skip>
</testcase>
</testsuite>
"""
self.assertEqual(expected, output)
示例3: test_skip_reason
# 需要导入模块: import unittest2 [as 别名]
# 或者: from unittest2 import skip [as 别名]
def test_skip_reason(self):
"""Check the skip element content is escaped"""
class SkipWithLt(unittest.TestCase):
def runTest(self):
self.fail("version < 2.7")
try:
runTest = unittest.skip("2.7 <= version")(runTest)
except AttributeError:
self.has_skip = False
else:
self.has_skip = True
doc = self._run_and_parse_test(SkipWithLt())
if self.has_skip:
self.assertEqual('2.7 <= version',
doc.getElementsByTagName("skip")[0].firstChild.nodeValue)
else:
self.assertTrue(
doc.getElementsByTagName("failure")[0].firstChild.nodeValue
.endswith("AssertionError: version < 2.7\n"))
示例4: test_class_not_setup_or_torndown_when_skipped
# 需要导入模块: import unittest2 [as 别名]
# 或者: from unittest2 import skip [as 别名]
def test_class_not_setup_or_torndown_when_skipped(self):
class Test(unittest2.TestCase):
classSetUp = False
tornDown = False
def setUpClass(cls):
Test.classSetUp = True
setUpClass = classmethod(setUpClass)
def tearDownClass(cls):
Test.tornDown = True
tearDownClass = classmethod(tearDownClass)
def test_one(self):
pass
Test = unittest2.skip("hop")(Test)
self.runTests(Test)
self.assertFalse(Test.classSetUp)
self.assertFalse(Test.tornDown)
示例5: test_skipping
# 需要导入模块: import unittest2 [as 别名]
# 或者: from unittest2 import skip [as 别名]
def test_skipping(self):
class Foo(unittest2.TestCase):
def test_skip_me(self):
self.skipTest("skip")
events = []
result = LoggingResult(events)
test = Foo("test_skip_me")
test.run(result)
self.assertEqual(events, ['startTest', 'addSkip', 'stopTest'])
self.assertEqual(result.skipped, [(test, "skip")])
# Try letting setUp skip the test now.
class Foo(unittest2.TestCase):
def setUp(self):
self.skipTest("testing")
def test_nothing(self): pass
events = []
result = LoggingResult(events)
test = Foo("test_nothing")
test.run(result)
self.assertEqual(events, ['startTest', 'addSkip', 'stopTest'])
self.assertEqual(result.skipped, [(test, "testing")])
self.assertEqual(result.testsRun, 1)
示例6: test_skip_doesnt_run_setup
# 需要导入模块: import unittest2 [as 别名]
# 或者: from unittest2 import skip [as 别名]
def test_skip_doesnt_run_setup(self):
class Foo(unittest2.TestCase):
wasSetUp = False
wasTornDown = False
def setUp(self):
Foo.wasSetUp = True
def tornDown(self):
Foo.wasTornDown = True
def test_1(self):
pass
test_1 = unittest2.skip('testing')(test_1)
result = unittest2.TestResult()
test = Foo("test_1")
suite = unittest2.TestSuite([test])
suite.run(result)
self.assertEqual(result.skipped, [(test, "testing")])
self.assertFalse(Foo.wasSetUp)
self.assertFalse(Foo.wasTornDown)
示例7: test_decorated_skip
# 需要导入模块: import unittest2 [as 别名]
# 或者: from unittest2 import skip [as 别名]
def test_decorated_skip(self):
def decorator(func):
def inner(*a):
return func(*a)
return inner
class Foo(unittest2.TestCase):
def test_1(self):
pass
test_1 = decorator(unittest2.skip('testing')(test_1))
result = unittest2.TestResult()
test = Foo("test_1")
suite = unittest2.TestSuite([test])
suite.run(result)
self.assertEqual(result.skipped, [(test, "testing")])
示例8: requires_resource
# 需要导入模块: import unittest2 [as 别名]
# 或者: from unittest2 import skip [as 别名]
def requires_resource(resource):
if resource == 'gui' and not _is_gui_available():
return unittest.skip("resource 'gui' is not available")
if is_resource_enabled(resource):
return _id
else:
return unittest.skip("resource {0!r} is not enabled".format(resource))
示例9: impl_detail
# 需要导入模块: import unittest2 [as 别名]
# 或者: from unittest2 import skip [as 别名]
def impl_detail(msg=None, **guards):
if check_impl_detail(**guards):
return _id
if msg is None:
guardnames, default = _parse_guards(guards)
if default:
msg = "implementation detail not available on {0}"
else:
msg = "implementation detail specific to {0}"
guardnames = sorted(guardnames.keys())
msg = msg.format(' or '.join(guardnames))
return unittest.skip(msg)
示例10: skip_unless_symlink
# 需要导入模块: import unittest2 [as 别名]
# 或者: from unittest2 import skip [as 别名]
def skip_unless_symlink(test):
"""Skip decorator for tests that require functional symlink"""
ok = can_symlink()
msg = "Requires functional symlink implementation"
return test if ok else unittest.skip(msg)(test)
示例11: skip_unless_xattr
# 需要导入模块: import unittest2 [as 别名]
# 或者: from unittest2 import skip [as 别名]
def skip_unless_xattr(test):
"""Skip decorator for tests that require functional extended attributes"""
ok = can_xattr()
msg = "no non-broken extended attribute support"
return test if ok else unittest.skip(msg)(test)
示例12: skip_unless_solr
# 需要导入模块: import unittest2 [as 别名]
# 或者: from unittest2 import skip [as 别名]
def skip_unless_solr(func):
"""
Use this decorator to skip tests which need a functional Solr connection.
The connection is given by the environment SOLR_URL
"""
if is_solr_available():
return func
msg = "Test needs a running Solr connection (SOLR_URL)"
warnings.warn(msg + str(func))
return unittest.skip(msg)(func)