diff --git a/pandas/conftest.py b/pandas/conftest.py index 2862f7c957abc..bf5e632374b59 100644 --- a/pandas/conftest.py +++ b/pandas/conftest.py @@ -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) diff --git a/pandas/tests/indexing/test_coercion.py b/pandas/tests/indexing/test_coercion.py index 8735e2a09920d..ac2e300f9f8d6 100644 --- a/pandas/tests/indexing/test_coercion.py +++ b/pandas/tests/indexing/test_coercion.py @@ -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 ) @@ -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") + obj.insert(1, insert_value) def test_insert_index_timedelta64(self): obj = pd.TimedeltaIndex(["1 day", "2 day", "3 day", "4 day"]) diff --git a/pandas/tests/tseries/offsets/common.py b/pandas/tests/tseries/offsets/common.py index b2ac28e1865d6..5edef896be537 100644 --- a/pandas/tests/tseries/offsets/common.py +++ b/pandas/tests/tseries/offsets/common.py @@ -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 @@ -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: