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

Python unittest.skip函数代码示例

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

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



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

示例1: wrapped

        def wrapped(_class, simple=False, skip=None, require=None, flows=None):
            if type(_class) == FunctionType:
                _class = make_test_case_class_from_function(
                    _class,
                    simple=simple,
                    base_class=self.TestCase,
                )

            if flows:
                for method_name in loader.load_test_names_from_test_case(_class):
                    setattr(_class, method_name, _flows(*flows)(getattr(_class, method_name)))

            if skip:
                unittest.skip(skip)(_class)

            if hasattr(_class, 'REQUIRE'):
                raise RuntimeError('"REQUIRE" attribute can not be pre set')

            if require:
                setattr(_class, 'REQUIRE', require)

            self.__context.add_test_case(_class)

            logger.debug(
                'Register test case "{}" on {}'.format(
                    _class.__name__, repr(self),
                ),
            )

            return _class
开发者ID:allavlasova,项目名称:task1,代码行数:30,代码来源:base.py


示例2: needs_aws

def needs_aws(test_item):
    """
    Use as a decorator before test classes or methods to only run them if AWS usable.
    """
    test_item = _mark_test('aws', test_item)
    try:
        # noinspection PyUnresolvedReferences
        import boto
    except ImportError:
        return unittest.skip("Skipping test. Install toil with the 'aws' extra to include this "
                             "test.")(test_item)
    except:
        raise
    else:
        dot_boto_path = os.path.expanduser('~/.boto')
        dot_aws_credentials_path = os.path.expanduser('~/.aws/credentials')
        hv_uuid_path = '/sys/hypervisor/uuid'
        if (os.path.exists(dot_boto_path)
            or os.path.exists(dot_aws_credentials_path)
            # Assume that EC2 machines like the Jenkins slave that we run CI on will have IAM roles
            or os.path.exists(hv_uuid_path) and file_begins_with(hv_uuid_path,'ec2')):
            return test_item
        else:
            return unittest.skip("Skipping test. Create ~/.boto or ~/.aws/credentials to include "
                                 "this test.")(test_item)
开发者ID:awesome-python,项目名称:toil,代码行数:25,代码来源:__init__.py


示例3: decorate_it

 def decorate_it(f):
     if hide_skipped_tests:
         ret_val = unittest.skip(msg_or_f)
         ret_val.__name__ = '_pretty_skipped_function'
         return ret_val
     else:
         return unittest.skip(msg_or_f)(f)
开发者ID:SahanGH,项目名称:psi4public,代码行数:7,代码来源:__init__.py


示例4: requires_resource

def requires_resource(resource):
    if resource == "gui" and not _is_gui_available():
        return unittest.skip("resource 'gui' is not available")
    if is_resource_enabled(resource):
        return _id
    else:
        return unittest.skip("resource {0!r} is not enabled".format(resource))
开发者ID:0compute,项目名称:xtraceback,代码行数:7,代码来源:support.py


示例5: skipUnlessPG92

def skipUnlessPG92(test):
    if not connection.vendor == 'postgresql':
        return unittest.skip('PostgreSQL required')(test)
    PG_VERSION = connection.pg_version
    if PG_VERSION < 90200:
        return unittest.skip('PostgreSQL >= 9.2 required')(test)
    return test
开发者ID:calebsmith,项目名称:django,代码行数:7,代码来源:test_ranges.py


示例6: patch_wagtail_settings

def patch_wagtail_settings():
    # fix fixture paths to be absolute paths
    from wagtail import tests
    from wagtail.wagtailimages.tests import test_models
    fixture_path = os.path.join(
        os.path.dirname(tests.__file__), 'fixtures', 'test.json')
    test_models.TestUsageCount.fixtures = [fixture_path]
    test_models.TestGetUsage.fixtures = [fixture_path]
    test_models.TestGetWillowImage.fixtures = [fixture_path]
    from wagtail.wagtailimages.tests import tests
    tests.TestMissingImage.fixtures = [fixture_path]
    from wagtail.wagtailimages.tests import test_rich_text
    test_rich_text.TestImageEmbedHandler.fixtures = [fixture_path]

    # skip these test - they rely on media URL matching filename
    from wagtail.wagtailimages.tests.tests import TestMissingImage
    TestMissingImage.test_image_tag_with_missing_image = \
        unittest.skip('Unsupported')(
            TestMissingImage.test_image_tag_with_missing_image)
    TestMissingImage.test_rich_text_with_missing_image = \
        unittest.skip('Unsupported')(
            TestMissingImage.test_rich_text_with_missing_image)

    # filter these warnings
    import warnings
    warnings.simplefilter('default', DeprecationWarning)
    warnings.simplefilter('default', PendingDeprecationWarning)
