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

Python unittest2.skipIf函数代码示例

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

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



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

示例1: skipRemote

def skipRemote(func):  # noqa
    """Decorator to skip tests based on whether server is remote,
    Remote in the sense whether it is Sauce Labs"""

    remote = int(conf.properties['main.remote'])
    return unittest2.skipIf(
        remote == 1,
        "Skipping as setup related to sauce labs is missing")(func)
开发者ID:lpramuk,项目名称:robottelo,代码行数:8,代码来源:decorators.py


示例2: only_run_with_non_partitioned_database

def only_run_with_non_partitioned_database(cls):
    """
    Only runs the test with the non-partitioned database settings.
    """
    skip_if = skipIf(
        settings.USE_PARTITIONED_DATABASE, 'Only applicable when sharding is not setup'
    )
    return skip_if(cls)
开发者ID:dimagi,项目名称:commcare-hq,代码行数:8,代码来源:utils.py


示例3: decorator

    def decorator(fn, path=arg):
        if path:
            cond = not os.path.exists(path)
        else:
            try:
                find_program('postgres', ['bin'])  # raise exception if not found
                cond = False
            except:
                cond = True  # not found

        return skipIf(cond, "PostgreSQL not found")(fn)
开发者ID:Varsha-Arun,项目名称:testing.postgresql,代码行数:11,代码来源:postgresql.py


示例4: skipIf

def skipIf(condition, reason):
    """
    A docorator for test skipping.
    """
    version = getPythonVersion()
    if version >= 2.7:
        import unittest
        return unittest.skipIf(condition, reason)
    else:
        import unittest2
        return unittest2.skipIf(condition, reason)
开发者ID:malcolmreynolds,项目名称:APGL,代码行数:11,代码来源:__init__.py


示例5: only_run_on_nix

def only_run_on_nix(func):
    """
    Decorator that allows to skip a test if not running on linux/macosx.
    :param func: Function to be decorated.
    :returns: The decorated function.
    """
    running_windows = sys.platform == "win32"
    return unittest.skipIf(
        running_windows,
        "Linux/Macosx only test."
    )(func)
开发者ID:shotgunsoftware,项目名称:tk-core,代码行数:11,代码来源:tank_test_base.py


示例6: only_run_on_windows

def only_run_on_windows(func):
    """
    Decorator that allows to skip a test if not running on windows.
    :param func: Function to be decorated.
    :returns: The decorated function.
    """
    running_nix = sys.platform != "win32"
    return unittest.skipIf(
        running_nix,
        "Windows only test."
    )(func)
开发者ID:shotgunsoftware,项目名称:tk-core,代码行数:11,代码来源:tank_test_base.py


示例7: decorator

        def decorator(fn, path=arg):
            if path:
                cond = not os.path.exists(path)
            else:
                try:
                    self.search_server()
                    cond = False  # found
                except:
                    cond = True  # not found

            return skipIf(cond, "%s not found" % self.name)(fn)
开发者ID:tk0miya,项目名称:testing.common.database,代码行数:11,代码来源:database.py


示例8: ParserTestCase


class ParserTestCase(object):

    def setUp(self):
        self.old_parser = settings.COMPRESS_PARSER
        settings.COMPRESS_PARSER = self.parser_cls
        super(ParserTestCase, self).setUp()

    def tearDown(self):
        settings.COMPRESS_PARSER = self.old_parser


class LxmlParserTests(ParserTestCase, CompressorTestCase):
    parser_cls = 'compressor.parser.LxmlParser'
LxmlParserTests = skipIf(lxml is None, 'lxml not found')(LxmlParserTests)


class Html5LibParserTests(ParserTestCase, CompressorTestCase):
    parser_cls = 'compressor.parser.Html5LibParser'

    def test_css_split(self):
        out = [
            (SOURCE_FILE, os.path.join(settings.COMPRESS_ROOT, u'css/one.css'), u'css/one.css', u'<link charset="utf-8" href="/media/css/one.css" rel="stylesheet" type="text/css">'),
            (SOURCE_HUNK, u'p { border:5px solid green;}', None, u'<style type="text/css">p { border:5px solid green;}</style>'),
            (SOURCE_FILE, os.path.join(settings.COMPRESS_ROOT, u'css/two.css'), u'css/two.css', u'<link charset="utf-8" href="/media/css/two.css" rel="stylesheet" type="text/css">'),
        ]
        split = self.css_node.split_contents()
        split = [(x[0], x[1], x[2], self.css_node.parser.elem_str(x[3])) for x in split]
        self.assertEqual(out, split)
开发者ID:simplegeo,项目名称:django_compressor,代码行数:28,代码来源:tests.py


示例9: CssTidyTestCase


class CssTidyTestCase(TestCase):
    def test_tidy(self):
        content = """
/* Some comment */
font,th,td,p{
color: black;
}
"""
        from compressor.filters.csstidy import CSSTidyFilter
        self.assertEqual(
            "font,th,td,p{color:#000;}", CSSTidyFilter(content).input())

CssTidyTestCase = skipIf(
    find_command(settings.COMPRESS_CSSTIDY_BINARY) is None,
    'CSStidy binary %r not found' % settings.COMPRESS_CSSTIDY_BINARY,
)(CssTidyTestCase)


class PrecompilerTestCase(TestCase):

    def setUp(self):
        self.filename = os.path.join(test_dir, 'media/css/one.css')
        with open(self.filename) as f:
            self.content = f.read()
        self.test_precompiler = os.path.join(test_dir, 'precompiler.py')

    def test_precompiler_infile_outfile(self):
        command = '%s %s -f {infile} -o {outfile}' % (sys.executable, self.test_precompiler)
        compiler = CompilerFilter(content=self.content, filename=self.filename, command=command)
        self.assertEqual(u"body { color:#990; }", compiler.input())
开发者ID:gregplaysguitar,项目名称:django_compressor,代码行数:30,代码来源:filters.py


示例10: run_benchmark

try:
    # python 2.x
    import unittest2 as unittest

    PENALTY_MEM = 10
    PENALTY_CPU = 100
except ImportError:
    # python 3.x
    import unittest

    PENALTY_MEM = 10
    PENALTY_CPU = 150


enableIf = unittest.skipIf(
    os.getenv("PREFIXTREE_PERF") is None or sys.version_info[:2] < (2, 7),
    "Set PREFIXTREE_PERF environment variable to run performance tests",
)


def run_benchmark(script):
    cmd = ["PYTHONPATH=. {0} {1}".format(sys.executable, script)]
    output = subprocess.check_output(cmd, shell=True)
    mem, time = output.split()
    return float(mem), float(time)


class TestPerformance(unittest.TestCase):
    def _benchmark(self):
        mem_dict, cpu_dict = run_benchmark("tests/benchmark_dict.py")
        TestPerformance._cpu_dict = cpu_dict
        TestPerformance._mem_dict = mem_dict
开发者ID:provoke-vagueness,项目名称:prefixtree,代码行数:32,代码来源:test_performance.py


示例11: skipIfPlatform

def skipIfPlatform(oslist):
    """Decorate the item to skip tests if running on one of the listed platforms."""
    # This decorator cannot be ported to `skipIf` yet because it is used on entire
    # classes, which `skipIf` explicitly forbids.
    return unittest2.skipIf(lldbplatformutil.getPlatform() in oslist,
                            "skip on %s" % (", ".join(oslist)))
开发者ID:Aj0Ay,项目名称:lldb,代码行数:6,代码来源:decorators.py


示例12:

import sys
import textwrap

from tornado.testing import bind_unused_port

# Encapsulate the choice of unittest or unittest2 here.
# To be used as 'from tornado.test.util import unittest'.
if sys.version_info < (2, 7):
    # In py26, we must always use unittest2.
    import unittest2 as unittest  # type: ignore
else:
    # Otherwise, use whichever version of unittest was imported in
    # tornado.testing.
    from tornado.testing import unittest

skipIfNonUnix = unittest.skipIf(os.name != 'posix' or sys.platform == 'cygwin',
                                "non-unix platform")

# travis-ci.org runs our tests in an overworked virtual machine, which makes
# timing-related tests unreliable.
skipOnTravis = unittest.skipIf('TRAVIS' in os.environ,
                               'timing tests unreliable on travis')

skipOnAppEngine = unittest.skipIf('APPENGINE_RUNTIME' in os.environ,
                                  'not available on Google App Engine')

# Set the environment variable NO_NETWORK=1 to disable any tests that
# depend on an external network.
skipIfNoNetwork = unittest.skipIf('NO_NETWORK' in os.environ,
                                  'network access disabled')

skipIfNoIPv6 = unittest.skipIf(not socket.has_ipv6, 'ipv6 support not present')
开发者ID:heewa,项目名称:tornado,代码行数:32,代码来源:util.py


示例13: refusing_port

import socket
import sys

from tornado.testing import bind_unused_port

