Python unittest.case.SkipTest() Examples
The following are 30
code examples of unittest.case.SkipTest().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
unittest.case
, or try the search function
.
Example #1
Source File: test_rsa.py From sneaky-creeper with MIT License | 6 votes |
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
Example #2
Source File: testing.py From attention-lvcsr with MIT License | 6 votes |
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
Example #3
Source File: runner.py From Joy_QA_Platform with Apache License 2.0 | 6 votes |
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)
Example #4
Source File: test_integration.py From autopush with Mozilla Public License 2.0 | 6 votes |
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"']
Example #5
Source File: test_integration.py From autopush with Mozilla Public License 2.0 | 6 votes |
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)
Example #6
Source File: testing.py From vnpy_crypto with MIT License | 6 votes |
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
Example #7
Source File: test_twitter.py From sneaky-creeper with MIT License | 5 votes |
def setUp(self): configPath = os.path.join(basePath, 'config', 'twitter-config.json') try: with open(configPath, 'rb') as f: s = json.loads(f.read()) except: raise SkipTest("Could not access Twitter configuration file.") self.testParams = s['twitter'] self.client = twython.Twython( self.testParams['key'], self.testParams['secret'], self.testParams['token'], self.testParams['tsecret']) self.randText = ''.join([random.choice(string.letters) for i in range(10)]) self.channel = twitter.Twitter() for e in self.channel.params['sending']: if e.name in self.testParams: e.value = self.testParams[e.name] for e in self.channel.params['receiving']: if e.name in self.testParams: e.value = self.testParams[e.name]
Example #8
Source File: test_tumblr.py From sneaky-creeper with MIT License | 5 votes |
def setUp(self): configPath = os.path.join(basePath, 'config', 'tumblrText-config.json') try: with open(configPath, 'rb') as f: s = json.loads(f.read()) except: raise SkipTest("Could not access Tumblr configuration file.") p_list = [] for k,v in s['tumblrText'].iteritems(): p = Parameter(k, False, '') p.value = v p_list.append(p) self.params = p_list json_params = s['tumblrText'] self.json_params = json_params self.client = pytumblr.TumblrRestClient( json_params['key'], json_params['secret'], json_params['token'], json_params['token_secret'], ) self.randText = ''.join([random.choice(string.letters) for i in range(10)]) self.apiParams = {} self.apiParams['filter'] = 'raw' from sneakers.channels.tumblrText import Tumblrtext self.chan = Tumblrtext() self.chan.params['sending'] = self.params self.chan.params['receiving'] = self.params
Example #9
Source File: test_lambdify.py From symengine.py with MIT License | 5 votes |
def test_Lambdify_LLVM(): n = 7 args = x, y, z = se.symbols('x y z') if not se.have_llvm: raises(ValueError, lambda: se.Lambdify(args, [x+y+z, x**2, (x-y)/z, x*y*z], backend='llvm')) raise SkipTest("No LLVM support") L = se.Lambdify(args, [x+y+z, x**2, (x-y)/z, x*y*z], backend='llvm') assert allclose(L(range(n, n+len(args))), [3*n+3, n**2, -1/(n+2), n*(n+1)*(n+2)])
Example #10
Source File: test_twitter.py From sneaky-creeper with MIT License | 5 votes |
def test_send(self): try: self.channel.send(self.randText) except TwythonError as e: # something out of our control raise SkipTest("Twython error occurred: {}".format(e)) resp = self.client.get_user_timeline(screen_name=self.testParams['name']) if 'text' in resp[0]: self.assertEqual(resp[0]['text'], self.randText)
Example #11
Source File: test_twitter.py From sneaky-creeper with MIT License | 5 votes |
def test_receive(self): try: self.client.update_status(status=self.randText) except TwythonError as e: # something out of our control raise SkipTest("Twython error occurred: {}".format(e)) tweets = self.channel.receive() self.assertEqual(tweets[0], self.randText)
Example #12
Source File: __init__.py From fuel with MIT License | 5 votes |
def skip_if_not_available(modules=None, datasets=None, configurations=None): """Raises a SkipTest exception when requirements are not met. Parameters ---------- modules : list A list of strings of module names. If one of the modules fails to import, the test will be skipped. datasets : list A list of strings of folder names. If the data path is not configured, or the folder does not exist, the test is skipped. configurations : list A list of of strings of configuration names. If this configuration is not set and does not have a default, the test will be skipped. """ if modules is None: modules = [] if datasets is None: datasets = [] if configurations is None: configurations = [] for module in modules: try: import_module(module) except Exception: raise SkipTest if datasets and not hasattr(config, 'data_path'): raise SkipTest for dataset in datasets: try: find_in_data_path(dataset) except IOError: raise SkipTest for configuration in configurations: if not hasattr(config, configuration): raise SkipTest
Example #13
Source File: test_all.py From sneaky-creeper with MIT License | 5 votes |
def unit_channel(channel, data): """ Test a channel. """ t = sneakers.Exfil(channel, []) # get parameters from config folder configPath = os.path.join(basePath, 'config', '{}-config.json'.format(channel)) try: with open(configPath) as f: params = json.loads(f.read()) except: raise SkipTest('could not load configuration file for {}'.format(channel)) t.set_channel_params({'sending': params[channel], 'receiving': params[channel]}) try: t.send(data) except TwythonError as e: # something out of our control raise SkipTest("Twython error occurred: {}".format(e)) got = t.receive() if len(data) > 300: assert_in(data, got, 'Failed in assertion for the \'{}\' channel with a very large payload.'.format(channel)) else: assert_in(data, got) ###################################################### #################### Actual Tests #################### ######################################################
Example #14
Source File: test_mongo.py From evernote-telegram-bot with MIT License | 5 votes |
def setUp(self): self.db_name = 'test_mongo_storage' connection_string = 'mongodb://127.0.0.1:27017/?serverSelectionTimeoutMS=100' try: self.client = Mongo(connection_string, db_name=self.db_name, collection='test') list(self.client.get_all({})) except ServerSelectionTimeoutError as e: raise SkipTest(str(e))
Example #15
Source File: outcome.py From PocoUnit with Apache License 2.0 | 5 votes |
def testPartExecutor(self, test_case, isTest=False): old_success = self.success self.success = True try: yield except KeyboardInterrupt: raise except SkipTest as e: self.success = False self.skipped.append((test_case, str(e))) except _ShouldStop: pass except: exc_info = sys.exc_info() if self.expecting_failure: self.expectedFailure = exc_info else: self.success = False self.errors.append((test_case, exc_info)) # explicitly break a reference cycle: # exc_info -> frame -> exc_info exc_info = None else: if self.result_supports_subtests and self.success: self.errors.append((test_case, None)) finally: self.success = self.success and old_success
Example #16
Source File: __init__.py From attention-lvcsr with MIT License | 5 votes |
def skip_if_not_available(modules=None, datasets=None, configurations=None): """Raises a SkipTest exception when requirements are not met. Parameters ---------- modules : list A list of strings of module names. If one of the modules fails to import, the test will be skipped. datasets : list A list of strings of folder names. If the data path is not configured, or the folder does not exist, the test is skipped. configurations : list A list of of strings of configuration names. If this configuration is not set and does not have a default, the test will be skipped. """ if modules is None: modules = [] if datasets is None: datasets = [] if configurations is None: configurations = [] for module in modules: try: import_module(module) except Exception: raise SkipTest if datasets and not hasattr(config, 'data_path'): raise SkipTest for dataset in datasets: try: find_in_data_path(dataset) except IOError: raise SkipTest for configuration in configurations: if not hasattr(config, configuration): raise SkipTest
Example #17
Source File: suite.py From unishark with Apache License 2.0 | 5 votes |
def _addClassOrModuleLevelException(self, result, exception, error_name): error = FixtureErrors(error_name) addSkip = getattr(result, 'addSkip', None) if addSkip is not None and isinstance(exception, SkipTest): addSkip(error, str(exception)) else: result.addError(error, sys.exc_info())
Example #18
Source File: test_lambdify.py From symengine.py with MIT License | 5 votes |
def test_Lambdify_LLVM_with_opt_level(): for opt_level in range(4): n = 7 args = x, y, z = se.symbols('x y z') if not se.have_llvm: raises(ValueError, lambda: se.Lambdify(args, [x+y+z, x**2, (x-y)/z, x*y*z], backend='llvm', opt_level=opt_level)) raise SkipTest("No LLVM support") L = se.Lambdify(args, [x+y+z, x**2, (x-y)/z, x*y*z], backend='llvm', opt_level=opt_level) assert allclose(L(range(n, n+len(args))), [3*n+3, n**2, -1/(n+2), n*(n+1)*(n+2)])
Example #19
Source File: test_eval.py From symengine.py with MIT License | 5 votes |
def test_n_mpc(): x = sqrt(Integer(2)) + 3*I try: from symengine import ComplexMPC y = ComplexMPC('1.41421356237309504880169', '3.0', 75) assert x.n(75) == y except ImportError: raises(Exception, lambda: (x.n(75, real=True))) raises(ValueError, lambda: (x.n(75, real=False))) raises(ValueError, lambda: (x.n(75))) raise SkipTest("No MPC support")
Example #20
Source File: test_eval.py From symengine.py with MIT License | 5 votes |
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")
Example #21
Source File: case.py From UnitTesting with MIT License | 5 votes |
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())
Example #22
Source File: test_integration.py From autopush with Mozilla Public License 2.0 | 5 votes |
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)
Example #23
Source File: test_integration.py From autopush with Mozilla Public License 2.0 | 5 votes |
def setup_module(): logging.getLogger('boto').setLevel(logging.CRITICAL) if "SKIP_INTEGRATION" in os.environ: # pragma: nocover raise SkipTest("Skipping integration tests")
Example #24
Source File: skip.py From Computable with MIT License | 5 votes |
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.")
Example #25
Source File: skip.py From locality-sensitive-hashing with MIT License | 5 votes |
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.")
Example #26
Source File: model_tests.py From paramz with BSD 3-Clause "New" or "Revised" License | 5 votes |
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)
Example #27
Source File: model_tests.py From paramz with BSD 3-Clause "New" or "Revised" License | 5 votes |
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)
Example #28
Source File: model_tests.py From paramz with BSD 3-Clause "New" or "Revised" License | 5 votes |
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)
Example #29
Source File: model_tests.py From paramz with BSD 3-Clause "New" or "Revised" License | 5 votes |
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")
Example #30
Source File: testing.py From attention-lvcsr with MIT License | 4 votes |
def skip_if_not_available(modules=None, datasets=None, configurations=None): """Raises a SkipTest exception when requirements are not met. Parameters ---------- modules : list A list of strings of module names. If one of the modules fails to import, the test will be skipped. datasets : list A list of strings of folder names. If the data path is not configured, or the folder does not exist, the test is skipped. configurations : list A list of of strings of configuration names. If this configuration is not set and does not have a default, the test will be skipped. """ if modules is None: modules = [] if datasets is None: datasets = [] if configurations is None: configurations = [] for module in modules: try: import_module(module) except Exception: raise SkipTest if module == 'bokeh': ConnectionError = import_module( 'requests.exceptions').ConnectionError session = import_module('bokeh.session').Session() try: session.execute('get', session.base_url) except ConnectionError: raise SkipTest if datasets and not hasattr(config, 'data_path'): raise SkipTest for dataset in datasets: if not os.path.exists(os.path.join(config.data_path, dataset)): raise SkipTest for configuration in configurations: if not hasattr(config, configuration): raise SkipTest