开发者ID:Beyond-Digital,项目名称:django-gaekit,代码行数:27,代码来源:runtests.py


示例7: test_start_with_two_args

    def test_start_with_two_args(self):
        if not self.open_argument.startswith('/'):
            unittest.skip("Only relevant for base class")

        path = os.path.join( self.app_dir, 'dist/argv.txt')
        if os.path.exists(path):
            os.unlink(path)

        self.maxDiff = None
        path = os.path.join( self.app_dir, 'dist/BasicApp.app')

        p = subprocess.Popen(["/usr/bin/open",
                '-a', path, "--args", "one", "two", "three"])
        exit = p.wait()
        self.assertEqual(exit, 0)

        path = os.path.join( self.app_dir, 'dist/argv.txt')
        for x in range(70):     # Argv emulation can take up-to 60 seconds
            time.sleep(1)
            if os.path.exists(path):
                break

        self.assertTrue(os.path.isfile(path))

        fp = open(path, 'r')
        data = fp.read().strip()
        fp.close()

        self.assertEqual(data.strip(), repr([os.path.join(self.app_dir, 'dist/BasicApp.app/Contents/Resources/main.py'), "one", "two", "three"]))
开发者ID:EthanSeaver,项目名称:Python-Projects,代码行数:29,代码来源:test_argv_emulation.py


示例8: test_connect_kat

	def test_connect_kat(self):
		"""Testing connection to KickAssTorrent"""
		if any('kat' == providers['provider_type'] for providers in self.ts['providers']):
			self.ts.connect_provider('kat')
			self.ts.test()
		else:
			unittest.skip("KickAssTorrent is not setup".encode('utf8'))
开发者ID:kavod,项目名称:TvShowWatch-2,代码行数:7,代码来源:ConfTest.py


示例9: test_connect_t411

	def test_connect_t411(self):
		"""Testing connection to T411"""
		if any('t411' == providers['provider_type'] for providers in self.ts['providers']):
			self.ts.connect_provider('t411')
			self.ts.test()
		else:
			unittest.skip("T411 is not setup".encode('utf8'))
开发者ID:kavod,项目名称:TvShowWatch-2,代码行数:7,代码来源:ConfTest.py


示例10: needs_aws

def needs_aws(test_item):
    """
    Use as a decorator before test classes or methods to only run them if AWS usable.
    """
    test_item = _mark_test('aws', test_item)
    try:
        # noinspection PyUnresolvedReferences
        from boto import config
    except ImportError:
        return unittest.skip("Install toil with the 'aws' extra to include this test.")(test_item)
    except:
        raise
    else:
        dot_aws_credentials_path = os.path.expanduser('~/.aws/credentials')
        hv_uuid_path = '/sys/hypervisor/uuid'
        boto_credentials = config.get('Credentials', 'aws_access_key_id')
        if boto_credentials:
            return test_item
        if (os.path.exists(dot_aws_credentials_path) or
                (os.path.exists(hv_uuid_path) and file_begins_with(hv_uuid_path, 'ec2'))):
            # Assume that EC2 machines like the Jenkins slave that we run CI on will have IAM roles
            return test_item
        else:
            return unittest.skip("Configure ~/.aws/credentials with AWS credentials to include "
                                 "this test.")(test_item)
开发者ID:python-toolbox,项目名称:fork_toil,代码行数:25,代码来源:__init__.py


