Skip to content

TST: strict xfail #38960

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 6 commits into from
Jan 9, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion pandas/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -473,7 +473,7 @@ def index_with_missing(request):
Fixture for indices with missing values
"""
if request.param in ["int", "uint", "range", "empty", "repeats"]:
pytest.xfail("missing values not supported")
pytest.skip("missing values not supported")
# GH 35538. Use deep copy to avoid illusive bug on np-dev
# Azure pipeline that writes into indices_dict despite copy
ind = indices_dict[request.param].copy(deep=True)
Expand Down
35 changes: 15 additions & 20 deletions pandas/tests/indexing/test_coercion.py
Original file line number Diff line number Diff line change
Expand Up @@ -436,7 +436,20 @@ def test_insert_index_float64(self, insert, coerced_val, coerced_dtype):
],
ids=["datetime64", "datetime64tz"],
)
def test_insert_index_datetimes(self, fill_val, exp_dtype):
@pytest.mark.parametrize(
"insert_value",
[pd.Timestamp("2012-01-01"), pd.Timestamp("2012-01-01", tz="Asia/Tokyo"), 1],
)
def test_insert_index_datetimes(self, request, fill_val, exp_dtype, insert_value):
if not hasattr(insert_value, "tz"):
request.node.add_marker(
pytest.mark.xfail(reason="ToDo: must coerce to object")
)
elif fill_val.tz != insert_value.tz:
request.node.add_marker(
pytest.mark.xfail(reason="GH 37605 - require tz equality?")
)

obj = pd.DatetimeIndex(
["2011-01-01", "2011-01-02", "2011-01-03", "2011-01-04"], tz=fill_val.tz
)
Expand All @@ -448,25 +461,7 @@ def test_insert_index_datetimes(self, fill_val, exp_dtype):
)
self._assert_insert_conversion(obj, fill_val, exp, exp_dtype)

if fill_val.tz:
msg = "Cannot compare tz-naive and tz-aware"
with pytest.raises(TypeError, match=msg):
obj.insert(1, pd.Timestamp("2012-01-01"))

msg = "Timezones don't match"
with pytest.raises(ValueError, match=msg):
obj.insert(1, pd.Timestamp("2012-01-01", tz="Asia/Tokyo"))

else:
msg = "Cannot compare tz-naive and tz-aware"
with pytest.raises(TypeError, match=msg):
obj.insert(1, pd.Timestamp("2012-01-01", tz="Asia/Tokyo"))

msg = "value should be a 'Timestamp' or 'NaT'. Got 'int' instead."
with pytest.raises(TypeError, match=msg):
obj.insert(1, 1)

pytest.xfail("ToDo: must coerce to object")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i think this indicates something that we need to fix. maybe should write out the assertion so that the xfail is meaningful

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @jbrockmendel, I was planning on pinging you and @WillAyd after a bit more digging into this, but you beat me to it :). This was originally changed in #18721 from a comment to the xfail that exists now. The comments were originally added
in 7c0b742. I'm not sure what should be asserted here; from the history it seems like it refers to the tests above.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also note those comments still exist in the test immediately below.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if we want to coerce to object (and i think we do), then for starters the insert on L467 shouldn't raise but should instead be equivalent to obj.astype(object).insert(1, 1). so i think can just change that and then xfail it?

the harder question is what we do in the two cases above that with mismatched tz or mismatched tzawareness. with mismatched tz could just cast (#37605), with mismatched tzawareness could also cast to object.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if you can create an issue for this in followup (and PR if you can!)

obj.insert(1, insert_value)

def test_insert_index_timedelta64(self):
obj = pd.TimedeltaIndex(["1 day", "2 day", "3 day", "4 day"])
Expand Down
11 changes: 8 additions & 3 deletions pandas/tests/tseries/offsets/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,12 +98,10 @@ def _get_offset(self, klass, value=1, normalize=False):
klass = klass(value, normalize=normalize)
return klass

def test_apply_out_of_range(self, tz_naive_fixture):
def test_apply_out_of_range(self, request, tz_naive_fixture):
tz = tz_naive_fixture
if self._offset is None:
return
if isinstance(tz, tzlocal) and not IS64:
pytest.xfail(reason="OverflowError inside tzlocal past 2038")

# try to create an out-of-bounds result timestamp; if we can't create
# the offset skip
Expand All @@ -123,6 +121,13 @@ def test_apply_out_of_range(self, tz_naive_fixture):
t = Timestamp("20080101", tz=tz)
result = t + offset
assert isinstance(result, datetime)

if isinstance(tz, tzlocal) and not IS64:
# If we hit OutOfBoundsDatetime on non-64 bit machines
# we'll drop out of the try clause before the next test
request.node.add_marker(
pytest.mark.xfail(reason="OverflowError inside tzlocal past 2038")
)
assert t.tzinfo == result.tzinfo

except OutOfBoundsDatetime:
Expand Down