• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Python unittest2.skip函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中unittest2.skip函数的典型用法代码示例。如果您正苦于以下问题:Python skip函数的具体用法?Python skip怎么用?Python skip使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了skip函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。

示例1: test_for

def test_for(inp):
    mod,fn = inp.split('.')

    # module
    if not mod in _modules:
        try:
            _modules[mod] = __import__(mod)
        except ImportError:
            return unittest.skip("No such module '%s'" % mod)

    # function
    f = getattr(_modules[mod], fn, None)
    if f is None:
        return unittest.skip("No such method '%s.%s'" % (mod,fn))

    # make sure function is implemented
    if not_implemented(f):
        return unittest.skip("'%s.%s' is not implemented" % (mod,fn))

    # return testcase if everything works 
    def deco(cls):
        module = sys.modules[cls.__module__]
        setattr(module, mod, _modules[mod])
        cls.__testing__ = inp
        return cls
    return deco 
开发者ID:AKilgore,项目名称:CS112-Spring2012,代码行数:26,代码来源:base.py


示例2: setUpClass

    def setUpClass(cls):
        try:
            from web.db.me import MongoEngineMiddleware

        except ImportError:
            skip("MongoEngine not available; skipping MongoEngine tests.")

        cls.middleware = MongoEngineMiddleware
开发者ID:dsx,项目名称:WebCore,代码行数:8,代码来源:test_db_mongo.py


示例3: skip_open_issue

def skip_open_issue(type, bug_id):
    """ Skips the test if there is an open issue for that test.

    @param type: The issue tracker type (e.g., Launchpad, GitHub).
    @param bug_id: ID of the issue for the test.
    """
    if type.lower() == 'launchpad' and LaunchpadTracker.is_bug_open(
            bug_id=bug_id):
        return skip('Launchpad Bug #{0}'.format(bug_id))
    elif type.lower() == 'github' and GitHubTracker.is_bug_open(
            issue_id=bug_id):
        return skip('GitHub Issue #{0}'.format(bug_id))
    return lambda obj: obj
开发者ID:MUSABALOYI,项目名称:opencafe,代码行数:13,代码来源:decorators.py


示例4: test_datetime

    def test_datetime(self):
        """If DATETIME is set to a tuple, it should be used to override LOCALE
        """
        from datetime import datetime
        from sys import platform
        dt = datetime(2015, 9, 13)
        # make a deep copy of page_kawgs
        page_kwargs = dict([(key, self.page_kwargs[key]) for key in
                            self.page_kwargs])
        for key in page_kwargs:
            if not isinstance(page_kwargs[key], dict):
                break
            page_kwargs[key] = dict([(subkey, page_kwargs[key][subkey])
                                     for subkey in page_kwargs[key]])
        # set its date to dt
        page_kwargs['metadata']['date'] = dt
        page = Page(**page_kwargs)

        self.assertEqual(page.locale_date,
            unicode(dt.strftime(_DEFAULT_CONFIG['DEFAULT_DATE_FORMAT']),
                                'utf-8'))

        page_kwargs['settings'] = dict([(x, _DEFAULT_CONFIG[x]) for x in
                                        _DEFAULT_CONFIG])

        # I doubt this can work on all platforms ...
        if platform == "win32":
            locale = 'jpn'
        else:
            locale = 'ja_JP.utf8'
        page_kwargs['settings']['DATE_FORMATS'] = {'jp': (locale,
                                                          '%Y-%m-%d(%a)')}
        page_kwargs['metadata']['lang'] = 'jp'

        import locale as locale_module
        try:
            page = Page(**page_kwargs)
            self.assertEqual(page.locale_date, u'2015-09-13(\u65e5)')
            # above is unicode in Japanese: 2015-09-13(“ú)
        except locale_module.Error:
            # The constructor of ``Page`` will try to set the locale to
            # ``ja_JP.utf8``. But this attempt will failed when there is no
            # such locale in the system. You can see which locales there are
            # in your system with ``locale -a`` command.
            #
            # Until we find some other method to test this functionality, we
            # will simply skip this test.
            skip("There is no locale %s in this system." % locale)
开发者ID:danawoodman,项目名称:pelican,代码行数:48,代码来源:test_contents.py


示例5: platform_skip

def platform_skip(platform_list):
    def _noop(obj):
        return obj

    if platform in platform_list:
        return unittest2.skip("Test disabled in the current platform")
    return _noop
开发者ID:rblank,项目名称:pyuv,代码行数:7,代码来源:common.py