示例11: test_compile

    def test_compile(self):
        # type: () -> None
        """Exercise the code generator so code coverage can be measured."""
        base_dir = os.path.dirname(
            os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(__file__)))))
        src_dir = os.path.join(
            base_dir,
            'src',
        )
        idl_dir = os.path.join(src_dir, 'mongo', 'idl')

        args = idl.compiler.CompilerArgs()
        args.output_suffix = "_codecoverage_gen"
        args.import_directories = [src_dir]

        unittest_idl_file = os.path.join(idl_dir, 'unittest.idl')
        if not os.path.exists(unittest_idl_file):
            unittest.skip("Skipping IDL Generator testing since %s could not be found." %
                          (unittest_idl_file))
            return

        args.input_file = os.path.join(idl_dir, 'unittest_import.idl')
        self.assertTrue(idl.compiler.compile_idl(args))

        args.input_file = unittest_idl_file
        self.assertTrue(idl.compiler.compile_idl(args))
开发者ID:GeertBosch,项目名称:mongo,代码行数:26,代码来源:test_generator.py


示例12: skipUnlessTrue

def skipUnlessTrue(descriptor):
    if not hasattr(config, descriptor):
        return unittest.skip("%s not defined in config.py, skipping" % descriptor)
    if getattr(config, descriptor) == 0:
        return unittest.skip("%s set to False in config.py, skipping" % descriptor)
    else:
        return lambda func: func
开发者ID:denghongcai,项目名称:6lbr,代码行数:7,代码来源:test.py


示例13: __init__

 def __init__(cls, name, bases, dct):
   super(SkipTestsMeta, cls).__init__(name, bases, dct)
   if cls.__name__ == "DatastoreInputReaderBaseTest":
     unittest.skip("Skip tests when testing from the base class.")(cls)
   else:
     # Since there is no unittest.unskip(), do it manually.
     cls.__unittest_skip__ = False
     cls.__unittest_skip_why__ = None
开发者ID:Batterii,项目名称:appengine-mapreduce,代码行数:8,代码来源:datastore_input_reader_base_test.py


示例14: __init__

 def __init__(self, *args, **kwargs):
     super(OptimizedStaticFilesStorageTestsMixin, self).__init__(*args, **kwargs)
     if not self.has_environment():
         skip_message = "No {environment} present.".format(environment=self.require_environment)
         self.testCollectStatic = unittest.skip(skip_message)(self.testCollectStatic)
         self.testCollectStaticBuildProfile = unittest.skip(skip_message)(self.testCollectStaticBuildProfile)
         self.testCollectStaticStandalone = unittest.skip(skip_message)(self.testCollectStaticStandalone)
         self.testCollectStaticStandaloneBuildProfile = unittest.skip(skip_message)(self.testCollectStaticStandaloneBuildProfile)
开发者ID:YuMingChang,项目名称:MMCB,代码行数:8,代码来源:tests.py


示例15: requiresSphinx

def requiresSphinx():
    """ A decorator: a test requires Sphinx """
    if sphinxIsAvailable:
        return lambda func: func
    elif sphinxVersion is not None:
        return unittest.skip('Sphinx is too old. {} required'.format(_SPHINX_VERSION))
    else:
        return unittest.skip('Sphinx not found')
开发者ID:freason,项目名称:enki,代码行数:8,代码来源:test_preview.py


示例16: skip_unless_galaxy

