Skip to content

Commit 3880fe2

Browse files
committed
BUG: Holiday(..) with both offset and observance raises NotImplementedError
GH10217
1 parent 1d87174 commit 3880fe2

File tree

2 files changed

+14
-0
lines changed

2 files changed

+14
-0
lines changed

pandas/tests/test_tseries.py

+11
Original file line numberDiff line numberDiff line change
@@ -737,6 +737,17 @@ def test_get_period_field_raises_on_out_of_range(self):
737737
def test_get_period_field_array_raises_on_out_of_range(self):
738738
self.assertRaises(ValueError, period.get_period_field_arr, -1, np.empty(1), 0)
739739

740+
741+
class TestHolidayConflictingArguments(tm.TestCase):
742+
743+
def test_both_offset_observance_raises(self):
744+
from pandas.tseries.holiday import Holiday, SA, next_monday
745+
from pandas import DateOffset
746+
747+
with self.assertRaises(NotImplementedError) as cm:
748+
h = Holiday("Cyber Monday", month=11, day=1,
749+
offset=[DateOffset(weekday=SA(4))], observance=next_monday)
750+
740751
if __name__ == '__main__':
741752
import nose
742753
nose.runmodule(argv=[__file__, '-vvs', '-x', '--pdb', '--pdb-failure'],

pandas/tseries/holiday.py

+3
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,9 @@ class from pandas.tseries.offsets
148148
>>> July3rd = Holiday('July 3rd', month=7, day=3,
149149
days_of_week=(0, 1, 2, 3))
150150
"""
151+
if offset is not None and observance is not None:
152+
raise NotImplementedError("Cannot use both offset and observance.")
153+
151154
self.name = name
152155
self.year = year
153156
self.month = month

0 commit comments

Comments
 (0)