Python nose.SkipTest() Examples

The following are 30 code examples of nose.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 nose , or try the search function .
Example #1
Source File: test_helpers.py    From daf-recipes with GNU General Public License v3.0 6 votes vote down vote up
def setup_class(cls):

        if not config.get('ckan.datastore.read_url'):
            raise nose.SkipTest('Datastore runs on legacy mode, skipping...')

        engine = db._get_engine(
            {'connection_url': config['ckan.datastore.write_url']}
        )
        cls.Session = orm.scoped_session(orm.sessionmaker(bind=engine))

        datastore_test_helpers.clear_db(cls.Session)

        create_tables = [
            u'CREATE TABLE test_a (id_a text)',
            u'CREATE TABLE test_b (id_b text)',
            u'CREATE TABLE "TEST_C" (id_c text)',
            u'CREATE TABLE test_d ("α/α" integer)',
        ]
        for create_table_sql in create_tables:
            cls.Session.execute(create_table_sql) 
Example #2
Source File: broken_hammer_controller_docker.py    From rex with BSD 2-Clause "Simplified" License 6 votes vote down vote up
def test_hammer_controller_rr_tracer():
    try:
        import trraces
    except ImportError:
        raise nose.SkipTest('need trraces')

    build_docker()

    t = archr.targets.DockerImageTarget('rex_tests:hammer_controller').build().start()
    tb = archr.arsenal.RRTracerBow(t, local_trace_dir='/tmp/rex_hammer_controller_trace', symbolic_fd=0)

    crash = rex.Crash(t, b"\x41"*120 + b'\n', aslr=False, tracer_bow=tb)

    exploit = crash.exploit()
    assert 'rop_chess_control' in exploit.arsenal
    exploit.arsenal['rop_chess_control'].script()
    exploit.arsenal['rop_chess_control'].script("x2.py") 
Example #3
Source File: test__datasource.py    From Computable with MIT License 6 votes vote down vote up
def test_ValidGzipFile(self):
        try:
            import gzip
        except ImportError:
            # We don't have the gzip capabilities to test.
            import nose
            raise nose.SkipTest
        # Test datasource's internal file_opener for Gzip files.
        filepath = os.path.join(self.tmpdir, 'foobar.txt.gz')
        fp = gzip.open(filepath, 'w')
        fp.write(magic_line)
        fp.close()
        fp = self.ds.open(filepath)
        result = fp.readline()
        fp.close()
        self.assertEqual(magic_line, result) 
Example #4
Source File: test_sparse.py    From Computable with MIT License 6 votes vote down vote up
def test_binary_operators(self):

        # skipping for now #####
        raise nose.SkipTest("skipping sparse binary operators test")

        def _check_inplace_op(iop, op):
            tmp = self.bseries.copy()

            expected = op(tmp, self.bseries)
            iop(tmp, self.bseries)
            assert_sp_series_equal(tmp, expected)

        inplace_ops = ['add', 'sub', 'mul', 'truediv', 'floordiv', 'pow']
        for op in inplace_ops:
            _check_inplace_op(
                getattr(operator, "i%s" % op), getattr(operator, op)) 
Example #5
Source File: test_geocode.py    From cesiumpy with Apache License 2.0 6 votes vote down vote up
def test_viewer(self):
        try:
            viewer = cesiumpy.Viewer(divid='viewertest')
            cyl = cesiumpy.Cylinder(position='Los Angeles', length=30000, topRadius=10000,
                                    bottomRadius=10000, material='AQUA')
            viewer.entities.add(cyl)
            viewer.camera.flyTo('Los Angeles')
            result = viewer.to_html()

            exp = """<script src="https://cesiumjs.org/Cesium/Build/Cesium/Cesium.js"></script>
<link rel="stylesheet" href="https://cesiumjs.org/Cesium/Build/Cesium/Widgets/widgets.css" type="text/css">
<div id="viewertest" style="width:100%; height:100%;"><div>
<script type="text/javascript">
  var widget = new Cesium.Viewer("viewertest");
  widget.entities.add({position : Cesium.Cartesian3.fromDegrees(-118.2436849, 34.0522342, 0.0), cylinder : {length : 30000.0, topRadius : 10000.0, bottomRadius : 10000.0, material : Cesium.Color.AQUA}});
  widget.camera.flyTo({destination : Cesium.Cartesian3.fromDegrees(-118.2436849, 34.0522342, 100000.0)});
</script>"""
            self.assertEqual(result, exp)
        except geopy.exc.GeocoderQuotaExceeded:
            raise nose.SkipTest("exceeded geocoder quota") 
