Skip to content

Commit ad17842

Browse files
authored
TST: add test with freq=2M to increase coverage of to_period (#53940)
1 parent 2574694 commit ad17842

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

pandas/tests/indexes/datetimes/methods/test_to_period.py

+8
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
import pytz
77

88
from pandas._libs.tslibs.ccalendar import MONTHS
9+
from pandas._libs.tslibs.offsets import MonthEnd
910
from pandas._libs.tslibs.period import INVALID_FREQ_ERR_MSG
1011

1112
from pandas import (
@@ -77,6 +78,13 @@ def test_to_period_monthish(self):
7778
with pytest.raises(ValueError, match=INVALID_FREQ_ERR_MSG):
7879
date_range("01-Jan-2012", periods=8, freq="EOM")
7980

81+
@pytest.mark.parametrize("freq", ["2M", MonthEnd(2)])
82+
def test_dti_to_period_2monthish(self, freq):
83+
dti = date_range("2020-01-01", periods=3, freq=freq)
84+
pi = dti.to_period()
85+
86+
tm.assert_index_equal(pi, period_range("2020-01", "2020-05", freq=freq))
87+
8088
def test_to_period_infer(self):
8189
# https://github.com/pandas-dev/pandas/issues/33358
8290
rng = date_range(

0 commit comments

Comments
 (0)