Skip to content

Commit 434068c

Browse files
author
David Hirschfeld
committed
Added test for issue #9552
1 parent bae6014 commit 434068c

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

pandas/tseries/tests/test_holiday.py

+24
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11

22
from datetime import datetime
33
import pandas.util.testing as tm
4+
from pandas import DatetimeIndex
45
from pandas.tseries.holiday import (
56
USFederalHolidayCalendar, USMemorialDay, USThanksgivingDay,
67
nearest_workday, next_monday_or_tuesday, next_monday,
@@ -49,6 +50,29 @@ def test_calendar(self):
4950
self.assertEqual(list(holidays_2.to_pydatetime()),
5051
self.holiday_list)
5152

53+
def test_calendar_caching(self):
54+
# Test for issue #9552
55+
56+
class TestCalendar(AbstractHolidayCalendar):
57+
def __init__(self, name=None, rules=None):
58+
super(TestCalendar, self).__init__(
59+
name=name,
60+
rules=rules
61+
)
62+
63+
jan1 = TestCalendar(rules=[Holiday('jan1', year=2015, month=1, day=1)])
64+
jan2 = TestCalendar(rules=[Holiday('jan2', year=2015, month=1, day=2)])
65+
66+
tm.assert_index_equal(
67+
jan1.holidays(),
68+
DatetimeIndex(['01-Jan-2015'])
69+
)
70+
tm.assert_index_equal(
71+
jan2.holidays(),
72+
DatetimeIndex(['02-Jan-2015'])
73+
)
74+
75+
5276
class TestHoliday(tm.TestCase):
5377

5478
def setUp(self):

0 commit comments

Comments
 (0)