Example #6
Source File: iptest.py    From Computable with MIT License 6 votes vote down vote up
def monkeypatch_xunit():
    try:
        knownfailureif(True)(lambda: None)()
    except Exception as e:
        KnownFailureTest = type(e)

    def addError(self, test, err, capt=None):
        if issubclass(err[0], KnownFailureTest):
            err = (SkipTest,) + err[1:]
        return self.orig_addError(test, err, capt)

    Xunit.orig_addError = Xunit.addError
    Xunit.addError = addError

#-----------------------------------------------------------------------------
# Logic for skipping doctests
#----------------------------------------------------------------------------- 
Example #7
Source File: decorators.py    From Computable with MIT License 6 votes vote down vote up
def skip(msg=None):
    """Decorator factory - mark a test function for skipping from test suite.

    Parameters
    ----------
      msg : string
        Optional message to be added.

    Returns
    -------
       decorator : function
         Decorator, which, when applied to a function, causes SkipTest
         to be raised, with the optional message added.
      """

    return skipif(True,msg) 
Example #8
Source File: test_index.py    From daf-recipes with GNU General Public License v3.0 6 votes vote down vote up
def setup_class(cls):

        if not search.is_available():
            raise nose.SkipTest('Solr not reachable')

        cls.solr_client = search.make_connection()

        cls.fq = " +site_id:\"%s\" " % config['ckan.site_id']

        cls.package_index = search.PackageSearchIndex()

        cls.base_package_dict = {
            'id': 'test-index',
            'name': 'monkey',
            'title': 'Monkey',
            'state': 'active',
            'private': False,
            'type': 'dataset',
            'owner_org': None,
            'metadata_created': datetime.datetime.now().isoformat(),
            'metadata_modified': datetime.datetime.now().isoformat(),
        } 
Example #9
Source File: test__datasource.py    From Computable with MIT License 6 votes vote down vote up
def test_ValidBz2File(self):
        try:
            import bz2
        except ImportError:
            # We don't have the bz2 capabilities to test.
            import nose
            raise nose.SkipTest
        # Test datasource's internal file_opener for BZip2 files.
        filepath = os.path.join(self.tmpdir, 'foobar.txt.bz2')
        fp = bz2.BZ2File(filepath, 'w')
        fp.write(magic_line)
        fp.close()
        fp = self.ds.open(filepath)
        result = fp.readline()
        fp.close()
        self.assertEqual(magic_line, result) 
Example #10
Source File: test_decorators.py    From Computable with MIT License 6 votes vote down vote up
def test_skip_functions_hardcoded():
    @dec.skipif(True)
    def f1(x):
        raise DidntSkipException

    try:
        f1('a')
    except DidntSkipException:
        raise Exception('Failed to skip')
    except nose.SkipTest:
        pass

    @dec.skipif(False)
    def f2(x):
        raise DidntSkipException

    try:
        f2('a')
    except DidntSkipException:
        pass
    except nose.SkipTest:
        raise Exception('Skipped when not expected to') 