def skip_unless_galaxy(min_release=None):
    """ Decorate tests with this to skip the test if Galaxy is not
    configured.
    """
    if min_release is not None:
        galaxy_release = os.environ.get('GALAXY_VERSION', None)
        if galaxy_release is not None and galaxy_release != 'dev':
            if not galaxy_release.startswith('release_'):
                raise ValueError("The value of GALAXY_VERSION environment variable should start with 'release_'")
            if not min_release.startswith('release_'):
                raise Exception("min_release should start with 'release_'")
            if galaxy_release[8:] < min_release[8:]:
                return unittest.skip(OLD_GALAXY_RELEASE % (galaxy_release, min_release))

    if 'BIOBLEND_GALAXY_URL' not in os.environ:
        return unittest.skip(NO_GALAXY_MESSAGE)

    if 'BIOBLEND_GALAXY_API_KEY' not in os.environ and 'BIOBLEND_GALAXY_MASTER_API_KEY' in os.environ:
        galaxy_url = os.environ['BIOBLEND_GALAXY_URL']
        galaxy_master_api_key = os.environ['BIOBLEND_GALAXY_MASTER_API_KEY']
        gi = bioblend.galaxy.GalaxyInstance(galaxy_url, galaxy_master_api_key)

        if 'BIOBLEND_GALAXY_USER_EMAIL' in os.environ:
            galaxy_user_email = os.environ['BIOBLEND_GALAXY_USER_EMAIL']
        else:
            galaxy_user_email = ''.join(random.choice(string.ascii_uppercase + string.digits) for _ in range(5)) + "@localhost.localdomain"

        galaxy_user_id = None
        for user in gi.users.get_users():
            if user["email"] == galaxy_user_email:
                galaxy_user_id = user["id"]
                break

        if galaxy_user_id is None:
            try:
                config = gi.config.get_config()
            except Exception:
                # If older Galaxy for instance just assume use_remote_user is False.
                config = {}

            if config.get("use_remote_user", False):
                new_user = gi.users.create_remote_user(galaxy_user_email)
            else:
                galaxy_user = galaxy_user_email.split("@", 1)[0]
                galaxy_password = ''.join(random.choice(string.ascii_uppercase + string.digits) for _ in range(20))

                # Create a new user and get a new API key for her
                new_user = gi.users.create_local_user(galaxy_user, galaxy_user_email, galaxy_password)
            galaxy_user_id = new_user["id"]

        api_key = gi.users.create_user_apikey(galaxy_user_id)
        os.environ["BIOBLEND_GALAXY_API_KEY"] = api_key

    if 'BIOBLEND_GALAXY_API_KEY' not in os.environ:
        return unittest.skip(NO_GALAXY_MESSAGE)

    return lambda f: f
开发者ID:blankenberg,项目名称:bioblend,代码行数:57,代码来源:test_util.py


示例17: test_chown

 def test_chown(self) :
     if not is_privileged :
         LogFile.write("skipping %s...\n" % inspect.stack()[0][3])
         unittest.skip("rpc-server not running as privileged user")
         return
     LogFile.write("testing %s...\n" % inspect.stack()[0][3])
     res = proxy.hpss_chown("%s/%s" % (hpss_test_dir, hpss_test_file) ,{}, 63232, 63232)
     LogFile.write("res=%s\n\n" % res)
     self.assertEqual(proxy.check_error(res)[1], "")
开发者ID:chanke,项目名称:hpss-utils,代码行数:9,代码来源:unittests.py


示例18: test_negative_update_my_account_2

 def test_negative_update_my_account_2(self):
     """
     @Feature: My Account - Negative Update
     @Test: Update My Account with invalid Surname
     @Steps:
     1. Update Current user with all variations of Surname in [2]
     @Assert: User is not updated. Appropriate error shown.
     @Status: Manual
     """
     unittest.skip(NOT_IMPLEMENTED)
开发者ID:bluesky-sgao,项目名称:robottelo,代码行数:10,代码来源:test_myaccount.py


示例19: test_getdatabase_postgres_nohostname_noport_setdefault

 def test_getdatabase_postgres_nohostname_noport_setdefault(self):
     """Check get_database set default hostname and port for MySQL"""
     try:
         db = AccessionID(dbname='taxadb', dbtype='postgres',
                          password="admin",
                          username="admin")
         self.assertEqual(int(db.get('port')), 5432)
         self.assertEqual(db.get('hostname'), 'localhost')
     except SystemExit as err:
         unittest.skip("Can't test function: %s" % str(err))
开发者ID:HadrienG,项目名称:taxa_db,代码行数:10,代码来源:test_taxadb.py


示例20: test_positive_update_my_account_5

 def test_positive_update_my_account_5(self):
     """
     @Feature: My Account - Positive Update
     @Test: Update Password/Verify fields in My Account
     @Steps:
     1. Update Password/Verify fields with all variations in [1]
     @Assert: User is updated
     @Status: Manual
     """
     unittest.skip(NOT_IMPLEMENTED)
开发者ID:bluesky-sgao,项目名称:robottelo,代码行数:10,代码来源:test_myaccount.py



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

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