Skip to content

TST: Split test_offsets.py #30194

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

Closed
wants to merge 13 commits into from
72 changes: 68 additions & 4 deletions pandas/tests/tseries/offsets/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,59 @@

import pandas.tseries.offsets as offsets

DATE_OFFSETS = {
"Day",
"MonthBegin",
"MonthEnd",
"SemiMonthBegin",
"SemiMonthEnd",
"YearBegin",
"YearEnd",
"QuarterBegin",
"QuarterEnd",
"LastWeekOfMonth",
"Week",
"WeekOfMonth",
"Easter",
"Hour",
"Minute",
"Second",
"Milli",
"Micro",
"Nano",
"DateOffset",
}

@pytest.fixture(params=[getattr(offsets, o) for o in offsets.__all__])
def offset_types(request):
BUSINESS_OFFSETS = {
"BusinessDay",
"BDay",
"CustomBusinessDay",
"CBMonthBegin",
"CBMonthEnd",
"BMonthBegin",
"BMonthEnd",
"BusinessHour",
"CustomBusinessHour",
"BYearBegin",
"BYearEnd",
"CDay",
"BQuarterBegin",
"BQuarterEnd",
"FY5253Quarter",
"FY5253",
}


@pytest.fixture(params=[getattr(offsets, o) for o in DATE_OFFSETS])
def date_offset_types(request):
"""
Fixture for all the datetime offsets available for a time series.
"""
return request.param


@pytest.fixture(params=[getattr(offsets, o) for o in BUSINESS_OFFSETS])
def business_offset_types(request):
"""
Fixture for all the datetime offsets available for a time series.
Copy link
Member

Choose a reason for hiding this comment

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

same docstring for business_offset_types as date_offset_types docstring. should differentiate.

Copy link
Author

Choose a reason for hiding this comment

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

Added in #31034

"""
Expand All @@ -14,11 +64,25 @@ def offset_types(request):
@pytest.fixture(
params=[
getattr(offsets, o)
for o in offsets.__all__
for o in DATE_OFFSETS
if issubclass(getattr(offsets, o), offsets.MonthOffset) and o != "MonthOffset"
]
)
def date_month_classes(request):
"""
Fixture for month based datetime offsets available for a time series.
"""
return request.param


@pytest.fixture(
params=[
getattr(offsets, o)
for o in BUSINESS_OFFSETS
if issubclass(getattr(offsets, o), offsets.MonthOffset) and o != "MonthOffset"
]
)
def month_classes(request):
def business_month_classes(request):
"""
Fixture for month based datetime offsets available for a time series.
Copy link
Member

Choose a reason for hiding this comment

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

same docstring for business_month_classes as date_month_classes. should differentiate.

Copy link
Author

Choose a reason for hiding this comment

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

Added in #31034

"""
Expand Down
Loading