Example #11
Source File: test_geocode.py    From cesiumpy with Apache License 2.0 6 votes vote down vote up
def test_geocode(self):
        try:
            result = cesiumpy.geocode._maybe_geocode('Los Angeles')
            self.assertEqual(result, (-118.2436849, 34.0522342))

            result = cesiumpy.geocode._maybe_geocode(['Los Angeles', 'Las Vegas'])
            self.assertEqual(result, [(-118.2436849, 34.0522342), (-115.1398296, 36.1699412)])

            result = cesiumpy.geocode._maybe_geocode(['Los Angeles', 'Las Vegas', [1, 2]])
            self.assertEqual(result, [(-118.2436849, 34.0522342), (-115.1398296, 36.1699412), [1, 2]])

            # do not convert
            result = cesiumpy.geocode._maybe_geocode(3)
            self.assertEqual(result, 3)

            result = cesiumpy.geocode._maybe_geocode('xxxxx_str_unable_to_be_converted_xxxxxx')
            self.assertEqual(result, 'xxxxx_str_unable_to_be_converted_xxxxxx')
        except geopy.exc.GeocoderQuotaExceeded:
            raise nose.SkipTest("exceeded geocoder quota") 
Example #12
Source File: testing.py    From vnpy_crypto with MIT License 6 votes vote down vote up
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 #13
Source File: test_loader.py    From Computable with MIT License 5 votes vote down vote up
def test_unicode_bytes_args(self):
        uarg = u'--a=é'
        try:
            barg = uarg.encode(sys.stdin.encoding)
        except (TypeError, UnicodeEncodeError):
            raise SkipTest("sys.stdin.encoding can't handle 'é'")
        
        cl = self.klass()
        with mute_warn():
            config = cl.load_config([barg])
        self.assertEqual(config.a, u'é') 
Example #14
Source File: test_dump.py    From daf-recipes with GNU General Public License v3.0 5 votes vote down vote up
def setup_class(cls):
        wsgiapp = middleware.make_app(config['global_conf'], **config)
        cls.app = paste.fixture.TestApp(wsgiapp)
        if not tests.is_datastore_supported():
            raise nose.SkipTest("Datastore not supported")
        p.load('datastore')
        ctd.CreateTestData.create()
        cls.sysadmin_user = model.User.get('testsysadmin')
        cls.normal_user = model.User.get('annafan')
        resource = model.Package.get('annakarenina').resources[0]
        cls.data = {
            'resource_id': resource.id,
            'force': True,
            'aliases': 'books',
            'fields': [{'id': u'b\xfck', 'type': 'text'},
                       {'id': 'author', 'type': 'text'},
                       {'id': 'published'},
                       {'id': u'characters', u'type': u'_text'},
                       {'id': 'random_letters', 'type': 'text[]'}],
            'records': [{u'b\xfck': 'annakarenina',
                         'author': 'tolstoy',
                         'published': '2005-03-01',
                         'nested': ['b', {'moo': 'moo'}],
                         u'characters': [u'Princess Anna', u'Sergius'],
                         'random_letters': ['a', 'e', 'x']},
                        {u'b\xfck': 'warandpeace', 'author': 'tolstoy',
                         'nested': {'a': 'b'}, 'random_letters': []}]
        }
        postparams = '%s=1' % json.dumps(cls.data)
        auth = {'Authorization': str(cls.sysadmin_user.apikey)}
        res = cls.app.post('/api/action/datastore_create', params=postparams,
                           extra_environ=auth)
        res_dict = json.loads(res.body)
        assert res_dict['success'] is True

        engine = db._get_engine({
            'connection_url': config['ckan.datastore.write_url']})
        cls.Session = orm.scoped_session(orm.sessionmaker(bind=engine)) 
Example #15
Source File: test_resample.py    From Computable with MIT License 5 votes vote down vote up
def _skip_if_no_pytz():
    try:
        import pytz
    except ImportError:
        raise nose.SkipTest("pytz not installed") 
