以下示例是关于Python中包含Unitest Skip用法的示例代码,想了解Unitest Skip的具体用法?Unitest Skip怎么用?Unitest Skip使用的例子?那么可以参考以下相关源代码片段来学习它的具体使用方法。
class MyTestCase(unittest.TestCase):
@unittest.skip("demonstrating skipping")
def test_nothing(self):
self.fail("shouldn't happen")
@unittest.skipIf(mylib.__version__ < (1, 3),
"not supported in this library version")
def test_format(self):
# Tests that work for only a certain version of the library.
pass
@unittest.skipUnless(sys.platform.startswith("win"), "requires Windows")
def test_windows_support(self):
# windows specific testing code
pass
def test_maybe_skipped(self):
if not external_resource_available():
self.skipTest("external resource not available")
# test code that depends on the external resource
pass
本文地址:https://www.itbaoku.cn/snippets/795568.html