本文整理汇总了Python中pytest.skip方法的典型用法代码示例。如果您正苦于以下问题:Python pytest.skip方法的具体用法?Python pytest.skip怎么用?Python pytest.skip使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pytest
的用法示例。
在下文中一共展示了pytest.skip方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_simple_inference
# 需要导入模块: import pytest [as 别名]
# 或者: from pytest import skip [as 别名]
def test_simple_inference(self):
if not torch.cuda.is_available():
import pytest
pytest.skip('test requires GPU and torch+cuda')
ori_grad_enabled = torch.is_grad_enabled()
root_dir = os.path.dirname(os.path.dirname(__name__))
model_config = os.path.join(
root_dir, 'configs/mask_rcnn/mask_rcnn_r50_fpn_1x_coco.py')
detector = MaskRCNNDetector(model_config)
await detector.init()
img_path = os.path.join(root_dir, 'demo/demo.jpg')
bboxes, _ = await detector.apredict(img_path)
self.assertTrue(bboxes)
# asy inference detector will hack grad_enabled,
# so restore here to avoid it to influence other tests
torch.set_grad_enabled(ori_grad_enabled)
示例2: smb_real
# 需要导入模块: import pytest [as 别名]
# 或者: from pytest import skip [as 别名]
def smb_real():
# for these tests to work the server at SMB_SERVER must support dialect
# 3.1.1, without this some checks will fail as we test 3.1.1 specific
# features
username = os.environ.get('SMB_USER', None)
password = os.environ.get('SMB_PASSWORD', None)
server = os.environ.get('SMB_SERVER', None)
port = os.environ.get('SMB_PORT', 445)
share = os.environ.get('SMB_SHARE', 'share')
if username and password and server:
share = r"\\%s\%s" % (server, share)
encrypted_share = "%s-encrypted" % share
return username, password, server, int(port), share, encrypted_share
else:
pytest.skip("SMB_USER, SMB_PASSWORD, SMB_PORT, SMB_SHARE, "
"environment variables were not set, integration tests "
"will be skipped")
示例3: setUp
# 需要导入模块: import pytest [as 别名]
# 或者: from pytest import skip [as 别名]
def setUp(self):
if self._should_be_skipped_due_to_version():
pytest.skip('Test cannot run with Python %s.' % (sys.version.split(' ')[0],))
missing = []
for req in self._test_file.options['requires']:
try:
__import__(req)
except ImportError:
missing.append(req)
if missing:
pytest.skip('Requires %s to be present.' % (','.join(missing),))
if self._test_file.options['except_implementations']:
implementations = [
item.strip() for item in
self._test_file.options['except_implementations'].split(",")
]
implementation = platform.python_implementation()
if implementation in implementations:
pytest.skip(
'Test cannot run with Python implementation %r'
% (implementation, ))
示例4: __init__
# 需要导入模块: import pytest [as 别名]
# 或者: from pytest import skip [as 别名]
def __init__(self, request):
if not svnbin:
py.test.skip("svn binary required")
if not request.config.option.runslowtests:
py.test.skip('use --runslowtests to run these tests')
tmpdir = request.getfuncargvalue("tmpdir")
repodir = tmpdir.join("repo")
py.process.cmdexec('svnadmin create %s' % repodir)
if sys.platform == 'win32':
repodir = '/' + str(repodir).replace('\\', '/')
self.repo = py.path.svnurl("file://%s" % repodir)
if sys.platform == 'win32':
# remove trailing slash...
repodir = repodir[1:]
self.repopath = py.path.local(repodir)
self.temppath = tmpdir.mkdir("temppath")
self.auth = SvnAuth('johnny', 'foo', cache_auth=False,
interactive=False)
make_repo_auth(self.repopath, {'johnny': ('foo', 'rw')})
self.port, self.pid = serve_bg(self.repopath.dirpath())
# XXX caching is too global
py.path.svnurl._lsnorevcache._dict.clear()
request.addfinalizer(lambda: py.process.kill(self.pid))
示例5: test_switch
# 需要导入模块: import pytest [as 别名]
# 或者: from pytest import skip [as 别名]
def test_switch(self, setup):
import pytest
try:
import xdist
pytest.skip('#160: fails under xdist')
except ImportError:
pass
wc = py.path.svnwc(setup.temppath, auth=setup.auth)
svnurl = 'svn://localhost:%s/%s' % (setup.port, setup.repopath.basename)
wc.checkout(svnurl)
wc.ensure('foo', dir=True).ensure('foo.txt').write('foo')
wc.commit('added foo dir with foo.txt file')
wc.ensure('bar', dir=True)
wc.commit('added bar dir')
bar = wc.join('bar')
bar.switch(svnurl + '/foo')
assert bar.join('foo.txt')
示例6: test_console_log
# 需要导入模块: import pytest [as 别名]
# 或者: from pytest import skip [as 别名]
def test_console_log(conf, requests_session):
r = requests_session.get(conf.getoption("server") + "/api/v1/action/")
r.raise_for_status()
response = r.json()
# Verify we have at least one response and then grab the first record
assert len(response) >= 1
# Look for any console-log actions
cl_records = [record for record in response if record["name"] == "console-log"]
if len(cl_records) == 0:
pytest.skip("No console-log actions found")
return
record = cl_records[0]
# Does an 'action' have all the required fields?
expected_action_fields = ["name", "implementation_url", "arguments_schema"]
for field in record:
assert field in expected_action_fields
check_action_schema_format(record)
示例7: test_show_heartbeat
# 需要导入模块: import pytest [as 别名]
# 或者: from pytest import skip [as 别名]
def test_show_heartbeat(conf, requests_session):
r = requests_session.get(conf.getoption("server") + "/api/v1/action/")
r.raise_for_status()
response = r.json()
# Verify we have at least one response and then grab the first record
assert len(response) >= 1
# Let's find at least one record that is a 'show-heartbeat'
sh_records = [record for record in response if record["name"] == "show-heartbeat"]
if len(sh_records) == 0:
pytest.skip("No show-heartbeat actions found")
return
record = sh_records[0]
expected_action_fields = ["name", "implementation_url", "arguments_schema"]
for field in record:
assert field in expected_action_fields
check_action_schema_format(record)
示例8: test_recipe_history
# 需要导入模块: import pytest [as 别名]
# 或者: from pytest import skip [as 别名]
def test_recipe_history(conf, requests_session):
r = requests_session.get(conf.getoption("server") + "/api/v1/recipe/")
r.raise_for_status()
data = r.json()
if len(data) == 0:
pytest.skip("No recipes found.")
for item in data:
endpoint = f'/api/v1/recipe/{item["id"]}/history/'
r = requests_session.get(conf.getoption("server") + endpoint)
r.raise_for_status()
history = r.json()
last_date = datetime.now()
for revision in history:
created = datetime.strptime(revision["date_created"], "%Y-%m-%dT%H:%M:%S.%fZ")
assert created < last_date
last_date = created
示例9: test_recipe_read
# 需要导入模块: import pytest [as 别名]
# 或者: from pytest import skip [as 别名]
def test_recipe_read(conf, requests_session):
# Get random recipe and make sure it's valid
response = requests_session.get(urljoin(conf.getoption("server"), "/api/v3/recipe/"))
data = response.json()
if len(data["results"]) == 0:
pytest.skip("Could not find any recipes")
element = randint(0, len(data["results"]) - 1)
recipe_id = data["results"][element]["id"]
response = requests_session.get(
urljoin(conf.getoption("server"), "/api/v3/recipe/{}".format(recipe_id))
)
data = response.json()
assert response.status_code != 404
assert_valid_schema(response.json())
示例10: test_get_data_user_stage
# 需要导入模块: import pytest [as 别名]
# 或者: from pytest import skip [as 别名]
def test_get_data_user_stage(is_public_test, tmpdir, conn_cnx, db_parameters):
"""SNOW-20927: Tests Get failure with 404 error."""
if is_public_test or 'AWS_ACCESS_KEY_ID' not in os.environ:
pytest.skip('This test requires to change the internal parameter')
default_s3bucket = os.getenv('SF_AWS_USER_BUCKET',
"sfc-dev1-regression/{}/reg".format(
getuser()))
test_data = [
{
's3location':
'{}/{}'.format(
default_s3bucket, db_parameters['name'] + '_stage'),
'stage_name': db_parameters['name'] + '_stage1',
'data_file_name': 'data.txt',
},
]
for elem in test_data:
_put_list_rm_files_in_stage(tmpdir, conn_cnx, db_parameters, elem)
示例11: test_run_mutation_trials_good_binop
# 需要导入模块: import pytest [as 别名]
# 或者: from pytest import skip [as 别名]
def test_run_mutation_trials_good_binop(
bos, bod, exp_trials, parallel, single_binop_file_with_good_test, change_to_tmp
):
"""Slow test to run detection trials on a simple mutation on a binop.
Based on fixture, there is one Add operation, with 6 substitutions e.g.
sub, div, mult, pow, mod, floordiv, therefore, 6 total trials are expected for a full run
and 1 trial is expected when break on detected is used.
Args:
bos: break on survival
bod: break on detection
exp_trials: number of expected trials
single_binop_file_with_good_test: fixture for single op with a good test
"""
if sys.version_info < (3, 8) and parallel:
pytest.skip("Under version 3.8 will not run parallel tests.")
test_cmds = f"pytest {single_binop_file_with_good_test.test_file.resolve()}".split()
config = Config(
n_locations=100, break_on_survival=bos, break_on_detected=bod, multi_processing=parallel
)
results_summary = run.run_mutation_trials(
single_binop_file_with_good_test.src_file.resolve(), test_cmds=test_cmds, config=config
)
assert len(results_summary.results) == exp_trials
# in all trials the status should be detected
for mutant_trial in results_summary.results:
assert mutant_trial.return_code == 1
assert mutant_trial.status == "DETECTED"
示例12: test_run_mutation_trials_bad_binop
# 需要导入模块: import pytest [as 别名]
# 或者: from pytest import skip [as 别名]
def test_run_mutation_trials_bad_binop(
bos, bod, exp_trials, parallel, single_binop_file_with_bad_test, change_to_tmp
):
"""Slow test to run detection trials on a simple mutation on a binop.
Based on fixture, there is one Add operation, with 6 substitutions e.g.
sub, div, mult, pow, mod, floordiv, therefore, 6 total trials are expected for a full run
and 1 trial is expected when break on detected is used.
Args:
bos: break on survival
bod: break on detection
exp_trials: number of expected trials
single_binop_file_with_good_test: fixture for single op with a good test
"""
if sys.version_info < (3, 8) and parallel:
pytest.skip("Under version 3.8 will not run parallel tests.")
test_cmds = f"pytest {single_binop_file_with_bad_test.test_file.resolve()}".split()
config = Config(
n_locations=100, break_on_survival=bos, break_on_detected=bod, multi_processing=parallel
)
results_summary = run.run_mutation_trials(
single_binop_file_with_bad_test.src_file.resolve(), test_cmds=test_cmds, config=config
)
assert len(results_summary.results) == exp_trials
# in all trials the status should be survivors
for mutant_trial in results_summary.results:
assert mutant_trial.return_code == 0
assert mutant_trial.status == "SURVIVED"
示例13: _check_unicode_filesystem
# 需要导入模块: import pytest [as 别名]
# 或者: from pytest import skip [as 别名]
def _check_unicode_filesystem(tmpdir):
filename = tmpdir / ntou('☃', 'utf-8')
tmpl = 'File system encoding ({encoding}) cannot support unicode filenames'
msg = tmpl.format(encoding=sys.getfilesystemencoding())
try:
io.open(str(filename), 'w').close()
except UnicodeEncodeError:
pytest.skip(msg)
示例14: test_file_stream_deadlock
# 需要导入模块: import pytest [as 别名]
# 或者: from pytest import skip [as 别名]
def test_file_stream_deadlock(self):
if cherrypy.server.protocol_version != 'HTTP/1.1':
return self.skip()
self.PROTOCOL = 'HTTP/1.1'
# Make an initial request but abort early.
self.persistent = True
conn = self.HTTP_CONN
conn.putrequest('GET', '/bigfile', skip_host=True)
conn.putheader('Host', self.HOST)
conn.endheaders()
response = conn.response_class(conn.sock, method='GET')
response.begin()
self.assertEqual(response.status, 200)
body = response.fp.read(65536)
if body != b'x' * len(body):
self.fail("Body != 'x' * %d. Got %r instead (%d bytes)." %
(65536, body[:50], len(body)))
response.close()
conn.close()
# Make a second request, which should fetch the whole file.
self.persistent = False
self.getPage('/bigfile')
if self.body != b'x' * BIGFILE_SIZE:
self.fail("Body != 'x' * %d. Got %r instead (%d bytes)." %
(BIGFILE_SIZE, self.body[:50], len(body)))
示例15: skip
# 需要导入模块: import pytest [as 别名]
# 或者: from pytest import skip [as 别名]
def skip(self, msg='skipped '):
pytest.skip(msg)