本文整理汇总了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
示例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)
示例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)
示例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))
示例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
示例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)
示例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"]))
示例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'))
示例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'))
示例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)
示例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))
示例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
示例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
示例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)
示例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')