本文整理汇总了Python中pytest.xfail方法的典型用法代码示例。如果您正苦于以下问题:Python pytest.xfail方法的具体用法?Python pytest.xfail怎么用?Python pytest.xfail使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pytest
的用法示例。
在下文中一共展示了pytest.xfail方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_status_update
# 需要导入模块: import pytest [as 别名]
# 或者: from pytest import xfail [as 别名]
def test_status_update(self, path1):
# not a mark because the global "pytestmark" will end up overwriting a mark here
pytest.xfail("svn-1.7 has buggy 'status --xml' output")
r = path1
try:
r.update(rev=1)
s = r.status(updates=1, rec=1)
# Comparing just the file names, because paths are unpredictable
# on Windows. (long vs. 8.3 paths)
import pprint
pprint.pprint(s.allpath())
assert r.join('anotherfile').basename in [item.basename for
item in s.update_available]
#assert len(s.update_available) == 1
finally:
r.update()
示例2: test_incdec
# 需要导入模块: import pytest [as 别名]
# 或者: from pytest import xfail [as 别名]
def test_incdec(self, incdec, value, url, config_stub):
if (value == '{}foo' and
url == 'http://example.com/path with {} spaces'):
pytest.xfail("https://github.com/qutebrowser/qutebrowser/issues/4917")
config_stub.val.url.incdec_segments = ['host', 'path', 'query',
'anchor']
# The integer used should not affect test output, as long as it's
# bigger than 1
# 20 was chosen by dice roll, guaranteed to be random
base_value = value.format(20)
if incdec == 'increment':
expected_value = value.format(21)
else:
expected_value = value.format(19)
base_url = QUrl(url.format(base_value))
expected_url = QUrl(url.format(expected_value))
assert navigate.incdec(base_url, 1, incdec) == expected_url
示例3: test_setitem_series_bool
# 需要导入模块: import pytest [as 别名]
# 或者: from pytest import xfail [as 别名]
def test_setitem_series_bool(self, val, exp_dtype):
obj = pd.Series([True, False, True, False])
assert obj.dtype == np.bool
if exp_dtype is np.int64:
exp = pd.Series([True, True, True, False])
self._assert_setitem_series_conversion(obj, val, exp, np.bool)
pytest.xfail("TODO_GH12747 The result must be int")
elif exp_dtype is np.float64:
exp = pd.Series([True, True, True, False])
self._assert_setitem_series_conversion(obj, val, exp, np.bool)
pytest.xfail("TODO_GH12747 The result must be float")
elif exp_dtype is np.complex128:
exp = pd.Series([True, True, True, False])
self._assert_setitem_series_conversion(obj, val, exp, np.bool)
pytest.xfail("TODO_GH12747 The result must be complex")
exp = pd.Series([True, val, True, False])
self._assert_setitem_series_conversion(obj, val, exp, exp_dtype)
示例4: test_insert_index_datetimes
# 需要导入模块: import pytest [as 别名]
# 或者: from pytest import xfail [as 别名]
def test_insert_index_datetimes(self, fill_val, exp_dtype):
obj = pd.DatetimeIndex(['2011-01-01', '2011-01-02', '2011-01-03',
'2011-01-04'], tz=fill_val.tz)
assert obj.dtype == exp_dtype
exp = pd.DatetimeIndex(['2011-01-01', fill_val.date(), '2011-01-02',
'2011-01-03', '2011-01-04'], tz=fill_val.tz)
self._assert_insert_conversion(obj, fill_val, exp, exp_dtype)
msg = "Passed item and index have different timezone"
if fill_val.tz:
with pytest.raises(ValueError, match=msg):
obj.insert(1, pd.Timestamp('2012-01-01'))
with pytest.raises(ValueError, match=msg):
obj.insert(1, pd.Timestamp('2012-01-01', tz='Asia/Tokyo'))
msg = "cannot insert DatetimeIndex with incompatible label"
with pytest.raises(TypeError, match=msg):
obj.insert(1, 1)
pytest.xfail("ToDo: must coerce to object")
示例5: test_replace_series_datetime_tz
# 需要导入模块: import pytest [as 别名]
# 或者: from pytest import xfail [as 别名]
def test_replace_series_datetime_tz(self):
how = 'series'
from_key = 'datetime64[ns, US/Eastern]'
to_key = 'timedelta64[ns]'
index = pd.Index([3, 4], name='xxx')
obj = pd.Series(self.rep[from_key], index=index, name='yyy')
assert obj.dtype == from_key
if how == 'dict':
replacer = dict(zip(self.rep[from_key], self.rep[to_key]))
elif how == 'series':
replacer = pd.Series(self.rep[to_key], index=self.rep[from_key])
else:
raise ValueError
result = obj.replace(replacer)
exp = pd.Series(self.rep[to_key], index=index, name='yyy')
assert exp.dtype == to_key
tm.assert_series_equal(result, exp)
# TODO(jreback) commented out to only have a single xfail printed
示例6: test_transform_numeric_ret
# 需要导入模块: import pytest [as 别名]
# 或者: from pytest import xfail [as 别名]
def test_transform_numeric_ret(cols, exp, comp_func, agg_func):
if agg_func == 'size' and isinstance(cols, list):
pytest.xfail("'size' transformation not supported with "
"NDFrameGroupy")
# GH 19200
df = pd.DataFrame(
{'a': pd.date_range('2018-01-01', periods=3),
'b': range(3),
'c': range(7, 10)})
result = df.groupby('b')[cols].transform(agg_func)
if agg_func == 'rank':
exp = exp.astype('float')
comp_func(result, exp)
示例7: test_td64arr_mod_int
# 需要导入模块: import pytest [as 别名]
# 或者: from pytest import xfail [as 别名]
def test_td64arr_mod_int(self, box_with_array):
tdi = timedelta_range('1 ns', '10 ns', periods=10)
tdarr = tm.box_expected(tdi, box_with_array)
expected = TimedeltaIndex(['1 ns', '0 ns'] * 5)
expected = tm.box_expected(expected, box_with_array)
result = tdarr % 2
tm.assert_equal(result, expected)
with pytest.raises(TypeError):
2 % tdarr
if box_with_array is pd.DataFrame:
pytest.xfail("DataFrame does not have __divmod__ or __rdivmod__")
result = divmod(tdarr, 2)
tm.assert_equal(result[1], expected)
tm.assert_equal(result[0], tdarr // 2)
示例8: test_td64arr_rmod_tdscalar
# 需要导入模块: import pytest [as 别名]
# 或者: from pytest import xfail [as 别名]
def test_td64arr_rmod_tdscalar(self, box_with_array, three_days):
tdi = timedelta_range('1 Day', '9 days')
tdarr = tm.box_expected(tdi, box_with_array)
expected = ['0 Days', '1 Day', '0 Days'] + ['3 Days'] * 6
expected = TimedeltaIndex(expected)
expected = tm.box_expected(expected, box_with_array)
result = three_days % tdarr
tm.assert_equal(result, expected)
if box_with_array is pd.DataFrame:
pytest.xfail("DataFrame does not have __divmod__ or __rdivmod__")
result = divmod(three_days, tdarr)
tm.assert_equal(result[1], expected)
tm.assert_equal(result[0], three_days // tdarr)
# ------------------------------------------------------------------
# Operations with invalid others
示例9: test_dt64arr_aware_sub_dt64ndarray_raises
# 需要导入模块: import pytest [as 别名]
# 或者: from pytest import xfail [as 别名]
def test_dt64arr_aware_sub_dt64ndarray_raises(self, tz_aware_fixture,
box_with_array):
if box_with_array is pd.DataFrame:
pytest.xfail("FIXME: ValueError with transpose; "
"alignment error without")
tz = tz_aware_fixture
dti = pd.date_range('2016-01-01', periods=3, tz=tz)
dt64vals = dti.values
dtarr = tm.box_expected(dti, box_with_array)
with pytest.raises(TypeError):
dtarr - dt64vals
with pytest.raises(TypeError):
dt64vals - dtarr
# -------------------------------------------------------------
# Addition of datetime-like others (invalid)
示例10: test_dt64arr_add_dt64ndarray_raises
# 需要导入模块: import pytest [as 别名]
# 或者: from pytest import xfail [as 别名]
def test_dt64arr_add_dt64ndarray_raises(self, tz_naive_fixture,
box_with_array):
if box_with_array is pd.DataFrame:
pytest.xfail("FIXME: ValueError with transpose; "
"alignment error without")
tz = tz_naive_fixture
dti = pd.date_range('2016-01-01', periods=3, tz=tz)
dt64vals = dti.values
dtarr = tm.box_expected(dti, box_with_array)
with pytest.raises(TypeError):
dtarr + dt64vals
with pytest.raises(TypeError):
dt64vals + dtarr
示例11: test_pretty_unicomb
# 需要导入模块: import pytest [as 别名]
# 或者: from pytest import xfail [as 别名]
def test_pretty_unicomb():
pytest.xfail('pp_list counts code points, not grapheme clusters.')
labels = ['name', 'age', 'favourite food']
table = [
['Spot', 3, 'kibble'],
['Skruffles', 2, 'kibble'],
['Zorb', 2, 'zorblaxian kibble'],
['Zörb', 87, 'zørblaχian ﻛبﻞ'],
[u'Zörb', 42, u'zörblǎxïǎn kïbble'],
['Zörb', 87, 'zørblaχian ﻛِبّﻞ'],
]
out = StringIO.StringIO()
pretty.pp_list(out, table, labels)
assert out.getvalue() == \
u' name | age | favourite food\n' \
u'----------+-----+------------------\n' \
u' Spot | 3 | kibble\n' \
u'Skruffles | 2 | kibble\n' \
u' Zorb | 2 | zorblaxian kibble\n' \
u' Zörb | 42 | zörblǎxïǎn kïbble\n' \
u' Zörb | 87 | zørblaxian ﻛِبّﻞ\n'
示例12: test_compressions
# 需要导入模块: import pytest [as 别名]
# 或者: from pytest import xfail [as 别名]
def test_compressions(fmt, mode, tmpdir):
if fmt == "zip" and sys.version_info < (3, 6):
pytest.xfail("zip compression requires python3.6 or higher")
tmpdir = str(tmpdir)
fn = os.path.join(tmpdir, ".tmp.getsize")
fs = LocalFileSystem()
f = OpenFile(fs, fn, compression=fmt, mode="wb")
data = b"Long line of readily compressible text"
with f as fo:
fo.write(data)
if fmt is None:
assert fs.size(fn) == len(data)
else:
assert fs.size(fn) != len(data)
f = OpenFile(fs, fn, compression=fmt, mode=mode)
with f as fo:
if mode == "rb":
assert fo.read() == data
else:
assert fo.read() == data.decode()
示例13: test_glob_weird_characters
# 需要导入模块: import pytest [as 别名]
# 或者: from pytest import xfail [as 别名]
def test_glob_weird_characters(tmpdir, sep, chars):
tmpdir = make_path_posix(str(tmpdir))
subdir = tmpdir + sep + "test" + chars + "x"
try:
os.makedirs(subdir, exist_ok=True)
except OSError as e:
if WIN and "label syntax" in str(e):
pytest.xfail("Illegal windows directory name")
else:
raise
with open(subdir + sep + "tmp", "w") as f:
f.write("hi")
out = LocalFileSystem().glob(subdir + sep + "*")
assert len(out) == 1
assert "/" in out[0]
assert "tmp" in out[0]
示例14: test_client_reliablity
# 需要导入模块: import pytest [as 别名]
# 或者: from pytest import xfail [as 别名]
def test_client_reliablity(options):
"""
Testing validation function of WebGear API
"""
client = None
try:
# define params
client = NetGear(
pattern=1, port=5554, receive_mode=True, logging=True, **options
)
# get data without any connection
frame_client = client.recv()
# check for frame
if frame_client is None:
raise RuntimeError
except Exception as e:
if isinstance(e, (RuntimeError)):
pytest.xfail("Reconnection ran successfully.")
else:
logger.exception(str(e))
finally:
# clean resources
if not (client is None):
client.close()
示例15: spawn
# 需要导入模块: import pytest [as 别名]
# 或者: from pytest import xfail [as 别名]
def spawn(self, cmd, expect_timeout=10.0):
"""Run a command using pexpect.
The pexpect child is returned.
"""
pexpect = pytest.importorskip("pexpect", "3.0")
if hasattr(sys, "pypy_version_info") and "64" in platform.machine():
pytest.skip("pypy-64 bit not supported")
if sys.platform.startswith("freebsd"):
pytest.xfail("pexpect does not work reliably on freebsd")
logfile = self.tmpdir.join("spawn.out").open("wb")
# Do not load user config.
env = os.environ.copy()
env.update(self._env_run_update)
child = pexpect.spawn(cmd, logfile=logfile, env=env)
self.request.addfinalizer(logfile.close)
child.timeout = expect_timeout
return child