Skip to content
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

CI: parametrize and xfail #55804

Merged
merged 1 commit into from
Nov 2, 2023
Merged
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
48 changes: 24 additions & 24 deletions pandas/tests/indexes/datetimes/test_constructors.py
Original file line number Diff line number Diff line change
Expand Up @@ -1013,35 +1013,35 @@ def test_dti_convert_datetime_list(self, tzstr):
dr2 = DatetimeIndex(list(dr), name="foo", freq="D")
tm.assert_index_equal(dr, dr2)

def test_dti_ambiguous_matches_timestamp(self):
@pytest.mark.parametrize(
"tz",
[
pytz.timezone("US/Eastern"),
gettz("US/Eastern"),
],
)
@pytest.mark.parametrize("use_str", [True, False])
@pytest.mark.parametrize("box_cls", [Timestamp, DatetimeIndex])
def test_dti_ambiguous_matches_timestamp(self, tz, use_str, box_cls, request):
# GH#47471 check that we get the same raising behavior in the DTI
# constructor and Timestamp constructor
dtstr = "2013-11-03 01:59:59.999999"
dtobj = Timestamp(dtstr).to_pydatetime()

tz = pytz.timezone("US/Eastern")
with pytest.raises(pytz.AmbiguousTimeError, match=dtstr):
Timestamp(dtstr, tz=tz)
with pytest.raises(pytz.AmbiguousTimeError, match=dtstr):
Timestamp(dtobj, tz=tz)
with pytest.raises(pytz.AmbiguousTimeError, match=dtstr):
DatetimeIndex([dtstr], tz=tz)
with pytest.raises(pytz.AmbiguousTimeError, match=dtstr):
DatetimeIndex([dtobj], tz=tz)
item = dtstr
if not use_str:
item = Timestamp(dtstr).to_pydatetime()
if box_cls is not Timestamp:
item = [item]

if not use_str and isinstance(tz, dateutil.tz.tzfile):
# FIXME: The Timestamp constructor here behaves differently than all
# the other cases bc with dateutil/zoneinfo tzinfos we implicitly
# get fold=0. Having this raise is not important, but having the
# behavior be consistent across cases is.
mark = pytest.mark.xfail(reason="We implicitly get fold=0.")
request.applymarker(mark)

tz2 = gettz("US/Eastern")
with pytest.raises(pytz.AmbiguousTimeError, match=dtstr):
Timestamp(dtstr, tz=tz2)
# FIXME: The Timestamp constructor here behaves differently than all
# the other cases bc with dateutil/zoneinfo tzinfos we implicitly
# get fold=0. Having this raise is not important, but having the
# behavior be consistent across cases is.
# with pytest.raises(pytz.AmbiguousTimeError, match=dtstr):
# Timestamp(dtobj, tz=tz2)
with pytest.raises(pytz.AmbiguousTimeError, match=dtstr):
DatetimeIndex([dtstr], tz=tz2)
with pytest.raises(pytz.AmbiguousTimeError, match=dtstr):
DatetimeIndex([dtobj], tz=tz2)
box_cls(item, tz=tz)

@pytest.mark.parametrize("tz", [None, "UTC", "US/Pacific"])
def test_dti_constructor_with_non_nano_dtype(self, tz):
Expand Down
Loading