示例6: all_drivers

def all_drivers(testcase):
    """Decorator for test classes so that the tests are run against all drivers.
    """

    module = sys.modules[testcase.__module__]
    drivers = (
        ('Mechanize', MECHANIZE_TESTING, LIB_MECHANIZE),
        ('Requests', REQUESTS_TESTING, LIB_REQUESTS),
        ('Traversal', TRAVERSAL_TESTING, LIB_TRAVERSAL),
        ('TraversalIntegration', TRAVERSAL_INTEGRATION_TESTING, LIB_TRAVERSAL),
    )
    testcase._testbrowser_abstract_testclass = True

    for postfix, layer, constant in drivers:
        name = testcase.__name__ + postfix
        custom = {'layer': layer,
                  '__module__': testcase.__module__,
                  '_testbrowser_abstract_testclass': False}

        subclass = type(name, (testcase,), custom)
        for attrname in dir(subclass):
            method = getattr(subclass, attrname, None)
            func = getattr(method, 'im_func', None)
            if constant in getattr(func, '_testbrowser_skip_driver', {}):
                reason = func._testbrowser_skip_driver[constant]
                setattr(subclass, attrname, skip(reason)(method))

        setattr(module, name, subclass)

    setattr(module, 'load_tests', load_tests)
    return testcase
开发者ID:4teamwork,项目名称:ftw.testbrowser,代码行数:31,代码来源:alldrivers.py


示例7: add_test_methods

    def add_test_methods(test_class):
        for filename in glob.iglob(os.path.join(basedir, tests_glob)):
            validating, _ = os.path.splitext(os.path.basename(filename))

            with open(filename) as test_file:
                data = json.load(test_file)

                for case in data:
                    for test in case["tests"]:
                        a_test = make_case(
                            case["schema"],
                            test["data"],
                            test["valid"],
                        )

                        test_name = "test_%s_%s" % (
                            validating,
                            re.sub(r"[\W ]+", "_", test["description"]),
                        )

                        if not PY3:
                            test_name = test_name.encode("utf-8")
                        a_test.__name__ = test_name

                        if skip is not None and skip(case):
                            a_test = unittest.skip("Checker not present.")(
                                a_test
                            )

                        setattr(test_class, test_name, a_test)

        return test_class
开发者ID:rsternagel,项目名称:jsonschema,代码行数:32,代码来源:tests.py


示例8: test_old_testresult_class

    def test_old_testresult_class(self):
        class Test(unittest2.TestCase):

            def testFoo(self):
                pass
        Test = unittest2.skip('no reason')(Test)
        self.assertOldResultWarning(Test('testFoo'), 0)
开发者ID:CodaFi,项目名称:swift-lldb,代码行数:7,代码来源:test_unittest2_with.py


示例9: skipIfSingleNode

def skipIfSingleNode():
    """
    Skip a test if its a single node install.
    """
    if len(get_host_list()[1]) == 0:
        return unittest.skip('requires multiple nodes')
    return lambda o: o
开发者ID:BALDELab,项目名称:incubator-hawq,代码行数:7,代码来源:__init__.py


示例10: create_backend_case

def create_backend_case(base, name, module="passlib.tests.test_drivers"):
    "create a test case for specific backend of a multi-backend handler"
    #get handler, figure out if backend should be tested
    handler = base.handler
    assert hasattr(handler, "backends"), "handler must support uh.HasManyBackends protocol"
    enable, reason = _enable_backend_case(handler, name)

    #UT1 doesn't support skipping whole test cases,
    #so we just return None.
    if not enable and ut_version < 2:
        return None

    #make classname match what it's stored under, to be tidy
    cname = name.title().replace("_","") + "_" + base.__name__.lstrip("_")

    #create subclass of 'base' which uses correct backend
    subcase = type(
        cname,
        (base,),
        dict(
            case_prefix = "%s (%s backend)" % (handler.name, name),
            backend = name,
            __module__=module,
        )
    )

    if not enable:
        subcase = unittest.skip(reason)(subcase)

    return subcase
开发者ID:GabrielDiniz,项目名称:FluxNetControl,代码行数:30,代码来源:utils.py


示例11: decorator

 def decorator(func):
     if hasattr(unittest, 'skip'):
         # If we don't have discovery, we probably don't skip, but we'll
         # try anyways...
         return unittest.skip('Discovery not supported.')(func)
     else:
         return None
开发者ID:ktan2020,项目名称:legacy-automation,代码行数:7,代码来源:test_main.py


