Skip to content

Commit

Permalink
get_next_holiday: fix review findings
Browse files Browse the repository at this point in the history
Use more stable calender for testing

make sure calendar is filled also if no date is passed

Signed-off-by: Schrotti <[email protected]>
  • Loading branch information
Rosi2143 committed Jan 15, 2025
1 parent 3446e91 commit 6fda9a8
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion holidays/holiday_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -977,7 +977,7 @@ def get_next_holiday(
(if previous is False) or the previous holiday (if previous is True).
If no date is given the search starts from current date"""

dt = self.__keytransform__(start) if start else datetime.now().date()
dt = self.__keytransform__(start if start else datetime.now().date())
if not previous:
next_date = next((x for x in self.get_entries_sorted() if x > dt), None)
if not next_date and dt.year < self.end_year:
Expand Down
8 changes: 4 additions & 4 deletions tests/test_holiday_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -1265,14 +1265,14 @@ def test_get_next_holiday_reverse(self):
)

def test_get_next_holiday_corner_cases(self):
from holidays.countries.ukraine import UA
from holidays.countries.united_states import US

ua = UA()
us = US()
# check for date before start of calendar
self.assertEqual(ua.get_next_holiday("1991-01-01", previous=True), (None, None))
self.assertEqual(us.get_next_holiday("1777-01-01", previous=True), (None, None))

# check for date after end of calendar
self.assertEqual(ua.get_next_holiday("2022-03-08"), (None, None))
self.assertEqual(us.get_next_holiday("2100-12-31"), (None, None))

def test_get_next_holiday_unsorted_calendars(self):
from holidays.countries.united_states import US
Expand Down

0 comments on commit 6fda9a8

Please sign in to comment.