Example #16
Source File: test_console.py    From Computable with MIT License 5 votes vote down vote up
def test_console_starts():
    """test that `ipython console` starts a terminal"""
    from IPython.external import pexpect
    
    args = ['console', '--colors=NoColor']
    # FIXME: remove workaround for 2.6 support
    if sys.version_info[:2] > (2,6):
        args = ['-m', 'IPython'] + args
        cmd = sys.executable
    else:
        cmd = 'ipython'
    
    try:
        p = pexpect.spawn(cmd, args=args)
    except IOError:
        raise SkipTest("Couldn't find command %s" % cmd)
    
    # timeout after one minute
    t = 60
    idx = p.expect([r'In \[\d+\]', pexpect.EOF], timeout=t)
    p.sendline('5')
    idx = p.expect([r'Out\[\d+\]: 5', pexpect.EOF], timeout=t)
    idx = p.expect([r'In \[\d+\]', pexpect.EOF], timeout=t)
    # send ctrl-D;ctrl-D to exit
    p.sendeof()
    p.sendeof()
    p.expect([pexpect.EOF, pexpect.TIMEOUT], timeout=t)
    if p.isalive():
        p.terminate() 
Example #17
Source File: test_launcher.py    From Computable with MIT License 5 votes vote down vote up
def test_cluster_id_arg(self):
        raise SkipTest("SSH Launchers don't support cluster ID") 
Example #18
Source File: test_sparse.py    From Computable with MIT License 5 votes vote down vote up
def test_operators_corner2(self):
        raise nose.SkipTest('known failer on numpy 1.5.1')

        # NumPy circumvents __r*__ operations
        val = np.float64(3.0)
        result = val - self.zbseries
        assert_sp_series_equal(result, 3 - self.zbseries) 
Example #19
Source File: test_daterange.py    From Computable with MIT License 5 votes vote down vote up
def _skip_if_no_cday():
    if datetools.cday is None:
        raise nose.SkipTest("CustomBusinessDay not available.") 
Example #20
Source File: test_timeseries.py    From Computable with MIT License 5 votes vote down vote up
def _skip_if_has_locale():
    import locale
    lang, _ = locale.getlocale()
    if lang is not None:
        raise nose.SkipTest("Specific locale is set {0}".format(lang)) 
Example #21
Source File: test_unit.py    From daf-recipes with GNU General Public License v3.0 5 votes vote down vote up
def test_pg_version_check(self):
        if not tests.is_datastore_supported():
            raise nose.SkipTest("Datastore not supported")
        engine = db._get_engine(
            {'connection_url': config['sqlalchemy.url']})
        connection = engine.connect()
        assert db._pg_version_is_at_least(connection, '8.0')
        assert not db._pg_version_is_at_least(connection, '10.0') 
Example #22
Source File: test_upsert.py    From daf-recipes with GNU General Public License v3.0 5 votes vote down vote up
def setup_class(cls):
        if not tests.is_datastore_supported():
            raise nose.SkipTest("Datastore not supported")
        p.load('datastore')
        ctd.CreateTestData.create()
        cls.sysadmin_user = model.User.get('testsysadmin')
        cls.normal_user = model.User.get('annafan')
        set_url_type(
            model.Package.get('annakarenina').resources, cls.sysadmin_user)
        resource = model.Package.get('annakarenina').resources[0]
        hhguide = u"hitchhiker's guide to the galaxy"
        cls.data = {
            'resource_id': resource.id,
            'fields': [{'id': u'b\xfck', 'type': 'text'},
                       {'id': 'author', 'type': 'text'},
                       {'id': 'nested', 'type': 'json'},
                       {'id': 'characters', 'type': 'text[]'},
                       {'id': 'published'}],
            'primary_key': u'b\xfck',
            'records': [{u'b\xfck': 'annakarenina', 'author': 'tolstoy',
                        'published': '2005-03-01', 'nested': ['b', {'moo': 'moo'}]},
                        {u'b\xfck': 'warandpeace', 'author': 'tolstoy',
                        'nested': {'a':'b'}},
                        {'author': 'adams',
                        'characters': ['Arthur Dent', 'Marvin'],
                        'nested': {'foo': 'bar'},
                        u'b\xfck': hhguide}
                       ]
            }
        postparams = '%s=1' % json.dumps(cls.data)
        auth = {'Authorization': str(cls.sysadmin_user.apikey)}
        res = cls.app.post('/api/action/datastore_create', params=postparams,
                           extra_environ=auth)
        res_dict = json.loads(res.body)
        assert res_dict['success'] is True

        engine = db._get_engine(
            {'connection_url': config['ckan.datastore.write_url']})
        cls.Session = orm.scoped_session(orm.sessionmaker(bind=engine)) 