示例12: stubbed

def stubbed(reason=None):
    """Skips test due to non-implentation or some other reason."""

    # Assume 'not implemented' if no reason is given
    if reason is None:
        reason = NOT_IMPLEMENTED
    return unittest2.skip(reason)
开发者ID:cpeters,项目名称:robottelo,代码行数:7,代码来源:decorators.py


示例13: slowTest

def slowTest(obj):
	'''Decorator for slow tests

	Tests wrapped with this decorator are ignored when you run
	C{test.py --fast}. You can either wrap whole test classes::

		@tests.slowTest
		class MyTest(tests.TestCase):
			...

	or individual test functions::

		class MyTest(tests.TestCase):

			@tests.slowTest
			def testFoo(self):
				...

			def testBar(self):
				...
	'''
	if FAST_TEST:
		wrapper = skip('Slow test')
		return wrapper(obj)
	else:
		return obj
开发者ID:hjq300,项目名称:zim-wiki,代码行数:26,代码来源:__init__.py


示例14: init_plugin

    def init_plugin(self, config_content=None):
        conf = None
        if config_content:
            conf = XmlConfigParser()
            conf.setXml(config_content)
        elif os.path.exists(default_plugin_file):
            conf = default_plugin_file
        else:
            unittest.skip("cannot get default plugin config file at %s" % default_plugin_file)

        self.p = AdvPlugin(self.console, conf)
        self.conf = self.p.config
        self.log.setLevel(logging.DEBUG)
        self.log.info("============================= Adv plugin: loading config ============================")
        self.p.onLoadConfig()
        self.log.info("============================= Adv plugin: starting  =================================")
        self.p.onStartup()
开发者ID:tanka8,项目名称:big-brother-bot,代码行数:17,代码来源:test_adv.py


示例15: wrapper

 def wrapper(func):
     # Replicate the same behaviour as doing:
     #
     # @unittest2.skip(reason)
     # @pytest.mark.stubbed
     # def func(...):
     #     ...
     return unittest2.skip(reason)(pytest.mark.stubbed(func))
开发者ID:JacobCallahan,项目名称:robottelo,代码行数:8,代码来源:__init__.py


示例16: local_decorator_creator

def local_decorator_creator():
    if not CASSANDRA_IP.startswith("127.0.0."):
        return unittest.skip('Tests only runs against local C*')

    def _id_and_mark(f):
        f.local = True

    return _id_and_mark
开发者ID:joaquincasares,项目名称:python-driver,代码行数:8,代码来源:__init__.py


示例17: newTestMethod

 def newTestMethod(*args, **kwargs):
     if TestOptionParser.__long__ is None:
         raise Exception("TestOptionParser must be used in order to use @longTest" "decorator.")
     if TestOptionParser.__long__:
         return testMethod(*args, **kwargs)
     else:
         msg = "Skipping long test: %s" % testMethod.__name__
         return unittest.skip(msg)(testMethod)(*args, **kwargs)
开发者ID:BrianPrz,项目名称:nupic,代码行数:8,代码来源:testcasebase.py


示例18: newTestMethod

 def newTestMethod(*args, **kwargs):
   if TestOptionParser.__long__ is None:
     raise Exception('TestOptionParser must be used in order to use @longTest'
                     'decorator.')
   if TestOptionParser.__long__:
     return testMethod(*args, **kwargs)
   else:
     msg = 'Skipping long test: {0!s}'.format(testMethod.__name__)
     return unittest.skip(msg)(testMethod)(*args, **kwargs)
开发者ID:runt18,项目名称:nupic,代码行数:9,代码来源:testcasebase.py


示例19: skipIfNoStandby

def skipIfNoStandby():
    """
    A decorator which skips a unit test if a standby
    is not already present in the cluster.
    """
    standby = get_host_list()[0]
    if standby is None:
        return unittest.skip('requires standby') 
    return lambda o: o 
开发者ID:BALDELab,项目名称:incubator-hawq,代码行数:9,代码来源:__init__.py


示例20: skip_unless_module

def skip_unless_module(module):
    available = True
    try:
        __import__(module)
    except ImportError:
        available = False
    if available:
        return lambda func: func
    return skip("Module %s could not be loaded, dependent test skipped." % module)
开发者ID:jmchilton,项目名称:pulsar,代码行数:9,代码来源:test_utils.py



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python unittest2.skipIf函数代码示例发布时间:2022-05-27
下一篇:
Python unittest2.registerResult函数代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap