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


Python unittest.skipUnless方法代码示例

本文整理汇总了Python中unittest.skipUnless方法的典型用法代码示例。如果您正苦于以下问题:Python unittest.skipUnless方法的具体用法?Python unittest.skipUnless怎么用?Python unittest.skipUnless使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在unittest的用法示例。


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

示例1: test_skipping_decorators

# 需要导入模块: import unittest [as 别名]
# 或者: from unittest import skipUnless [as 别名]
def test_skipping_decorators(self):
        op_table = ((unittest.skipUnless, False, True),
                    (unittest.skipIf, True, False))
        for deco, do_skip, dont_skip in op_table:
            class Foo(unittest.TestCase):
                @deco(do_skip, "testing")
                def test_skip(self): pass

                @deco(dont_skip, "testing")
                def test_dont_skip(self): pass
            test_do_skip = Foo("test_skip")
            test_dont_skip = Foo("test_dont_skip")
            suite = unittest.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:war-and-code,项目名称:jawfish,代码行数:25,代码来源:test_skipping.py

示例2: test_ci_shippable

# 需要导入模块: import unittest [as 别名]
# 或者: from unittest import skipUnless [as 别名]
def test_ci_shippable(self):
        self.set_env(
            SHIPPABLE="true",
            BUILD_NUMBER="10",
            REPO_NAME="owner/repo",
            BRANCH="master",
            BUILD_URL="https://shippable.com/...",
            COMMIT="743b04806ea677403aa2ff26c6bdeb85005de658",
            CODECOV_TOKEN="token",
            CODECOV_NAME="name",
        )
        self.fake_report()
        res = self.run_cli()
        self.assertEqual(res["query"]["service"], "shippable")
        self.assertEqual(
            res["query"]["commit"], "743b04806ea677403aa2ff26c6bdeb85005de658"
        )
        self.assertEqual(res["query"]["build"], "10")
        self.assertEqual(res["query"]["slug"], "owner/repo")
        self.assertEqual(res["query"]["build_url"], "https://shippable.com/...")
        self.assertEqual(res["codecov"].token, "token")
        self.assertEqual(res["codecov"].name, "name")

    # @unittest.skipUnless(os.getenv('CI') == "True" and os.getenv('APPVEYOR') == 'True', 'Skip AppVeyor CI test') 
开发者ID:codecov,项目名称:codecov-python,代码行数:26,代码来源:test.py

示例3: run_unittest

# 需要导入模块: import unittest [as 别名]
# 或者: from unittest import skipUnless [as 别名]
def run_unittest(*classes):
    """Run tests from unittest.TestCase-derived classes."""
    valid_types = (unittest.TestSuite, unittest.TestCase)
    suite = unittest.TestSuite()
    for cls in classes:
        if isinstance(cls, str):
            if cls in sys.modules:
                suite.addTest(unittest.findTestCases(sys.modules[cls]))
            else:
                raise ValueError("str arguments must be keys in sys.modules")
        elif isinstance(cls, valid_types):
            suite.addTest(cls)
        else:
            suite.addTest(unittest.makeSuite(cls))
    def case_pred(test):
        if match_tests is None:
            return True
        for name in test.id().split("."):
            if fnmatch.fnmatchcase(name, match_tests):
                return True
        return False
    _filter_suite(suite, case_pred)
    _run_suite(suite)

# We don't have sysconfig on Py2.6:
# #=======================================================================
# # Check for the presence of docstrings.
# 
# HAVE_DOCSTRINGS = (check_impl_detail(cpython=False) or
#                    sys.platform == 'win32' or
#                    sysconfig.get_config_var('WITH_DOC_STRINGS'))
# 
# requires_docstrings = unittest.skipUnless(HAVE_DOCSTRINGS,
#                                           "test requires docstrings")
# 
# 
# #=======================================================================
# doctest driver. 
开发者ID:Soft8Soft,项目名称:verge3d-blender-addon,代码行数:40,代码来源:support.py

示例4: live_only

# 需要导入模块: import unittest [as 别名]
# 或者: from unittest import skipUnless [as 别名]
def live_only():
    return unittest.skipUnless(
        os.environ.get(ENV_LIVE_TEST, False),
        'This is a live only test. A live test will bypass all vcrpy components.') 
开发者ID:microsoft,项目名称:knack,代码行数:6,代码来源:decorators.py

示例5: record_only

# 需要导入模块: import unittest [as 别名]
# 或者: from unittest import skipUnless [as 别名]
def record_only():
    return unittest.skipUnless(
        not os.environ.get(ENV_LIVE_TEST, False),
        'This test is excluded from being run live. To force a recording, please remove the recording file.') 
开发者ID:microsoft,项目名称:knack,代码行数:6,代码来源:decorators.py

示例6: setUpClass

# 需要导入模块: import unittest [as 别名]
# 或者: from unittest import skipUnless [as 别名]
def setUpClass(cls):
        cwd = os.path.dirname(os.path.realpath(__file__))
        spec_dir = os.path.join(cwd, '../../openapi')
        cls.swagger_path = os.path.join(spec_dir, 'data_repository_service.swagger.yaml')
        cls.smartapi_path = os.path.join(spec_dir, 'data_repository_service.smartapi.yaml')
        cls.openapi_path = os.path.join(spec_dir, 'data_repository_service.openapi.yaml')

        # The :func:`unittest.skipUnless` calls depend on class variables,
        # which means that we can't decorate the test cases conventionally
        # and have to do so after the class variables we need are instantiated.
        openapi_dec = unittest.skipUnless(os.path.exists(cls.openapi_path), "Generated schema not found.")
        cls.test_openapi_schema_validity = openapi_dec(cls.test_openapi_schema_validity)
        smartapi_dec = unittest.skipUnless(os.path.exists(cls.smartapi_path), "Generated schema not found.")
        cls.test_smartapi_schema_validity = smartapi_dec(cls.test_smartapi_schema_validity) 
开发者ID:ga4gh,项目名称:data-repository-service-schemas,代码行数:16,代码来源:test_package.py

示例7: with_docker_executor

# 需要导入模块: import unittest [as 别名]
# 或者: from unittest import skipUnless [as 别名]
def with_docker_executor(wrapped=None):
    """Decorate unit test to run processes with the Docker executor."""
    if wrapped is None:
        return functools.partial(with_docker_executor)

    @wrapt.decorator
    def wrapper(wrapped_method, instance, args, kwargs):
        return unittest.skipUnless(*check_docker())(
            with_custom_executor(NAME="resolwe.flow.executors.docker",)(wrapped_method)
        )(*args, **kwargs)

    return wrapper(wrapped) 
开发者ID:genialis,项目名称:resolwe,代码行数:14,代码来源:utils.py

示例8: skipUnlessIronPython

# 需要导入模块: import unittest [as 别名]
# 或者: from unittest import skipUnless [as 别名]
def skipUnlessIronPython():
    """Skips the test unless currently running on IronPython"""
    return unittest.skipUnless(is_cli, 'IronPython specific test') 
开发者ID:IronLanguages,项目名称:ironpython2,代码行数:5,代码来源:ipunittest.py

示例9: need_symbol

# 需要导入模块: import unittest [as 别名]
# 或者: from unittest import skipUnless [as 别名]
def need_symbol(name):
    return unittest.skipUnless(name in ctypes_symbols,
                               '{!r} is required'.format(name)) 
开发者ID:IronLanguages,项目名称:ironpython2,代码行数:5,代码来源:__init__.py

示例10: _make_tarball

# 需要导入模块: import unittest [as 别名]
# 或者: from unittest import skipUnless [as 别名]
def _make_tarball(self, target_name):
        # creating something to tar
        tmpdir = self.mkdtemp()
        self.write_file([tmpdir, 'file1'], 'xxx')
        self.write_file([tmpdir, 'file2'], 'xxx')
        os.mkdir(os.path.join(tmpdir, 'sub'))
        self.write_file([tmpdir, 'sub', 'file3'], 'xxx')

        tmpdir2 = self.mkdtemp()
        unittest.skipUnless(splitdrive(tmpdir)[0] == splitdrive(tmpdir2)[0],
                            "source and target should be on same drive")

        base_name = os.path.join(tmpdir2, target_name)

        # working with relative paths to avoid tar warnings
        old_dir = os.getcwd()
        os.chdir(tmpdir)
        try:
            make_tarball(splitdrive(base_name)[1], '.')
        finally:
            os.chdir(old_dir)

        # check if the compressed tarball was created
        tarball = base_name + '.tar.gz'
        self.assertTrue(os.path.exists(tarball))

        # trying an uncompressed one
        base_name = os.path.join(tmpdir2, target_name)
        old_dir = os.getcwd()
        os.chdir(tmpdir)
        try:
            make_tarball(splitdrive(base_name)[1], '.', compress=None)
        finally:
            os.chdir(old_dir)
        tarball = base_name + '.tar'
        self.assertTrue(os.path.exists(tarball)) 
开发者ID:IronLanguages,项目名称:ironpython2,代码行数:38,代码来源:test_archive_util.py

示例11: test_unicode

