本文整理汇总了Python中unittest.case.SkipTest方法的典型用法代码示例。如果您正苦于以下问题:Python case.SkipTest方法的具体用法?Python case.SkipTest怎么用?Python case.SkipTest使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类unittest.case
的用法示例。
在下文中一共展示了case.SkipTest方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: skip
# 需要导入模块: from unittest import case [as 别名]
# 或者: from unittest.case import SkipTest [as 别名]
def skip(reason):
def decorator(test_item):
if not hasattr(test_item, '__name__') and has_pytest:
return pytest.mark.skip(reason)
if not isinstance(test_item, SKIP_TYPES):
@functools.wraps(test_item)
def skip_wrapper(*args, **kwargs):
raise SkipTest(reason)
test_item = skip_wrapper
test_item.__unittest_skip__ = True
test_item.__unittest_skip_why__ = reason
return test_item
return decorator
示例2: test_client_cert_webpush
# 需要导入模块: from unittest import case [as 别名]
# 或者: from unittest.case import SkipTest [as 别名]
def test_client_cert_webpush(self):
try:
client = yield self.quick_register(
sslcontext=self._create_context(self.auth_client))
except ssl.SSLError as ex:
if ex.reason == "CA_MD_TOO_WEAK":
raise SkipTest("Old test cert used")
raise
yield client.disconnect()
assert client.channels
chan = client.channels.keys()[0]
yield client.send_notification()
yield client.delete_notification(chan)
result = yield client.get_notification()
assert result is None
yield self.shut_down(client)
示例3: _test_unauth
# 需要导入模块: from unittest import case [as 别名]
# 或者: from unittest.case import SkipTest [as 别名]
def _test_unauth(self, certfile):
try:
client = yield self.quick_register(
sslcontext=self._create_context(certfile))
except ssl.SSLError as ex:
if ex.reason == 'CA_MD_TOO_WEAK':
raise SkipTest("Old test cert in use")
raise
yield client.disconnect()
yield client.send_notification(status=401)
assert self.logs.logged(
lambda e: (e['log_format'] == "Failed TLS auth" and
(not certfile or
e['client_info']['tls_failed_cn'] == 'localhost')
))
response, body = yield _agent(
'DELETE',
"https://localhost:9020/m/foo",
contextFactory=self.client_SSLCF(certfile))
assert response.code == 401
wwwauth = response.headers.getRawHeaders('www-authenticate')
assert wwwauth == ['Transport mode="tls-client-certificate"']
示例4: _handle_skip_feature
# 需要导入模块: from unittest import case [as 别名]
# 或者: from unittest.case import SkipTest [as 别名]
def _handle_skip_feature(self, testcase_dict):
""" handle skip feature for testcase
- skip: skip current test unconditionally
- skipIf: skip current test if condition is true
- skipUnless: skip current test unless condition is true
"""
skip_reason = None
if "skip" in testcase_dict:
skip_reason = testcase_dict["skip"]
elif "skipIf" in testcase_dict:
skip_if_condition = testcase_dict["skipIf"]
if self.context.eval_content(skip_if_condition):
skip_reason = "{} evaluate to True".format(skip_if_condition)
elif "skipUnless" in testcase_dict:
skip_unless_condition = testcase_dict["skipUnless"]
if not self.context.eval_content(skip_unless_condition):
skip_reason = "{} evaluate to False".format(skip_unless_condition)
if skip_reason:
raise SkipTest(skip_reason)
示例5: skip_if_configuration_set
# 需要导入模块: from unittest import case [as 别名]
# 或者: from unittest.case import SkipTest [as 别名]
def skip_if_configuration_set(configuration, value, message=None):
"""Raise SkipTest if a configuration option has a certain value.
Parameters
----------
configuration : str
Configuration option to check.
value : str
Value of `blocks.config.<attribute>` which should cause
a `SkipTest` to be raised.
message : str, optional
Reason for skipping the test.
"""
if getattr(config, configuration) == value:
if message is not None:
raise SkipTest(message)
else:
raise SkipTest
示例6: setUp
# 需要导入模块: from unittest import case [as 别名]
# 或者: from unittest.case import SkipTest [as 别名]
def setUp(self):
self.randText = ''.join([random.choice(string.letters) for i in range(10)])
pubPath = os.path.join(basePath, 'config', 'test_key.pub')
privPath = os.path.join(basePath, 'config', 'test_key')
if not os.path.isfile(pubPath) or not os.path.isfile(privPath):
raise SkipTest('could not access RSA keypair in config folder')
self.rsa = Rsa()
# set some parameters
for e in self.rsa.params['sending']:
if e.name == 'publicKey':
e.value = pubPath
for e in self.rsa.params['receiving']:
if e.name == 'privateKey':
e.value = privPath
示例7: test_pydot
# 需要导入模块: from unittest import case [as 别名]
# 或者: from unittest.case import SkipTest [as 别名]
def test_pydot(self):
try:
import pydot
G = self.testmodel.build_pydot()
testmodel_node_labels = set(['testmodel',
'lengthscale',
'variance',
'Cacher(heres_johnny)\n limit=5\n \\#cached=1',
'rbf',
'Cacher(heres_johnny)\n limit=5\n \\#cached=1',
'Gaussian_noise',
'variance'])
testmodel_edges = set([tuple(e) for e in [['variance', 'Gaussian_noise'],
['Gaussian_noise', 'Cacher(heres_johnny)\n limit=5\n \\#cached=1'],
['rbf', 'rbf'],
['Gaussian_noise', 'variance'],
['testmodel', 'Gaussian_noise'],
['lengthscale', 'rbf'],
['rbf', 'lengthscale'],
['rbf', 'testmodel'],
['variance', 'rbf'],
['testmodel', 'rbf'],
['testmodel', 'testmodel'],
['Gaussian_noise', 'testmodel'],
['Gaussian_noise', 'Gaussian_noise'],
['rbf', 'variance'],
['rbf', 'Cacher(heres_johnny)\n limit=5\n \\#cached=1']]])
self.assertSetEqual(set([n.get_label() for n in G.get_nodes()]), testmodel_node_labels)
edges = set()
for e in G.get_edges():
points = e.obj_dict['points']
edges.add(tuple(G.get_node(p)[0].get_label() for p in points))
self.assertSetEqual(edges, testmodel_edges)
except ImportError:
raise SkipTest("pydot not available")
示例8: test_optimize_rprop
# 需要导入模块: from unittest import case [as 别名]
# 或者: from unittest.case import SkipTest [as 别名]
def test_optimize_rprop(self):
try:
import climin
except ImportError:
raise SkipTest("climin not installed, skipping test")
import warnings
with warnings.catch_warnings():
warnings.simplefilter("ignore")
self.testmodel.optimize('rprop', messages=1)
np.testing.assert_array_less(self.testmodel.gradient, np.ones(self.testmodel.size)*1e-2)
示例9: test_optimize_ada
# 需要导入模块: from unittest import case [as 别名]
# 或者: from unittest.case import SkipTest [as 别名]
def test_optimize_ada(self):
try:
import climin
except ImportError:
raise SkipTest("climin not installed, skipping test")
import warnings
with warnings.catch_warnings():
warnings.simplefilter("ignore")
self.testmodel.trigger_update()
self.testmodel.optimize('adadelta', messages=1, step_rate=1, momentum=1)
np.testing.assert_array_less(self.testmodel.gradient, np.ones(self.testmodel.size)*1e-2)
示例10: test_optimize_adam
# 需要导入模块: from unittest import case [as 别名]
# 或者: from unittest.case import SkipTest [as 别名]
def test_optimize_adam(self):
try:
import climin
except ImportError:
raise SkipTest("climin not installed, skipping test")
import warnings
with warnings.catch_warnings():
warnings.simplefilter("ignore")
self.testmodel.trigger_update()
self.testmodel.optimize('adam', messages=1, step_rate=1., momentum=1.)
np.testing.assert_array_less(self.testmodel.gradient, np.ones(self.testmodel.size)*1e-2)
示例11: options
# 需要导入模块: from unittest import case [as 别名]
# 或者: from unittest.case import SkipTest [as 别名]
def options(self, parser, env):
"""
Add my options to command line.
"""
env_opt = 'NOSE_WITHOUT_SKIP'
parser.add_option('--no-skip', action='store_true',
dest='noSkip', default=env.get(env_opt, False),
help="Disable special handling of SkipTest "
"exceptions.")
示例12: setup_module
# 需要导入模块: from unittest import case [as 别名]
# 或者: from unittest.case import SkipTest [as 别名]
def setup_module():
logging.getLogger('boto').setLevel(logging.CRITICAL)
if "SKIP_INTEGRATION" in os.environ: # pragma: nocover
raise SkipTest("Skipping integration tests")
示例13: test_proxy_protocol_ssl
# 需要导入模块: from unittest import case [as 别名]
# 或者: from unittest.case import SkipTest [as 别名]
def test_proxy_protocol_ssl(self):
ip = '198.51.100.22'
def proxy_request():
# like TestProxyProtocol.test_proxy_protocol, we prepend
# the proxy proto. line before the payload (which is
# encrypted in this case). HACK: sneak around httplib's
# wrapped ssl sock by hooking into SSLContext.wrap_socket
proto_line = 'PROXY TCP4 {} 203.0.113.7 35646 80\r\n'.format(ip)
class SSLContextWrapper(object):
def __init__(self, context):
self.context = context
def wrap_socket(self, sock, *args, **kwargs):
# send proto_line over the raw, unencrypted sock
sock.send(proto_line)
# now do the handshake/encrypt sock
return self.context.wrap_socket(sock, *args, **kwargs)
try:
http = httplib.HTTPSConnection(
"localhost:{}".format(self.ep.conf.proxy_protocol_port),
context=SSLContextWrapper(self._create_context(None)))
except ssl.SSLError as ex:
if ex.reason == 'CA_MD_TOO_WEAK':
raise SkipTest("Old test cert in use")
raise
try:
http.request('GET', '/v1/err')
response = http.getresponse()
return response, response.read()
finally:
http.close()
response, body = yield deferToThread(proxy_request)
assert response.status == 418
payload = json.loads(body)
assert payload['error'] == "Test Error"
assert self.logs.logged_ci(lambda ci: ci.get('remote_ip') == ip)
示例14: _executeTestPart
# 需要导入模块: from unittest import case [as 别名]
# 或者: from unittest.case import SkipTest [as 别名]
def _executeTestPart(self, function, outcome, isTest=False):
try:
deferred = function()
if isiterable(deferred):
yield from deferred
except KeyboardInterrupt:
raise
except SkipTest as e:
outcome.success = False
outcome.skipped = str(e)
except _UnexpectedSuccess:
exc_info = sys.exc_info()
outcome.success = False
if isTest:
outcome.unexpectedSuccess = exc_info
else:
outcome.errors.append(exc_info)
except _ExpectedFailure:
outcome.success = False
exc_info = sys.exc_info()
if isTest:
outcome.expectedFailure = exc_info
else:
outcome.errors.append(exc_info)
except self.failureException:
outcome.success = False
outcome.failures.append(sys.exc_info())
except Exception:
outcome.success = False
outcome.errors.append(sys.exc_info())
示例15: test_n_mpfr
# 需要导入模块: from unittest import case [as 别名]
# 或者: from unittest.case import SkipTest [as 别名]
def test_n_mpfr():
x = sqrt(Integer(2))
try:
from symengine import RealMPFR
y = RealMPFR('1.41421356237309504880169', 75)
assert x.n(75, real=True) == y
except ImportError:
raises(ValueError, lambda: (x.n(75, real=True)))
raises(ValueError, lambda: (x.n(75)))
raise SkipTest("No MPFR support")