# Encapsulate the choice of unittest or unittest2 here.
# To be used as 'from tornado.test.util import unittest'.
if sys.version_info < (2, 7):
    # In py26, we must always use unittest2.
    import unittest2 as unittest
else:
    # Otherwise, use whichever version of unittest was imported in
    # tornado.testing.
    from tornado.testing import unittest

skipIfNonUnix = unittest.skipIf(os.name != 'posix' or sys.platform == 'cygwin',
                                "non-unix platform")

# travis-ci.org runs our tests in an overworked virtual machine, which makes
# timing-related tests unreliable.
skipOnTravis = unittest.skipIf(True,
                               'timing tests unreliable on travis')

# Set the environment variable NO_NETWORK=1 to disable any tests that
# depend on an external network.
skipIfNoNetwork = unittest.skipIf('NO_NETWORK' in os.environ,
                                  'network access disabled')

skipIfNoIPv6 = unittest.skipIf(not socket.has_ipv6, 'ipv6 support not present')


def refusing_port():
开发者ID:grizzer,项目名称:kali-nethunter,代码行数:32,代码来源:util.py


示例14: in

        if permission == PRIVATE:
            return Authenticated in principals
        # Cliquet default authz policy uses prefixed_userid.
        prefixed = [getattr(context, 'prefixed_userid', None)]
        return USER_PRINCIPAL in (principals + prefixed)

    def principals_allowed_by_permission(self, context, permission):
        raise NotImplementedError()  # PRAGMA NOCOVER


def authorize(permits=True, authz_class=None):
    """Patch the default authorization policy to return what is specified
    in :param:permits.
    """
    if authz_class is None:
        authz_class = 'cliquet.tests.support.AllowAuthorizationPolicy'

    def wrapper(f):
        @functools.wraps(f)
        def wrapped(*args, **kwargs):
            with mock.patch(
                    '%s.permits' % authz_class,
                    return_value=permits):
                return f(*args, **kwargs)
        return wrapped
    return wrapper

skip_if_travis = unittest.skipIf('TRAVIS' in os.environ, "travis")
skip_if_no_postgresql = unittest.skipIf(psycopg2 is None,
                                        "postgresql is not installed.")
开发者ID:phrawzty,项目名称:cliquet,代码行数:30,代码来源:support.py


示例15: SkipIfCppImplementation

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:114393824,项目名称:protobuf,代码行数:4,代码来源:unknown_fields_test.py


示例16: skip_if_linux

def skip_if_linux():
    return unittest.skipIf(LINUX and SKIP_PYTHON_IMPL,
                           "not worth being tested on LINUX (pure python)")
开发者ID:sethp-jive,项目名称:psutil,代码行数:3,代码来源:test_memory_leaks.py


示例17: skipNotPOSIX

def skipNotPOSIX():
    return unittest.skipIf(os.name != 'posix',
                           'This test works only on POSIX')
开发者ID:MarekLew,项目名称:rope,代码行数:3,代码来源:testutils.py


示例18: only_for_versions_lower

def only_for_versions_lower(version):
    """Should be used as a decorator for a unittest.TestCase test method"""
    return unittest.skipIf(
        sys.version > version,
        'This test requires version of Python lower than {0}'.format(version))
开发者ID:MarekLew,项目名称:rope,代码行数:5,代码来源:testutils.py


示例19: only_for

def only_for(version):
    """Should be used as a decorator for a unittest.TestCase test method"""
    return unittest.skipIf(
        sys.version < version,
        'This test requires at least {0} version of Python.'.format(version))
开发者ID:MarekLew,项目名称:rope,代码行数:5,代码来源:testutils.py


示例20: tearDown

        settings['fxa-oauth.webapp.authorized_domains'] = ['*.firefox.com', ]

        if additional_settings is not None:
            settings.update(additional_settings)
        return settings

    def tearDown(self):
        super(BaseWebTest, self).tearDown()
        self.db.flush()


class ThreadMixin(object):

    def setUp(self):
        super(ThreadMixin, self).setUp()
        self._threads = []

    def tearDown(self):
        super(ThreadMixin, self).tearDown()

        for thread in self._threads:
            thread.join()

    def _create_thread(self, *args, **kwargs):
        thread = threading.Thread(*args, **kwargs)
        self._threads.append(thread)
        return thread


skip_if_travis = unittest.skipIf('TRAVIS' in os.environ, "travis")
开发者ID:michielbdejong,项目名称:cliquet,代码行数:30,代码来源:support.py



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
Python unittest2.skipUnless函数代码示例发布时间:2022-05-27
下一篇:
Python unittest2.skip函数代码示例发布时间: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