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


Python case.SkipTest方法代碼示例

本文整理匯總了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 
開發者ID:birforce,項目名稱:vnpy_crypto,代碼行數:18,代碼來源:testing.py

示例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) 
開發者ID:mozilla-services,項目名稱:autopush,代碼行數:20,代碼來源:test_integration.py

示例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"'] 
開發者ID:mozilla-services,項目名稱:autopush,代碼行數:25,代碼來源:test_integration.py

示例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) 
開發者ID:JoyMobileDevelopmentTeam,項目名稱:Joy_QA_Platform,代碼行數:25,代碼來源:runner.py

示例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 
開發者ID:rizar,項目名稱:attention-lvcsr,代碼行數:21,代碼來源:testing.py

示例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 
開發者ID:DakotaNelson,項目名稱:sneaky-creeper,代碼行數:21,代碼來源:test_rsa.py

示例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") 
開發者ID:sods,項目名稱:paramz,代碼行數:40,代碼來源:model_tests.py

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

示例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) 
開發者ID:sods,項目名稱:paramz,代碼行數:13,代碼來源:model_tests.py

示例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) 
開發者ID:sods,項目名稱:paramz,代碼行數:13,代碼來源:model_tests.py

示例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.") 
開發者ID:singhj,項目名稱:locality-sensitive-hashing,代碼行數:11,代碼來源:skip.py

示例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") 
開發者ID:mozilla-services,項目名稱:autopush,代碼行數:6,代碼來源:test_integration.py

示例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) 
開發者ID:mozilla-services,項目名稱:autopush,代碼行數:42,代碼來源:test_integration.py

示例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()) 
開發者ID:SublimeText,項目名稱:UnitTesting,代碼行數:32,代碼來源:case.py

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


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