當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。