# 需要导入模块: import unittest [as 别名]
# 或者: from unittest import skipUnless [as 别名]
def test_unicode(self):
        if not test_support.have_unicode:
            # Python 2.5 has no unittest.skipUnless
            self.skipTest('no unicode support')
        endcases = [u'', u'<\\u>', u'<\\%c>' % 0x1234, u'<\n>', u'<\\>']
        for proto in pickletester.protocols:
            for u in endcases:
                p = self.dumps(u, proto)
                u2 = self.loads(p)
                self.assertEqual(u2, u)

    # The ability to pickle recursive objects was added in 2.7.11 to fix
    # a crash in CPickle (issue #892902). 
开发者ID:IronLanguages,项目名称:ironpython2,代码行数:15,代码来源:test_xpickle.py

示例12: test_make_tarball

# 需要导入模块: import unittest [as 别名]
# 或者: from unittest import skipUnless [as 别名]
def test_make_tarball(self):
        # creating something to tar
        tmpdir = self.mkdtemp()
        self.write_file([tmpdir, 'file1'], 'xxx')
        self.write_file([tmpdir, 'file2'], 'xxx')
        os.mkdir(os.path.join(tmpdir, 'sub'))
        self.write_file([tmpdir, 'sub', 'file3'], 'xxx')

        tmpdir2 = self.mkdtemp()
        # force shutil to create the directory
        os.rmdir(tmpdir2)
        unittest.skipUnless(splitdrive(tmpdir)[0] == splitdrive(tmpdir2)[0],
                            "source and target should be on same drive")

        base_name = os.path.join(tmpdir2, 'archive')

        # working with relative paths to avoid tar warnings
        old_dir = os.getcwd()
        os.chdir(tmpdir)
        try:
            _make_tarball(splitdrive(base_name)[1], '.')
        finally:
            os.chdir(old_dir)

        # check if the compressed tarball was created
        tarball = base_name + '.tar.gz'
        self.assertTrue(os.path.exists(tarball))

        # trying an uncompressed one
        base_name = os.path.join(tmpdir2, 'archive')
        old_dir = os.getcwd()
        os.chdir(tmpdir)
        try:
            _make_tarball(splitdrive(base_name)[1], '.', compress=None)
        finally:
            os.chdir(old_dir)
        tarball = base_name + '.tar'
        self.assertTrue(os.path.exists(tarball)) 
开发者ID:dxwu,项目名称:BinderFilter,代码行数:40,代码来源:test_shutil.py

示例13: test_make_tarball

# 需要导入模块: import unittest [as 别名]
# 或者: from unittest import skipUnless [as 别名]
def test_make_tarball(self):
        # creating something to tar
        tmpdir = self.mkdtemp()
        self.write_file([tmpdir, 'file1'], 'xxx')
        self.write_file([tmpdir, 'file2'], 'xxx')
        os.mkdir(os.path.join(tmpdir, 'sub'))
        self.write_file([tmpdir, 'sub', 'file3'], 'xxx')

        tmpdir2 = self.mkdtemp()
        unittest.skipUnless(splitdrive(tmpdir)[0] == splitdrive(tmpdir2)[0],
                            "source and target should be on same drive")

        base_name = os.path.join(tmpdir2, 'archive')

        # working with relative paths to avoid tar warnings
        old_dir = os.getcwd()
        os.chdir(tmpdir)
        try:
            make_tarball(splitdrive(base_name)[1], '.')
        finally:
            os.chdir(old_dir)

        # check if the compressed tarball was created
        tarball = base_name + '.tar.gz'
        self.assertTrue(os.path.exists(tarball))

        # trying an uncompressed one
        base_name = os.path.join(tmpdir2, 'archive')
        old_dir = os.getcwd()
        os.chdir(tmpdir)
        try:
            make_tarball(splitdrive(base_name)[1], '.', compress=None)
        finally:
            os.chdir(old_dir)
        tarball = base_name + '.tar'
        self.assertTrue(os.path.exists(tarball)) 
开发者ID:ktraunmueller,项目名称:Computable,代码行数:38,代码来源:test_archive_util.py

示例14: requires_tcl

# 需要导入模块: import unittest [as 别名]
# 或者: from unittest import skipUnless [as 别名]
def requires_tcl(*version):
    return unittest.skipUnless(tcl_version >= version,
            'requires Tcl version >= ' + '.'.join(map(str, version))) 
开发者ID:aliyun,项目名称:oss-ftp,代码行数:5,代码来源:support.py

示例15: skipUnlessDom0

# 需要导入模块: import unittest [as 别名]
# 或者: from unittest import skipUnless [as 别名]
def skipUnlessDom0(test_item):
    """Decorator that skips test outside dom0.

    Some tests (especially integration tests) have to be run in more or less
    working dom0. This is checked by connecting to libvirt.
    """

    return unittest.skipUnless(in_dom0, 'outside dom0')(test_item) 
开发者ID:QubesOS,项目名称:qubes-core-admin,代码行数:10,代码来源:__init__.py


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