Skip to content

Commit 094b09c

Browse files
authored
TST: strict xfail (#38960)
1 parent 66a30bd commit 094b09c

File tree

3 files changed

+24
-24
lines changed

3 files changed

+24
-24
lines changed

pandas/conftest.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -473,7 +473,7 @@ def index_with_missing(request):
473473
Fixture for indices with missing values
474474
"""
475475
if request.param in ["int", "uint", "range", "empty", "repeats"]:
476-
pytest.xfail("missing values not supported")
476+
pytest.skip("missing values not supported")
477477
# GH 35538. Use deep copy to avoid illusive bug on np-dev
478478
# Azure pipeline that writes into indices_dict despite copy
479479
ind = indices_dict[request.param].copy(deep=True)

pandas/tests/indexing/test_coercion.py

+15-20
Original file line numberDiff line numberDiff line change
@@ -436,7 +436,20 @@ def test_insert_index_float64(self, insert, coerced_val, coerced_dtype):
436436
],
437437
ids=["datetime64", "datetime64tz"],
438438
)
439-
def test_insert_index_datetimes(self, fill_val, exp_dtype):
439+
@pytest.mark.parametrize(
440+
"insert_value",
441+
[pd.Timestamp("2012-01-01"), pd.Timestamp("2012-01-01", tz="Asia/Tokyo"), 1],
442+
)
443+
def test_insert_index_datetimes(self, request, fill_val, exp_dtype, insert_value):
444+
if not hasattr(insert_value, "tz"):
445+
request.node.add_marker(
446+
pytest.mark.xfail(reason="ToDo: must coerce to object")
447+
)
448+
elif fill_val.tz != insert_value.tz:
449+
request.node.add_marker(
450+
pytest.mark.xfail(reason="GH 37605 - require tz equality?")
451+
)
452+
440453
obj = pd.DatetimeIndex(
441454
["2011-01-01", "2011-01-02", "2011-01-03", "2011-01-04"], tz=fill_val.tz
442455
)
@@ -448,25 +461,7 @@ def test_insert_index_datetimes(self, fill_val, exp_dtype):
448461
)
449462
self._assert_insert_conversion(obj, fill_val, exp, exp_dtype)
450463

451-
if fill_val.tz:
452-
msg = "Cannot compare tz-naive and tz-aware"
453-
with pytest.raises(TypeError, match=msg):
454-
obj.insert(1, pd.Timestamp("2012-01-01"))
455-
456-
msg = "Timezones don't match"
457-
with pytest.raises(ValueError, match=msg):
458-
obj.insert(1, pd.Timestamp("2012-01-01", tz="Asia/Tokyo"))
459-
460-
else:
461-
msg = "Cannot compare tz-naive and tz-aware"
462-
with pytest.raises(TypeError, match=msg):
463-
obj.insert(1, pd.Timestamp("2012-01-01", tz="Asia/Tokyo"))
464-
465-
msg = "value should be a 'Timestamp' or 'NaT'. Got 'int' instead."
466-
with pytest.raises(TypeError, match=msg):
467-
obj.insert(1, 1)
468-
469-
pytest.xfail("ToDo: must coerce to object")
464+
obj.insert(1, insert_value)
470465

471466
def test_insert_index_timedelta64(self):
472467
obj = pd.TimedeltaIndex(["1 day", "2 day", "3 day", "4 day"])

pandas/tests/tseries/offsets/common.py

+8-3
Original file line numberDiff line numberDiff line change
@@ -98,12 +98,10 @@ def _get_offset(self, klass, value=1, normalize=False):
9898
klass = klass(value, normalize=normalize)
9999
return klass
100100

101-
def test_apply_out_of_range(self, tz_naive_fixture):
101+
def test_apply_out_of_range(self, request, tz_naive_fixture):
102102
tz = tz_naive_fixture
103103
if self._offset is None:
104104
return
105-
if isinstance(tz, tzlocal) and not IS64:
106-
pytest.xfail(reason="OverflowError inside tzlocal past 2038")
107105

108106
# try to create an out-of-bounds result timestamp; if we can't create
109107
# the offset skip
@@ -123,6 +121,13 @@ def test_apply_out_of_range(self, tz_naive_fixture):
123121
t = Timestamp("20080101", tz=tz)
124122
result = t + offset
125123
assert isinstance(result, datetime)
124+
125+
if isinstance(tz, tzlocal) and not IS64:
126+
# If we hit OutOfBoundsDatetime on non-64 bit machines
127+
# we'll drop out of the try clause before the next test
128+
request.node.add_marker(
129+
pytest.mark.xfail(reason="OverflowError inside tzlocal past 2038")
130+
)
126131
assert t.tzinfo == result.tzinfo
127132

128133
except OutOfBoundsDatetime:

0 commit comments

Comments
 (0)