Example #23
Source File: test_upsert.py    From daf-recipes with GNU General Public License v3.0 5 votes vote down vote up
def setup_class(cls):
        if not tests.is_datastore_supported():
            raise nose.SkipTest("Datastore not supported")
        p.load('datastore')
        ctd.CreateTestData.create()
        cls.sysadmin_user = model.User.get('testsysadmin')
        cls.normal_user = model.User.get('annafan')
        set_url_type(
            model.Package.get('annakarenina').resources, cls.sysadmin_user)
        resource = model.Package.get('annakarenina').resources[0]
        cls.data = {
            'resource_id': resource.id,
            'fields': [{'id': u'b\xfck', 'type': 'text'},
                       {'id': 'author', 'type': 'text'},
                       {'id': 'nested', 'type': 'json'},
                       {'id': 'characters', 'type': 'text[]'},
                       {'id': 'published'}],
            'primary_key': u'b\xfck',
            'records': [{u'b\xfck': 'annakarenina', 'author': 'tolstoy',
                        'published': '2005-03-01', 'nested': ['b', {'moo': 'moo'}]},
                        {u'b\xfck': 'warandpeace', 'author': 'tolstoy',
                        'nested': {'a':'b'}}
                       ]
            }
        postparams = '%s=1' % json.dumps(cls.data)
        auth = {'Authorization': str(cls.sysadmin_user.apikey)}
        res = cls.app.post('/api/action/datastore_create', params=postparams,
                           extra_environ=auth)
        res_dict = json.loads(res.body)
        assert res_dict['success'] is True

        engine = db._get_engine(
            {'connection_url': config['ckan.datastore.write_url']})
        cls.Session = orm.scoped_session(orm.sessionmaker(bind=engine)) 
Example #24
Source File: test_upsert.py    From daf-recipes with GNU General Public License v3.0 5 votes vote down vote up
def setup_class(cls):
        if not tests.is_datastore_supported():
            raise nose.SkipTest("Datastore not supported")
        p.load('datastore')
        ctd.CreateTestData.create()
        cls.sysadmin_user = model.User.get('testsysadmin')
        cls.normal_user = model.User.get('annafan')
        set_url_type(
            model.Package.get('annakarenina').resources, cls.sysadmin_user)
        resource = model.Package.get('annakarenina').resources[0]
        cls.data = {
            'resource_id': resource.id,
            'fields': [{'id': u'b\xfck', 'type': 'text'},
                       {'id': 'author', 'type': 'text'},
                       {'id': 'nested', 'type': 'json'},
                       {'id': 'characters', 'type': 'text[]'},
                       {'id': 'published'}],
            'primary_key': u'b\xfck',
            'records': [{u'b\xfck': 'annakarenina', 'author': 'tolstoy',
                        'published': '2005-03-01', 'nested': ['b', {'moo': 'moo'}]},
                        {u'b\xfck': 'warandpeace', 'author': 'tolstoy',
                        'nested': {'a':'b'}}
                       ]
            }
        postparams = '%s=1' % json.dumps(cls.data)
        auth = {'Authorization': str(cls.sysadmin_user.apikey)}
        res = cls.app.post('/api/action/datastore_create', params=postparams,
                           extra_environ=auth)
        res_dict = json.loads(res.body)
        assert res_dict['success'] is True

        engine = db._get_engine(
            {'connection_url': config['ckan.datastore.write_url']})
        cls.Session = orm.scoped_session(orm.sessionmaker(bind=engine)) 
