|
42 | 42 | from pandas.tseries.holiday import USFederalHolidayCalendar
|
43 | 43 |
|
44 | 44 |
|
| 45 | +offset_classes = [getattr(offsets, x) for x in dir(offsets)] |
| 46 | +offset_classes = [x for x in offset_classes if inspect.isclass(x) and |
| 47 | + issubclass(x, DateOffset)] |
| 48 | + |
| 49 | + |
| 50 | +@pytest.fixture(params=offset_classes) |
| 51 | +def offset_types(request): |
| 52 | + return request.param |
| 53 | + |
| 54 | + |
45 | 55 | def test_monthrange():
|
46 | 56 | import calendar
|
47 | 57 | for y in range(2000, 2013):
|
@@ -4904,23 +4914,15 @@ def test_all_offset_classes(self):
|
4904 | 4914 |
|
4905 | 4915 | # ---------------------------------------------------------------------
|
4906 | 4916 |
|
4907 |
| -offset_classes = [getattr(offsets, x) for x in dir(offsets)] |
4908 |
| -offset_classes = [x for x in offset_classes if inspect.isclass(x) and |
4909 |
| - issubclass(x, DateOffset)] |
| 4917 | +month_classes = [x for x in offset_classes if |
| 4918 | + issubclass(x, offsets.MonthOffset)] |
| 4919 | + |
| 4920 | +tick_classes = [x for x in offset_classes if issubclass(x, offsets.Tick)] |
4910 | 4921 |
|
4911 | 4922 |
|
4912 |
| -def test_valid_attributes(): |
| 4923 | +@pytest.parametrize('cls', month_classes+tick_classes) |
| 4924 | +@pytest.parametrize('kwd', _rd_kwds) |
| 4925 | +def test_valid_attributes(kwd, cls): |
4913 | 4926 | # check that we cannot create e.g. MonthEnd(weeks=3)
|
4914 |
| - month_classes = [x for x in offset_classes if |
4915 |
| - issubclass(x, offsets.MonthOffset)] |
4916 |
| - |
4917 |
| - for cls in month_classes: |
4918 |
| - for kwd in _rd_kwds: |
4919 |
| - with pytest.raises(TypeError): |
4920 |
| - cls(**{kwd: 3}) |
4921 |
| - |
4922 |
| - tick_classes = [x for x in offset_classes if issubclass(x, offsets.Tick)] |
4923 |
| - for cls in tick_classes: |
4924 |
| - for kwd in _rd_kwds: |
4925 |
| - with pytest.raises(TypeError): |
4926 |
| - cls(**{kwd: 4}) |
| 4927 | + with pytest.raises(TypeError): |
| 4928 | + cls(**{kwd: 3}) |
0 commit comments