本文整理汇总了Python中testtools.testcase.TestSkipped方法的典型用法代码示例。如果您正苦于以下问题:Python testcase.TestSkipped方法的具体用法?Python testcase.TestSkipped怎么用?Python testcase.TestSkipped使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类testtools.testcase
的用法示例。
在下文中一共展示了testcase.TestSkipped方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_restartable
# 需要导入模块: from testtools import testcase [as 别名]
# 或者: from testtools.testcase import TestSkipped [as 别名]
def test_restartable(self):
if not self.restartable:
raise testcase.TestSkipped("not restartable")
else:
executor = self.executor_cls(**self.executor_kwargs)
fut = executor.submit(returns_one)
self.assertEqual(1, fut.result())
executor.shutdown()
self.assertEqual(1, executor.statistics.executed)
self.assertRaises(RuntimeError, executor.submit, returns_one)
executor.restart()
self.assertEqual(0, executor.statistics.executed)
fut = executor.submit(returns_one)
self.assertEqual(1, fut.result())
self.assertEqual(1, executor.statistics.executed)
executor.shutdown()
示例2: use_another_user
# 需要导入模块: from testtools import testcase [as 别名]
# 或者: from testtools.testcase import TestSkipped [as 别名]
def use_another_user(self):
if self.auth_mode != "keystone":
raise testcase.TestSkipped("Auth mode is not Keystone")
old_token = self.token
self.token = self.VALID_TOKEN_2
try:
yield
finally:
self.token = old_token
示例3: use_invalid_token
# 需要导入模块: from testtools import testcase [as 别名]
# 或者: from testtools.testcase import TestSkipped [as 别名]
def use_invalid_token(self):
if self.auth_mode != "keystone":
raise testcase.TestSkipped("Auth mode is not Keystone")
old_token = self.token
self.token = self.INVALID_TOKEN
try:
yield
finally:
self.token = old_token
示例4: _skip_decorator
# 需要导入模块: from testtools import testcase [as 别名]
# 或者: from testtools.testcase import TestSkipped [as 别名]
def _skip_decorator(func):
@functools.wraps(func)
def skip_if_not_implemented(*args, **kwargs):
try:
return func(*args, **kwargs)
except exceptions.NotImplementedError as e:
raise testcase.TestSkipped(six.text_type(e))
return skip_if_not_implemented
示例5: _create_key_manager
# 需要导入模块: from testtools import testcase [as 别名]
# 或者: from testtools.testcase import TestSkipped [as 别名]
def _create_key_manager(self):
key_mgr = vault_key_manager.VaultKeyManager(cfg.CONF)
if ('VAULT_TEST_URL' not in os.environ or
'VAULT_TEST_ROOT_TOKEN' not in os.environ):
raise testcase.TestSkipped('Missing Vault setup information')
key_mgr._root_token_id = os.environ['VAULT_TEST_ROOT_TOKEN']
key_mgr._vault_url = os.environ['VAULT_TEST_URL']
return key_mgr
示例6: setUp
# 需要导入模块: from testtools import testcase [as 别名]
# 或者: from testtools.testcase import TestSkipped [as 别名]
def setUp(self):
super(BarbicanKeyManagerTestCase, self).setUp()
try:
self.ctxt = self.get_context()
self.key_mgr._get_barbican_client(self.ctxt)
except Exception as e:
# When we run functional-vault target, This test class needs
# to be skipped as barbican is not running
raise testcase.TestSkipped(str(e))
示例7: _skip_decorator
# 需要导入模块: from testtools import testcase [as 别名]
# 或者: from testtools.testcase import TestSkipped [as 别名]
def _skip_decorator(func):
@functools.wraps(func)
def skip_if_not_implemented(*args, **kwargs):
try:
return func(*args, **kwargs)
except NotImplementedError as e:
raise testcase.TestSkipped(str(e))
except Exception as e:
if 'not implemented' in str(e):
raise testcase.TestSkipped(str(e))
raise
return skip_if_not_implemented
示例8: setUp
# 需要导入模块: from testtools import testcase [as 别名]
# 或者: from testtools.testcase import TestSkipped [as 别名]
def setUp(self):
super(VaultlockerFuncBaseTestCase, self).setUp()
self.vault_client = None
self.vault_addr = os.environ.get('PIFPAF_VAULT_ADDR')
self.root_token = os.environ.get('PIFPAF_ROOT_TOKEN')
self.test_uuid = str(uuid.uuid4())
self.vault_backend = 'vaultlocker-test-{}'.format(self.test_uuid)
self.vault_policy = 'vaultlocker-policy-{}'.format(self.test_uuid)
self.vault_approle = 'vaultlocker-approle-{}'.format(self.test_uuid)
if not self.vault_addr or not self.root_token:
raise testcase.TestSkipped('Vault not running')
self.vault_client = hvac.Client(url=self.vault_addr,
token=self.root_token)
self.vault_client.enable_secret_backend(
backend_type='kv',
description='vault test backend',
mount_point=self.vault_backend
)
try:
self.vault_client.enable_auth_backend('approle')
except hvac.exceptions.InvalidRequest:
pass
self.vault_client.set_policy(
name=self.vault_policy,
rules=TEST_POLICY.format(backend=self.vault_backend)
)
self.vault_client.create_role(
self.vault_approle,
token_ttl='60s',
token_max_ttl='60s',
policies=[self.vault_policy],
bind_secret_id='true',
bound_cidr_list='127.0.0.1/32')
self.approle_uuid = self.vault_client.get_role_id(self.vault_approle)
self.secret_id = self.vault_client.write(
'auth/approle/role/{}/secret-id'.format(self.vault_approle)
)['data']['secret_id']
self.test_config = {
'vault': {
'url': self.vault_addr,
'approle': self.approle_uuid,
'secret_id': self.secret_id,
'backend': self.vault_backend,
}
}
self.config = mock.MagicMock()
self.config.get.side_effect = \
lambda s, k: self.test_config.get(s).get(k)