Example #25
Source File: test_default_views.py    From daf-recipes with GNU General Public License v3.0 5 votes vote down vote up
def setup_class(cls):
        if not is_datastore_supported():
            raise nose.SkipTest('Datastore not supported')
        if not p.plugin_loaded('datastore'):
            p.load('datastore')
        if not p.plugin_loaded('datapusher'):
            p.load('datapusher')
        if not p.plugin_loaded('recline_grid_view'):
            p.load('recline_grid_view')

        helpers.reset_db() 
Example #26
Source File: test.py    From daf-recipes with GNU General Public License v3.0 5 votes vote down vote up
def setup_class(cls):
        wsgiapp = middleware.make_app(config['global_conf'], **config)
        cls.app = paste.fixture.TestApp(wsgiapp)
        if not tests.is_datastore_supported():
            raise nose.SkipTest("Datastore not supported")
        p.load('datastore')
        p.load('datapusher')
        ctd.CreateTestData.create()
        cls.sysadmin_user = model.User.get('testsysadmin')
        cls.normal_user = model.User.get('annafan')
        engine = db._get_engine(
            {'connection_url': config['ckan.datastore.write_url']})
        cls.Session = orm.scoped_session(orm.sessionmaker(bind=engine))
        set_url_type(
            model.Package.get('annakarenina').resources, cls.sysadmin_user) 
Example #27
Source File: test_solr_package_search.py    From daf-recipes with GNU General Public License v3.0 5 votes vote down vote up
def test_1_filtered(self):
        # TODO: solr is not currently set up to allow partial matches
        #       and extras are not saved as multivalued so this
        #       test will fail. Make multivalued or remove?
        from ckan.tests.legacy import SkipTest
        raise SkipTest

        self._filtered_search(u'england', ['eng', 'eng_ni', 'uk', 'gb'], 4) 
Example #28
Source File: test_solr_search_index.py    From daf-recipes with GNU General Public License v3.0 5 votes vote down vote up
def test_solr_url_exists(self):
        if not is_search_supported():
            from nose import SkipTest
            raise SkipTest("Search not supported")

        conn = search.make_connection()
        try:
            # solr.SolrConnection.query will throw a socket.error if it
            # can't connect to the SOLR instance
            q = conn.search(q="*:*", rows=1)
        except pysolr.SolrError, e:
            if not config.get('solr_url'):
                raise AssertionError("Config option 'solr_url' needs to be defined in this CKAN's development.ini. Default of %s didn't work: %s" % (search.DEFAULT_SOLR_URL, e))
            else:
                raise AssertionError('SOLR connection problem. Connection defined in development.ini as: solr_url=%s Error: %s' % (config['solr_url'], e)) 
Example #29
Source File: test_activity.py    From daf-recipes with GNU General Public License v3.0 5 votes vote down vote up
def setup_class(self):
        if not asbool(config.get('ckan.activity_streams_enabled', 'true')):
            raise SkipTest('Activity streams not enabled')
        import ckan
        import ckan.model as model
        tests.CreateTestData.create()
        sysadmin_user = model.User.get('testsysadmin')
        self.sysadmin_user = {
                'id': sysadmin_user.id,
                'apikey': sysadmin_user.apikey,
                'name': sysadmin_user.name,
                }
        normal_user = model.User.get('annafan')

        self.normal_user = {
                'id': normal_user.id,
                'apikey': normal_user.apikey,
                'name': normal_user.name,
                }
        warandpeace = model.Package.get('warandpeace')
        self.warandpeace = {
                'id': warandpeace.id,
                }
        annakarenina = model.Package.get('annakarenina')
        self.annakarenina = {
                'id': annakarenina.id,
                }
        self.users = [self.sysadmin_user, self.normal_user]
        self.app = paste.fixture.TestApp(pylons.test.pylonsapp) 
Example #30
Source File: segmentation.py    From razzy-spinner with GNU General Public License v3.0 5 votes vote down vote up
def setup_module(module):
    from nose import SkipTest
    try:
        import numpy
    except ImportError:
        raise SkipTest("numpy is required for nltk.metrics.segmentation")