當前位置: 首頁>>代碼示例>>Python>>正文


Python testcase.TestSkipped方法代碼示例

本文整理匯總了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() 
開發者ID:openstack,項目名稱:futurist,代碼行數:20,代碼來源:test_executors.py

示例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 
開發者ID:gnocchixyz,項目名稱:gnocchi,代碼行數:11,代碼來源:test_rest.py

示例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 
開發者ID:gnocchixyz,項目名稱:gnocchi,代碼行數:11,代碼來源:test_rest.py

示例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 
開發者ID:gnocchixyz,項目名稱:gnocchi,代碼行數:10,代碼來源:base.py

示例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 
開發者ID:openstack,項目名稱:castellan,代碼行數:12,代碼來源:test_vault_key_manager.py

示例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)) 
開發者ID:openstack,項目名稱:castellan,代碼行數:11,代碼來源:test_barbican_key_manager.py

示例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 
開發者ID:openstack,項目名稱:designate,代碼行數:14,代碼來源:__init__.py

示例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) 
開發者ID:openstack-charmers,項目名稱:vaultlocker,代碼行數:59,代碼來源:base.py


注:本文中的testtools.testcase.TestSkipped方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。