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


Python unittest.skip函数代码示例

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


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


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