Skip to content

Commit

Permalink
TST: add test with freq=2M to increase coverage of to_period (pandas-…
Browse files Browse the repository at this point in the history
  • Loading branch information
natmokval authored and im-vinicius committed Jul 8, 2023
1 parent c9fa159 commit 665bf62
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions pandas/tests/indexes/datetimes/methods/test_to_period.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import pytz

from pandas._libs.tslibs.ccalendar import MONTHS
from pandas._libs.tslibs.offsets import MonthEnd
from pandas._libs.tslibs.period import INVALID_FREQ_ERR_MSG

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

@pytest.mark.parametrize("freq", ["2M", MonthEnd(2)])
def test_dti_to_period_2monthish(self, freq):
dti = date_range("2020-01-01", periods=3, freq=freq)
pi = dti.to_period()

tm.assert_index_equal(pi, period_range("2020-01", "2020-05", freq=freq))

def test_to_period_infer(self):
# https://github.com/pandas-dev/pandas/issues/33358
rng = date_range(
Expand Down

0 comments on commit 665bf62

Please sign in to comment.