Skip to content

Commit

Permalink
Expose resetAddedAndRemovedHolidays for calendar
Browse files Browse the repository at this point in the history
  • Loading branch information
gbfredrik committed Nov 9, 2023
1 parent 84e1c52 commit 995bdd4
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
15 changes: 15 additions & 0 deletions Python/test/test_calendars.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,21 @@ def test_joint_calendar_holidays(self):
self.assertIn(holiday, joint_holidays)


class ResetBespokeCalendarTest(unittest.TestCase):

def test_reset_added_holidays(self):
calendar = ql.BespokeCalendar("bespoke thing")

test_date: ql.Date = ql.Date(1, ql.January, 2024)
self.assertFalse(calendar.isHoliday(test_date))
calendar.addHoliday(test_date)
self.assertTrue(calendar.isHoliday(test_date))
# TODO: Can extend test with this, if exposed:
# self.assertEqual(len(calendar.addedHolidays()), 1)
calendar.resetAddedAndRemovedHolidays()
self.assertFalse(calendar.isHoliday(test_date))


if __name__ == "__main__":
print("testing QuantLib", ql.__version__)
unittest.main(verbosity=2)
2 changes: 2 additions & 0 deletions SWIG/calendars.i
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,8 @@ class Calendar {
bool isEndOfMonth(const Date&);
void addHoliday(const Date&);
void removeHoliday(const Date&);
void resetAddedAndRemovedHolidays();

Date adjust(const Date& d,
BusinessDayConvention convention = QuantLib::Following);
Date advance(const Date& d, Integer n, TimeUnit unit,
Expand Down

0 comments on commit 995bdd4

Please sign in to comment.