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


Python unittest2.skipIf方法代码示例

本文整理汇总了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) 
开发者ID:tao12345666333,项目名称:tornado-zh,代码行数:9,代码来源:testing.py

示例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) 
开发者ID:sklearn-theano,项目名称:sklearn-theano,代码行数:6,代码来源:unknown_fields_test.py

示例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 
开发者ID:pysmt,项目名称:pysmt,代码行数:10,代码来源:__init__.py

示例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 
开发者ID:gkrizek,项目名称:bash-lambda-layer,代码行数:16,代码来源:testutils.py

示例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()) 
开发者ID:Lithium876,项目名称:ConTroll_Remote_Access_Trojan,代码行数:28,代码来源:test_skipping.py

示例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) 
开发者ID:stanislav-web,项目名称:OpenDoor,代码行数:51,代码来源:test_lib_reader.py


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