本文整理汇总了Python中pytest.skip函数的典型用法代码示例。如果您正苦于以下问题:Python skip函数的具体用法?Python skip怎么用?Python skip使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了skip函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_text
def test_text(self):
win = self.win
if self.win.winType=='pygame':
pytest.skip("Text is different on pygame")
#set font
fontFile = os.path.join(prefs.paths['resources'], 'DejaVuSerif.ttf')
#using init
stim = visual.TextStim(win,text=u'\u03A8a', color=[0.5,1.0,1.0], ori=15,
height=0.8*self.scaleFactor, pos=[0,0], font='DejaVu Serif',
fontFiles=[fontFile], autoLog=False)
stim.draw()
#compare with a LIBERAL criterion (fonts do differ)
utils.compareScreenshot('text1_%s.png' %(self.contextName), win, crit=20)
win.flip()#AFTER compare screenshot
#using set
stim.setText('y', log=False)
if sys.platform=='win32':
stim.setFont('Courier New', log=False)
else:
stim.setFont('Courier', log=False)
stim.setOri(-30.5, log=False)
stim.setHeight(1.0*self.scaleFactor, log=False)
stim.setColor([0.1,-1,0.8], colorSpace='rgb', log=False)
stim.setPos([-0.5,0.5],'+', log=False)
stim.setContrast(0.8, log=False)
stim.setOpacity(0.8, log=False)
stim.draw()
str(stim) #check that str(xxx) is working
#compare with a LIBERAL criterion (fonts do differ)
utils.compareScreenshot('text2_%s.png' %(self.contextName), win, crit=20)
示例2: test_cifar_convnet_error
def test_cifar_convnet_error(device_id):
if cntk_device(device_id).type() != DeviceKind_GPU:
pytest.skip('test only runs on GPU')
set_default_device(cntk_device(device_id))
try:
base_path = os.path.join(os.environ['CNTK_EXTERNAL_TESTDATA_SOURCE_DIRECTORY'],
*"Image/CIFAR/v0/cifar-10-batches-py".split("/"))
# N.B. CNTK_EXTERNAL_TESTDATA_SOURCE_DIRECTORY has {train,test}_map.txt
# and CIFAR-10_mean.xml in the base_path.
except KeyError:
base_path = os.path.join(os.path.dirname(os.path.abspath(__file__)),
*"../../../../Examples/Image/DataSets/CIFAR-10".split("/"))
base_path = os.path.normpath(base_path)
os.chdir(os.path.join(base_path, '..'))
from _cntk_py import set_computation_network_trace_level, set_fixed_random_seed, force_deterministic_algorithms
set_computation_network_trace_level(1)
set_fixed_random_seed(1) # BUGBUG: has no effect at present # TODO: remove debugging facilities once this all works
#force_deterministic_algorithms()
# TODO: do the above; they lead to slightly different results, so not doing it for now
reader_train = create_reader(os.path.join(base_path, 'train_map.txt'), os.path.join(base_path, 'CIFAR-10_mean.xml'), True)
reader_test = create_reader(os.path.join(base_path, 'test_map.txt'), os.path.join(base_path, 'CIFAR-10_mean.xml'), False)
test_error = convnet_cifar10_dataaug(reader_train, reader_test, max_epochs=1)
expected_test_error = 0.617
assert np.allclose(test_error, expected_test_error,
atol=TOLERANCE_ABSOLUTE)
示例3: test_pqueue_by_servicebus_client_fail_send_batch_messages
def test_pqueue_by_servicebus_client_fail_send_batch_messages(live_servicebus_config, partitioned_queue):
pytest.skip("TODO: Pending bugfix in uAMQP")
def batch_data():
for i in range(3):
yield str(i) * 1024 * 256
client = ServiceBusClient(
service_namespace=live_servicebus_config['hostname'],
shared_access_key_name=live_servicebus_config['key_name'],
shared_access_key_value=live_servicebus_config['access_key'],
debug=True)
queue_client = client.get_queue(partitioned_queue)
results = queue_client.send(BatchMessage(batch_data()))
assert len(results) == 4
assert not results[0][0]
assert isinstance(results[0][1], MessageSendFailed)
with queue_client.get_sender() as sender:
with pytest.raises(MessageSendFailed):
sender.send(BatchMessage(batch_data()))
with queue_client.get_sender() as sender:
sender.queue_message(BatchMessage(batch_data()))
results = sender.send_pending_messages()
assert len(results) == 4
assert not results[0][0]
assert isinstance(results[0][1], MessageSendFailed)
示例4: test_yy_format_with_yearfirst
def test_yy_format_with_yearfirst(self):
data = """date,time,B,C
090131,0010,1,2
090228,1020,3,4
090331,0830,5,6
"""
# See gh-217
import dateutil
if dateutil.__version__ >= LooseVersion('2.5.0'):
pytest.skip("testing yearfirst=True not-support"
"on datetutil < 2.5.0 this works but"
"is wrong")
rs = self.read_csv(StringIO(data), index_col=0,
parse_dates=[['date', 'time']])
idx = DatetimeIndex([datetime(2009, 1, 31, 0, 10, 0),
datetime(2009, 2, 28, 10, 20, 0),
datetime(2009, 3, 31, 8, 30, 0)],
dtype=object, name='date_time')
xp = DataFrame({'B': [1, 3, 5], 'C': [2, 4, 6]}, idx)
tm.assert_frame_equal(rs, xp)
rs = self.read_csv(StringIO(data), index_col=0,
parse_dates=[[0, 1]])
idx = DatetimeIndex([datetime(2009, 1, 31, 0, 10, 0),
datetime(2009, 2, 28, 10, 20, 0),
datetime(2009, 3, 31, 8, 30, 0)],
dtype=object, name='date_time')
xp = DataFrame({'B': [1, 3, 5], 'C': [2, 4, 6]}, idx)
tm.assert_frame_equal(rs, xp)
示例5: test_unary_ufunc
def test_unary_ufunc(ufunc):
if ufunc == 'fix':
pytest.skip('fix calls floor in a way that we do not yet support')
dafunc = getattr(da, ufunc)
npfunc = getattr(np, ufunc)
arr = np.random.randint(1, 100, size=(20, 20))
darr = da.from_array(arr, 3)
with pytest.warns(None): # some invalid values (arccos, arcsin, etc.)
# applying Dask ufunc doesn't trigger computation
assert isinstance(dafunc(darr), da.Array)
assert_eq(dafunc(darr), npfunc(arr), equal_nan=True)
with pytest.warns(None): # some invalid values (arccos, arcsin, etc.)
# applying NumPy ufunc is lazy
if isinstance(npfunc, np.ufunc):
assert isinstance(npfunc(darr), da.Array)
else:
assert isinstance(npfunc(darr), np.ndarray)
assert_eq(npfunc(darr), npfunc(arr), equal_nan=True)
with pytest.warns(None): # some invalid values (arccos, arcsin, etc.)
# applying Dask ufunc to normal ndarray triggers computation
assert isinstance(dafunc(arr), np.ndarray)
assert_eq(dafunc(arr), npfunc(arr), equal_nan=True)
示例6: test_pickles
def test_pickles(current_pickle_data, legacy_pickle):
if not is_platform_little_endian():
pytest.skip("known failure on non-little endian")
version = os.path.basename(os.path.dirname(legacy_pickle))
with catch_warnings(record=True):
compare(current_pickle_data, legacy_pickle, version)
示例7: srtm_login_or_skip
def srtm_login_or_skip(monkeypatch):
import os
try:
srtm_username = os.environ['SRTM_USERNAME']
except KeyError:
pytest.skip('SRTM_USERNAME environment variable is unset.')
try:
srtm_password = os.environ['SRTM_PASSWORD']
except KeyError:
pytest.skip('SRTM_PASSWORD environment variable is unset.')
from six.moves.urllib.request import (HTTPBasicAuthHandler,
HTTPCookieProcessor,
HTTPPasswordMgrWithDefaultRealm,
build_opener)
from six.moves.http_cookiejar import CookieJar
password_manager = HTTPPasswordMgrWithDefaultRealm()
password_manager.add_password(
None,
"https://urs.earthdata.nasa.gov",
srtm_username,
srtm_password)
cookie_jar = CookieJar()
opener = build_opener(HTTPBasicAuthHandler(password_manager),
HTTPCookieProcessor(cookie_jar))
monkeypatch.setattr(cartopy.io, 'urlopen', opener.open)
示例8: _skip_if_no_fenics
def _skip_if_no_fenics(param):
_, args = param
needs_fenics = len([f for f in args if "fenics" in str(f)]) > 0
from pymor.core.config import config
if needs_fenics and not config.HAVE_FENICS:
pytest.skip("skipped test due to missing Fenics")
示例9: test_run_datastore_analysis
def test_run_datastore_analysis(setup_provider, datastore, soft_assert, datastores_hosts_setup,
clear_all_tasks, appliance):
"""Tests smarthost analysis
Metadata:
test_flag: datastore_analysis
"""
# Initiate analysis
try:
datastore.run_smartstate_analysis(wait_for_task_result=True)
except MenuItemNotFound:
# TODO need to update to cover all detastores
pytest.skip('Smart State analysis is disabled for {} datastore'.format(datastore.name))
details_view = navigate_to(datastore, 'DetailsFromProvider')
# c_datastore = details_view.entities.properties.get_text_of("Datastore Type")
# Check results of the analysis and the datastore type
# TODO need to clarify datastore type difference
# soft_assert(c_datastore == datastore.type.upper(),
# 'Datastore type does not match the type defined in yaml:' +
# 'expected "{}" but was "{}"'.format(datastore.type.upper(), c_datastore))
wait_for(lambda: details_view.entities.content.get_text_of(CONTENT_ROWS_TO_CHECK[0]),
delay=15, timeout="3m",
fail_condition='0',
fail_func=appliance.server.browser.refresh)
managed_vms = details_view.entities.relationships.get_text_of('Managed VMs')
if managed_vms != '0':
for row_name in CONTENT_ROWS_TO_CHECK:
value = details_view.entities.content.get_text_of(row_name)
soft_assert(value != '0',
'Expected value for {} to be non-empty'.format(row_name))
else:
assert details_view.entities.content.get_text_of(CONTENT_ROWS_TO_CHECK[-1]) != '0'
示例10: test_encode
def test_encode(self, html_encoding_file):
_, encoding = os.path.splitext(
os.path.basename(html_encoding_file)
)[0].split('_')
try:
with open(html_encoding_file, 'rb') as fobj:
from_string = self.read_html(fobj.read(), encoding=encoding,
index_col=0).pop()
with open(html_encoding_file, 'rb') as fobj:
from_file_like = self.read_html(BytesIO(fobj.read()),
encoding=encoding,
index_col=0).pop()
from_filename = self.read_html(html_encoding_file,
encoding=encoding,
index_col=0).pop()
tm.assert_frame_equal(from_string, from_file_like)
tm.assert_frame_equal(from_string, from_filename)
except Exception:
# seems utf-16/32 fail on windows
if is_platform_windows():
if '16' in encoding or '32' in encoding:
pytest.skip()
raise
示例11: test_ascii_path
def test_ascii_path(pyi_builder):
distdir = pyi_builder._distdir
dd_ascii = distdir.encode('ascii', 'replace').decode('ascii')
if distdir != dd_ascii:
pytest.skip(reason="Default build path not ASCII, skipping...")
pyi_builder.test_script('pyi_path_encoding.py')
示例12: test_verbose_reporting
def test_verbose_reporting(self, testdir, pytestconfig):
p1 = testdir.makepyfile("""
import pytest
def test_fail():
raise ValueError()
def test_pass():
pass
class TestClass:
def test_skip(self):
pytest.skip("hello")
def test_gen():
def check(x):
assert x == 1
yield check, 0
""")
result = testdir.runpytest(p1, '-v')
result.stdout.fnmatch_lines([
"*test_verbose_reporting.py::test_fail *FAIL*",
"*test_verbose_reporting.py::test_pass *PASS*",
"*test_verbose_reporting.py::TestClass::test_skip *SKIP*",
"*test_verbose_reporting.py::test_gen*0* *FAIL*",
])
assert result.ret == 1
if not pytestconfig.pluginmanager.get_plugin("xdist"):
pytest.skip("xdist plugin not installed")
result = testdir.runpytest(p1, '-v', '-n 1')
result.stdout.fnmatch_lines([
"*FAIL*test_verbose_reporting.py::test_fail*",
])
assert result.ret == 1
示例13: test_radial
def test_radial(self):
if self.win.winType=='pygame':
pytest.skip("RadialStim dodgy on pygame")
win = self.win
#using init
wedge = visual.RadialStim(win, tex='sqrXsqr', color=1,size=2*self.scaleFactor,
visibleWedge=[0, 45], radialCycles=2, angularCycles=2, interpolate=False, autoLog=False)
wedge.draw()
thresh = 10
utils.compareScreenshot('wedge1_%s.png' %(self.contextName), win, crit=thresh)
win.flip()#AFTER compare screenshot
#using .set()
wedge.setMask('gauss', log=False)
wedge.setSize(3*self.scaleFactor, log=False)
wedge.setAngularCycles(3, log=False)
wedge.setRadialCycles(3, log=False)
wedge.setOri(180, log=False)
wedge.setContrast(0.8, log=False)
wedge.setOpacity(0.8, log=False)
wedge.setRadialPhase(0.1,operation='+', log=False)
wedge.setAngularPhase(0.1, log=False)
wedge.draw()
str(wedge) #check that str(xxx) is working
utils.compareScreenshot('wedge2_%s.png' %(self.contextName), win, crit=10.0)
示例14: test_provider_crud
def test_provider_crud(request, rest_api, from_detail):
"""Test the CRUD on provider using REST API.
Steps:
* POST /api/providers (method ``create``) <- {"hostname":..., "name":..., "type":
"EmsVmware"}
* Remember the provider ID.
* Delete it either way:
* DELETE /api/providers/<id>
* POST /api/providers (method ``delete``) <- list of dicts containing hrefs to the
providers, in this case just list with one dict.
Metadata:
test_flag: rest
"""
if "create" not in rest_api.collections.providers.action.all:
pytest.skip("Create action is not implemented in this version")
if current_version() < "5.5":
provider_type = "EmsVmware"
else:
provider_type = "ManageIQ::Providers::Vmware::InfraManager"
provider = rest_api.collections.providers.action.create(
hostname=fauxfactory.gen_alphanumeric(),
name=fauxfactory.gen_alphanumeric(),
type=provider_type,
)[0]
if from_detail:
provider.action.delete()
provider.wait_not_exists(num_sec=30, delay=0.5)
else:
rest_api.collections.providers.action.delete(provider)
provider.wait_not_exists(num_sec=30, delay=0.5)
示例15: test_solc_installation_as_function_call
def test_solc_installation_as_function_call(monkeypatch, tmpdir, platform, version):
if get_platform() != platform:
pytest.skip("Wront platform for install script")
base_install_path = str(tmpdir.mkdir("temporary-dir"))
monkeypatch.setenv('SOLC_BASE_INSTALL_PATH', base_install_path)
# sanity check that it's not already installed.
executable_path = get_executable_path(version)
assert not os.path.exists(executable_path)
install_solc(identifier=version, platform=platform)
assert os.path.exists(executable_path)
monkeypatch.setenv('SOLC_BINARY', executable_path)
extract_path = get_extract_path(version)
if os.path.exists(extract_path):
contains_so_file = any(
os.path.basename(path).partition(os.path.extsep)[2] == 'so'
for path
in os.listdir(extract_path)
)
if contains_so_file:
monkeypatch.setenv('LD_LIBRARY_PATH', extract_path)
actual_version = get_solc_version()
expected_version = semantic_version.Spec(version.lstrip('v'))
assert actual_version in expected_version