How to use the nose.plugins.skip.SkipTest function in nose

To help you get started, we’ve selected a few nose examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github mongodb / mongo-python-driver / test / test_gevent.py View on Github external
Sequence:
        gr0: start a slow find()
        gr1: start a fast find()
        gr1: get results
        gr0: get results
        """
        NOT_STARTED = 0
        SUCCESS = 1
        SKIP = 2

        try:
            from multiprocessing import Value, Process
        except ImportError:
            # Python < 2.6
            raise SkipTest('No multiprocessing module')
        
        outcome = Value('i', NOT_STARTED)

        results = {
            'find_fast_result': None,
            'find_slow_result': None,
        }

        # Do test in separate process so patch_socket() doesn't affect all
        # subsequent unittests
        def do_test():
            if use_greenlets:
                try:
                    from gevent import Greenlet
                    from gevent import monkey
github oVirt / vdsm / tests / functional / networkTestsOVS.py View on Github external
def setupNetworks(self, nets, bonds, opts, **kwargs):
        if opts.pop('ovs', True):
            # setup every network as OVS network
            for net, attrs in nets.items():
                if not attrs.get('bridged', True):
                    raise SkipTest('OVS does not support bridgeless networks')
                if 'remove' not in attrs:
                    nets[net].update({'custom': {'ovs': True}})
            for bond, attrs in bonds.items():
                if 'remove' not in attrs:
                    bond_opts = bonds[bond].get('options', '').split()
                    modified = False
                    for i in range(len(bond_opts)):
                        if bond_opts[i].startswith('custom='):
                            bond_opts[i] = ('custom=%s,ovs=True' %
                                            bond_opts[i].split('=', 1)[1])
                            modified = True
                            break
                    if not modified:
                        bond_opts.append('custom=ovs=True')
                    bonds[bond]['options'] = ' '.join(bond_opts)
github ansible / ansible / test / units / modules / network / f5 / test_bigip_device_trust.py View on Github external
# -*- coding: utf-8 -*-
#
# Copyright (c) 2017 F5 Networks Inc.
# GNU General Public License v3.0 (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)

from __future__ import (absolute_import, division, print_function)
__metaclass__ = type

import os
import json
import sys

from nose.plugins.skip import SkipTest
if sys.version_info < (2, 7):
    raise SkipTest("F5 Ansible modules require Python >= 2.7")

from ansible.module_utils.basic import AnsibleModule

try:
    from library.modules.bigip_device_trust import Parameters
    from library.modules.bigip_device_trust import ModuleManager
    from library.modules.bigip_device_trust import ArgumentSpec
    from library.modules.bigip_device_trust import HAS_F5SDK

    # In Ansible 2.8, Ansible changed import paths.
    from test.units.compat import unittest
    from test.units.compat.mock import Mock
    from test.units.compat.mock import patch

    from test.units.modules.utils import set_module_args
except ImportError:
github avTranscoder / avTranscoder / test / pyTest / testTranscoderAdd.py View on Github external
import os

# Check if environment is setup to run the tests
if os.environ.get('AVTRANSCODER_TEST_AUDIO_WAVE_FILE') is None or \
    os.environ.get('AVTRANSCODER_TEST_AUDIO_MOV_FILE') is None:
    from nose.plugins.skip import SkipTest
    raise SkipTest("Need to define environment variables "
        "AVTRANSCODER_TEST_AUDIO_WAVE_FILE and "
        "AVTRANSCODER_TEST_AUDIO_MOV_FILE")

from nose.tools import *

from pyAvTranscoder import avtranscoder as av


def testAddStreamTranscoder():
    """
    Add a streamTranscoder to the Transcoder, and process rewrap of an audio stream.
    """
    # input
    inputFile = av.InputFile( os.environ['AVTRANSCODER_TEST_AUDIO_WAVE_FILE'] )
    inputIndex = 0
    inputFile.activateStream( inputIndex )
github ansible / ansible / test / units / modules / network / f5 / test_bigip_static_route.py View on Github external
from test.units.modules.utils import set_module_args
except ImportError:
    try:
        from ansible.modules.network.f5.bigip_static_route import ApiParameters
        from ansible.modules.network.f5.bigip_static_route import ModuleParameters
        from ansible.modules.network.f5.bigip_static_route import ModuleManager
        from ansible.modules.network.f5.bigip_static_route import ArgumentSpec

        # Ansible 2.8 imports
        from units.compat import unittest
        from units.compat.mock import Mock
        from units.compat.mock import patch

        from units.modules.utils import set_module_args
    except ImportError:
        raise SkipTest("F5 Ansible modules require the f5-sdk Python library")

fixture_path = os.path.join(os.path.dirname(__file__), 'fixtures')
fixture_data = {}


def load_fixture(name):
    path = os.path.join(fixture_path, name)

    if path in fixture_data:
        return fixture_data[path]

    with open(path) as f:
        data = f.read()

    try:
        data = json.loads(data)
github pycurl / pycurl / tests / util.py View on Github external
def decorated(*args, **kwargs):
        if sys.version_info[0] < 3:
            raise nose.plugins.skip.SkipTest('python < 3')

        return fn(*args, **kwargs)
github F5Networks / f5-ansible / test / unit / test_bigip_traffic_group.py View on Github external
# -*- coding: utf-8 -*-
#
# Copyright (c) 2017 F5 Networks Inc.
# GNU General Public License v3.0 (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)

from __future__ import (absolute_import, division, print_function)
__metaclass__ = type

import os
import json
import pytest
import sys

from nose.plugins.skip import SkipTest
if sys.version_info < (2, 7):
    raise SkipTest("F5 Ansible modules require Python >= 2.7")

from ansible.compat.tests import unittest
from ansible.compat.tests.mock import Mock
from ansible.compat.tests.mock import patch
from ansible.module_utils.basic import AnsibleModule

try:
    from library.modules.bigip_traffic_group import ApiParameters
    from library.modules.bigip_traffic_group import ModuleParameters
    from library.modules.bigip_traffic_group import ModuleManager
    from library.modules.bigip_traffic_group import ArgumentSpec
    from library.module_utils.network.f5.common import F5ModuleError
    from library.module_utils.network.f5.common import iControlUnexpectedHTTPError
    from test.unit.modules.utils import set_module_args
except ImportError:
    try:
github rlane / ubpf / test_framework / test_elf.py View on Github external
def check_datafile(filename):
    """
    """
    data = testdata.read(filename)
    if 'pyelf' not in data:
        raise SkipTest("no pyelf section in datafile")
    if 'result' not in data and 'error' not in data and 'error pattern' not in data:
        raise SkipTest("no result or error section in datafile")
    if not os.path.exists(VM):
        raise SkipTest("VM not found")

    elf = generate_elf(data['pyelf'])

    cmd = [VM]

    cmd.append('-')

    vm = Popen(cmd, stdin=PIPE, stdout=PIPE, stderr=PIPE)

    stdout, stderr = vm.communicate(elf)
    stderr = stderr.strip()

    if 'error' in data:
        if data['error'] != stderr:
github skoolkid / skoolkit / tests / test_disassemblies.py View on Github external
def _write_skool(self, snapshot, prefix, ctlutil=None, ctlfile=None, org=None):
        if not os.path.isfile(snapshot):
            raise SkipTest("{0} not found".format(snapshot))
        os.environ['SKOOLKIT_HOME'] = SKOOLKIT_HOME
        if ctlutil:
            output, error = self._run_cmd('{0} {1}'.format(ctlutil, snapshot))
            self.assertEqual(len(error), 0)
            ctlfile = '{0}-{1}.ctl'.format(prefix, os.getpid())
            self.write_text_file(output, ctlfile)
        options = '-c {}'.format(ctlfile)
        if org is not None:
            options += ' -o {}'.format(org)
        output, error = self.run_sna2skool('{} {}'.format(options, snapshot), out_lines=False)
        self.assertEqual(len(error), 0)
        skoolfile = '{0}-{1}.skool'.format(prefix, os.getpid())
        self.write_text_file(output, skoolfile)
        return skoolfile
github oracle / oci-ansible-modules / test / units / test_oci_load_balancer_listener.py View on Github external
import logging
from ansible.modules.cloud.oracle import oci_load_balancer, oci_load_balancer_listener
from ansible.module_utils.oracle import oci_utils, oci_lb_utils

try:
    import oci
    from oci.util import to_dict
    from oci.load_balancer.models import (
        Listener,
        SSLConfigurationDetails,
        LoadBalancer,
        ConnectionConfiguration,
    )
    from oci.exceptions import ServiceError, ClientError
except ImportError:
    raise SkipTest("test_oci_load_balancer_listener.py requires `oci` module")


class FakeModule(object):
    def __init__(self, **kwargs):
        self.params = kwargs

    def fail_json(self, *args, **kwargs):
        self.exit_args = args
        self.exit_kwargs = kwargs
        raise Exception(kwargs["msg"])

    def exit_json(self, *args, **kwargs):
        self.exit_args = args
        self.exit_kwargs = kwargs