How to use the pytest.mark.skipif function in pytest

To help you get started, we’ve selected a few pytest 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 li012589 / NeuralRG / test / View on Github external
noCuda = 0
    p  = Popen(["nvidia-smi","--query-gpu=index,utilization.gpu,,memory.used,,driver_version,name,gpu_serial,display_active,display_mode", "--format=csv,noheader,nounits"], stdout=PIPE)
except OSError:
    noCuda = 1

maxGPU = 0
if noCuda == 0:
        p = os.popen('nvidia-smi --query-gpu=index --format=csv,noheader,nounits')
        i ='\n')
        maxGPU = int(i[-2])+1
    except OSError:
        noCuda = 1

skipIfNoCuda = pytest.mark.skipif(noCuda == 1,reason = "NO cuda insatllation, found through nvidia-smi")
skipIfOnlyOneGPU = pytest.mark.skipif(maxGPU < 2,reason = "Only one gpu")

def test_tempalte_invertibleMLP():

    print("test mlp")

    gaussian = Gaussian([2])

    sList = [MLP(2, 10), MLP(2, 10), MLP(2, 10), MLP(2, 10)]
    tList = [MLP(2, 10), MLP(2, 10), MLP(2, 10), MLP(2, 10)]

    realNVP = RealNVP([2], sList, tList, gaussian)
    x = realNVP.prior(10)
    mask = realNVP.createMask(["channel"]*4,ifByte=0)
github meuter / citizenshell / test / View on Github external
@mark.skipif(TEST_SERIAL_PORT_AVAILABLE, reason="test host not available")
def test_serialshell_by_uri():
    shell = get_serialshell_by_uri()
    assert shell("echo Hello World") == "Hello World"
github paramiko / paramiko / tests / View on Github external
from paramiko.py3compat import builtins, u

def _support(filename):
    return join(dirname(realpath(__file__)), filename)

# TODO: consider using pytest.importorskip('gssapi') instead? We presumably
# still need CLI configurability for the Kerberos parameters, though, so can't
# JUST key off presence of GSSAPI optional dependency...
# TODO: anyway, s/True/os.environ.get('RUN_GSSAPI', False)/ or something.
needs_gssapi = pytest.mark.skipif(True, reason="No GSSAPI to test")

def needs_builtin(name):
    Skip decorated test if builtin name does not exist.
    reason = "Test requires a builtin '{}'".format(name)
    return pytest.mark.skipif(not hasattr(builtins, name), reason=reason)

slow = pytest.mark.slow

utf8_password = u('\u2022')
github geopython / OWSLib / tests / View on Github external
@pytest.mark.skipif(not service_ok(SERVICE_URL),
                    reason='service is unreachable')
def test_wfs3_ldproxy():
    w = WebFeatureService(SERVICE_URL, version='3.0')

    assert w.url == ''
    assert w.version == '3.0'
    assert w.url_query_string == 'f=json'

    conformance = w.conformance()
    assert len(conformance['conformsTo']) == 5

    api = w.api()
    assert api['components']['parameters'] is not None
    assert api['paths'] is not None
github tammoippen / geopip / tests / View on Github external
@pytest.mark.skipif(not SHAPELY_ENABLED, reason='No shapely available.')
def test_p_in_polygon_rect(rect, rand_lat, rand_lng):
    rect_cw = {'type': 'Polygon', 'coordinates': [list(reversed(rect))]}
    rect = {'type': 'Polygon', 'coordinates': [rect]}

    p_rect_cw = prepare({'geometry': rect_cw, 'properties': {}})[0]
    p_rect = prepare({'geometry': rect, 'properties': {}})[0]

    # inside
    for i_ in range(100):
        p = (random(), random())
        assert p_in_polygon(p, p_rect)
        assert p_in_polygon(p, p_rect_cw)

    # outside
    for i_ in range(100):
        p = (rand_lng(), rand_lat())
github odlgroup / odl / odl / tomo / util / View on Github external
except ImportError:
    # Use the identity decorator (default of OptionalArgDecorator)
    from odl.util import OptionalArgDecorator as identity

    skip_if_no_astra = skip_if_no_astra_cuda = skip_if_no_skimage = identity

    skip_if_no_astra = pytest.mark.skipif(
        'not odl.tomo.ASTRA_AVAILABLE',
        reason='ASTRA not available',
    skip_if_no_astra_cuda = pytest.mark.skipif(
        'not odl.tomo.ASTRA_CUDA_AVAILABLE',
        reason='ASTRA CUDA not available',
    skip_if_no_skimage = pytest.mark.skipif(
        'not odl.tomo.SKIMAGE_AVAILABLE',
        reason='skimage not available',
github mlflow / mlflow / tests / onnx / View on Github external
import pandas as pd
import numpy as np
import yaml

import tensorflow as tf
import mlflow
import mlflow.keras
import mlflow.pyfunc.scoring_server as pyfunc_scoring_server
from mlflow import pyfunc
from tests.helper_functions import pyfunc_serve_and_score_model
from mlflow.tracking.artifact_utils import _download_artifact_from_uri
from mlflow.utils.environment import _mlflow_conda_env
from mlflow.utils.model_utils import _get_flavor_configuration
from tests.projects.utils import tracking_uri_mock  # pylint: disable=unused-import

pytestmark = pytest.mark.skipif(
    (sys.version_info < (3, 6)),
    reason="Tests require Python 3 to run!")

def data():
    iris = datasets.load_iris()
    data = pd.DataFrame(data=np.c_[iris['data'], iris['target']],
                        columns=iris['feature_names'] + ['target'])
    y = data['target']
    x = data.drop('target', axis=1)
    return x, y

def model(data):
github emc-openstack / storops / storops_comptest / vnx / View on Github external
@pytest.mark.skipif(not vnx.is_snap_enabled(),
                    reason='snap feature not available')
def test_delete_snap(vnx_gf):
    snap_name = vnx_gf.add_snap_name()
    snap = vnx_gf.vnx.get_snap(name=snap_name)
    assert_that(snap.existed, equal_to(False))
github mapbox / rasterio / tests / View on Github external
import affine
import boto3
import pytest

import rasterio
from rasterio.enums import Resampling
from rasterio import shutil as rio_shutil
from rasterio.vrt import WarpedVRT
from rasterio.warp import transform_bounds

from .conftest import requires_gdal21

# Custom markers.
credentials = pytest.mark.skipif(
    reason="S3 raster access requires credentials")

DST_CRS = 'EPSG:3857'

def _copy_update_profile(path_in, path_out, **kwargs):
    """Create a copy of path_in in path_out updating profile with **kwargs"""
    with as src:
        profile = src.profile.copy()
        with, 'w', **profile) as dst:
    return str(path_out)
github sherpa / sherpa / sherpa / utils / View on Github external
def requires_data(test_function):
         Decorator for functions requiring external data (i.e. data not distributed with Sherpa
         itself) is missing.  This is used to skip tests that require such data.

         See PR #391 for why this is a function:
        condition = SherpaTestCase.datadir is None
        msg = "required test data missing"
        return pytest.mark.skipif(condition, reason=msg)(test_function)