File tree Expand file tree Collapse file tree 1 file changed +24
-0
lines changed Expand file tree Collapse file tree 1 file changed +24
-0
lines changed Original file line number Diff line number Diff line change 11
22from datetime import datetime
33import pandas .util .testing as tm
4+ from pandas import DatetimeIndex
45from 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+
5276class TestHoliday (tm .TestCase ):
5377
5478 def setUp (self ):
You can’t perform that action at this time.
0 commit comments