Skip to content

TST: Split test_offsets.py - Added fixtures for date offsets and business date offsets #31034

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 2 commits into from
Closed
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
89 changes: 89 additions & 0 deletions pandas/tests/tseries/offsets/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,49 @@

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",
}


BUSINESS_OFFSETS = {
"BusinessDay",
"BDay",
"CustomBusinessDay",
"CBMonthBegin",
"CBMonthEnd",
"BMonthBegin",
"BMonthEnd",
"BusinessHour",
"CustomBusinessHour",
"BYearBegin",
"BYearEnd",
"CDay",
"BQuarterBegin",
"BQuarterEnd",
"FY5253Quarter",
"FY5253",
}

Copy link
Contributor

Choose a reason for hiding this comment

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

can you define offset_types in terms of the lists above?

Copy link
Author

@Raalsky Raalsky Jan 30, 2020

Choose a reason for hiding this comment

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

Sorry but I'm off due to my exams. I'll be back within a few days 😉


@pytest.fixture(params=[getattr(offsets, o) for o in offsets.__all__])
def offset_types(request):
Expand All @@ -23,3 +66,49 @@ def 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 DATE_OFFSETS])
def date_offset_types(request):
"""
Fixture for all the datetime offsets available for a time series except business
subclasses.
"""
return request.param


@pytest.fixture(
params=[
getattr(offsets, o)
for o in DATE_OFFSETS
if issubclass(getattr(offsets, o), offsets.MonthOffset) and o != "MonthOffset"
]
)
def date_month_classes(request):
Copy link
Contributor

Choose a reason for hiding this comment

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

this seems to duplicate month_classes no? I like your name better, can you remove the other one (and change to use this one)

"""
Fixture for month based datetime offsets available for a time series except business
subclasses.
"""
return request.param


@pytest.fixture(params=[getattr(offsets, o) for o in BUSINESS_OFFSETS])
def business_offset_types(request):
"""
Fixture for all the business 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 business_month_classes(request):
"""
Fixture for month based business datetime offsets available for a time series.
"""
return request.param