本文整理汇总了Python中unittest2.skipIf方法的典型用法代码示例。如果您正苦于以下问题:Python unittest2.skipIf方法的具体用法?Python unittest2.skipIf怎么用?Python unittest2.skipIf使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类unittest2
的用法示例。
在下文中一共展示了unittest2.skipIf方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __getattr__
# 需要导入模块: import unittest2 [as 别名]
# 或者: from unittest2 import skipIf [as 别名]
def __getattr__(self, name):
"""Proxy all unknown attributes to the original method.
This is important for some of the decorators in the `unittest`
module, such as `unittest.skipIf`.
"""
return getattr(self.orig_method, name)
示例2: SkipIfCppImplementation
# 需要导入模块: import unittest2 [as 别名]
# 或者: from unittest2 import skipIf [as 别名]
def SkipIfCppImplementation(func):
return unittest.skipIf(
api_implementation.Type() == 'cpp' and api_implementation.Version() == 2,
'C++ implementation does not expose unknown fields to Python')(func)
示例3: __call__
# 需要导入模块: import unittest2 [as 别名]
# 或者: from unittest2 import skipIf [as 别名]
def __call__(self, test_fun):
msg = "%s not available" % self.solver
cond = self.solver not in get_env().factory.all_solvers()
@unittest.skipIf(cond, msg)
@wraps(test_fun)
def wrapper(*args, **kwargs):
return test_fun(*args, **kwargs)
return wrapper
示例4: skip_if_windows
# 需要导入模块: import unittest2 [as 别名]
# 或者: from unittest2 import skipIf [as 别名]
def skip_if_windows(reason):
"""Decorator to skip tests that should not be run on windows.
Example usage:
@skip_if_windows("Not valid")
def test_some_non_windows_stuff(self):
self.assertEqual(...)
"""
def decorator(func):
return unittest.skipIf(
platform.system() not in ['Darwin', 'Linux'], reason)(func)
return decorator
示例5: test_skipping_decorators
# 需要导入模块: import unittest2 [as 别名]
# 或者: from unittest2 import skipIf [as 别名]
def test_skipping_decorators(self):
op_table = ((unittest2.skipUnless, False, True),
(unittest2.skipIf, True, False))
for deco, do_skip, dont_skip in op_table:
class Foo(unittest2.TestCase):
def test_skip(self):
pass
test_skip = deco(do_skip, "testing")(test_skip)
def test_dont_skip(self):
pass
test_dont_skip = deco(dont_skip, "testing")(test_dont_skip)
test_do_skip = Foo("test_skip")
test_dont_skip = Foo("test_dont_skip")
suite = unittest2.TestSuite([test_do_skip, test_dont_skip])
events = []
result = LoggingResult(events)
suite.run(result)
self.assertEqual(len(result.skipped), 1)
expected = ['startTest', 'addSkip', 'stopTest',
'startTest', 'addSuccess', 'stopTest']
self.assertEqual(events, expected)
self.assertEqual(result.testsRun, 2)
self.assertEqual(result.skipped, [(test_do_skip, "testing")])
self.assertTrue(result.wasSuccessful())
示例6: test_total_lines
# 需要导入模块: import unittest2 [as 别名]
# 或者: from unittest2 import skipIf [as 别名]
def test_total_lines(self):
""" Reader.total_lines test """
empty_reader = Reader(browser_config={})
self.assertIs(type(empty_reader.total_lines), int)
# def test_randomize_list_exception(self):
# """ Reader.randomize_list exception test """
#
# reader = Reader(browser_config={})
# setattr(reader, '_Reader__config', self.__configuration_for_exception)
# setattr(sys, '_Output__is_windows', False)
# with self.assertRaises(ReaderError) as context:
# reader.randomize_list('directories', 'tmplist')
# self.assertTrue(ReaderError == context.expected)
#
# @unittest.skipIf(True is sys().is_windows, "Skip test for windows")
# def test_randomize_list_unix(self):
# """ Reader.randomize_list unix test """
#
# reader = Reader(browser_config={
# 'is_external_wordlist': True,
# 'list': 'tests/data/directories.dat',
# })
# setattr(reader, '_Reader__config', self.__configuration)
# reader.count_total_lines()
# self.assertIsNone(reader.randomize_list('directories', 'tmplist'))
# fe = open('tests/data/directories.dat', 'r')
# fa = open('tests/tmp/list.tmp', 'r')
# expected = sum(1 for l in fe)
# actual = sum(1 for l in fa)
# self.assertIs(expected, actual)
#
# def test_randomize_list_windows(self):
# """ Reader.randomize_list windows test """
#
# reader = Reader(browser_config={
# 'is_external_wordlist': True,
# 'list': 'tests/data/directories.dat',
# })
# setattr(reader, '_Reader__config', self.__configuration)
# setattr(sys, 'is_windows', True)
# reader.count_total_lines()
# self.assertIsNone(reader.randomize_list('directories', 'tmplist'))
# fe = open('tests/data/directories.dat', 'r')
# fa = open('tests/tmp/list.tmp', 'r')
# expected = sum(1 for l in fe)
# actual = sum(1 for l in fa)
# self.assertIs(expected, actual)