-
-
Notifications
You must be signed in to change notification settings - Fork 18.7k
Prevent passing invalid kwds to DateOffset constructors #18226
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
Changes from 1 commit
b9fe60e
f10a1c6
807d769
687e3b7
d5443ca
5e5e0c0
17f7b5a
3834ef8
1c54e96
0e37a24
a572368
d0ff381
409dbd0
6a9233e
4406df8
44891cd
573abb6
c6cc8bc
a68f4a7
c8224c1
55779d8
d5b8302
b54e26b
fade4a2
38c2238
fe895ff
11ba1a9
bc90a19
0b3dca0
9c841fc
adee395
43dc17e
4ff8c22
d261be9
b4b9e15
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -42,6 +42,16 @@ | |
from pandas.tseries.holiday import USFederalHolidayCalendar | ||
|
||
|
||
offset_classes = [getattr(offsets, x) for x in dir(offsets)] | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. no, pls just use the fixture (you can certainly create more if needed) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. OK. |
||
offset_classes = [x for x in offset_classes if inspect.isclass(x) and | ||
issubclass(x, DateOffset)] | ||
|
||
|
||
@pytest.fixture(params=offset_classes) | ||
def offset_types(request): | ||
return request.param | ||
|
||
|
||
def test_monthrange(): | ||
import calendar | ||
for y in range(2000, 2013): | ||
|
@@ -4904,23 +4914,15 @@ def test_all_offset_classes(self): | |
|
||
# --------------------------------------------------------------------- | ||
|
||
offset_classes = [getattr(offsets, x) for x in dir(offsets)] | ||
offset_classes = [x for x in offset_classes if inspect.isclass(x) and | ||
issubclass(x, DateOffset)] | ||
month_classes = [x for x in offset_classes if | ||
issubclass(x, offsets.MonthOffset)] | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I would just make these fixtures |
||
|
||
tick_classes = [x for x in offset_classes if issubclass(x, offsets.Tick)] | ||
|
||
|
||
def test_valid_attributes(): | ||
@pytest.parametrize('cls', month_classes+tick_classes) | ||
@pytest.parametrize('kwd', _rd_kwds) | ||
def test_valid_attributes(kwd, cls): | ||
# check that we cannot create e.g. MonthEnd(weeks=3) | ||
month_classes = [x for x in offset_classes if | ||
issubclass(x, offsets.MonthOffset)] | ||
|
||
for cls in month_classes: | ||
for kwd in _rd_kwds: | ||
with pytest.raises(TypeError): | ||
cls(**{kwd: 3}) | ||
|
||
tick_classes = [x for x in offset_classes if issubclass(x, offsets.Tick)] | ||
for cls in tick_classes: | ||
for kwd in _rd_kwds: | ||
with pytest.raises(TypeError): | ||
cls(**{kwd: 4}) | ||
with pytest.raises(TypeError): | ||
cls(**{kwd: 3}) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this serves the entire sub-directory, why are you removing?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Because it isn't moved outside test_offsets and causes a "where the heck is this defined" reaction to a new reader. Will revert.