Skip to content

Commit e9d8d74

Browse files
authored
Add working day tests for countries with substituted holidays (#2695)
1 parent 0905697 commit e9d8d74

File tree

5 files changed

+435
-253
lines changed

5 files changed

+435
-253
lines changed

holidays/countries/hungary.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ class Hungary(HolidayBase, ChristianHolidays, InternationalHolidays, StaticHolid
2828

2929
country = "HU"
3030
default_language = "hu"
31+
start_year = 1945
3132
supported_languages = ("en_US", "hu", "uk")
3233

3334
def __init__(self, *args, **kwargs):
@@ -40,7 +41,7 @@ def _populate_public_holidays(self):
4041
# New Year's Day.
4142
self._add_new_years_day(tr("Újév"))
4243

43-
if 1945 <= self._year <= 1950 or self._year >= 1989:
44+
if self._year <= 1950 or self._year >= 1989:
4445
# National Day.
4546
self._add_holiday_mar_15(tr("Nemzeti ünnep"))
4647

tests/countries/test_hungary.py

Lines changed: 178 additions & 89 deletions
Original file line numberDiff line numberDiff line change
@@ -13,17 +13,192 @@
1313
from unittest import TestCase
1414

1515
from holidays.countries.hungary import Hungary, HU, HUN
16-
from tests.common import CommonCountryTests
16+
from tests.common import CommonCountryTests, WorkingDayTests
1717

1818

19-
class TestHungary(CommonCountryTests, TestCase):
19+
class TestHungary(CommonCountryTests, WorkingDayTests, TestCase):
2020
@classmethod
2121
def setUpClass(cls):
2222
super().setUpClass(Hungary, years=range(1945, 2050))
2323

2424
def test_country_aliases(self):
2525
self.assertAliases(Hungary, HU, HUN)
2626

27+
def test_no_holidays(self):
28+
self.assertNoHolidays(Hungary(years=1944))
29+
30+
def test_substituted_holidays(self):
31+
self.assertHoliday(
32+
"1991-08-19",
33+
"1992-08-21",
34+
"1992-12-24",
35+
"1993-12-24",
36+
"1994-03-14",
37+
"1997-05-02",
38+
"1997-10-24",
39+
"1997-12-24",
40+
"1998-01-02",
41+
"1998-08-21",
42+
"1998-12-24",
43+
"1999-12-24",
44+
"2001-03-16",
45+
"2001-04-30",
46+
"2001-10-22",
47+
"2001-11-02",
48+
"2001-12-24",
49+
"2001-12-31",
50+
"2002-08-19",
51+
"2002-12-24",
52+
"2003-05-02",
53+
"2003-10-24",
54+
"2003-12-24",
55+
"2004-01-02",
56+
"2004-12-24",
57+
"2005-03-14",
58+
"2005-10-31",
59+
"2007-03-16",
60+
"2007-04-30",
61+
"2007-10-22",
62+
"2007-11-02",
63+
"2007-12-24",
64+
"2007-12-31",
65+
"2008-05-02",
66+
"2008-10-24",
67+
"2008-12-24",
68+
"2009-01-02",
69+
"2009-08-21",
70+
"2009-12-24",
71+
"2010-12-24",
72+
"2011-03-14",
73+
"2011-10-31",
74+
"2012-03-16",
75+
"2012-04-30",
76+
"2012-10-22",
77+
"2012-11-02",
78+
"2012-12-24",
79+
"2012-12-31",
80+
"2013-08-19",
81+
"2013-12-24",
82+
"2013-12-27",
83+
"2014-05-02",
84+
"2014-10-24",
85+
"2014-12-24",
86+
"2015-01-02",
87+
"2015-08-21",
88+
"2015-12-24",
89+
"2016-03-14",
90+
"2016-10-31",
91+
"2018-03-16",
92+
"2018-04-30",
93+
"2018-10-22",
94+
"2018-11-02",
95+
"2018-12-24",
96+
"2018-12-31",
97+
"2019-08-19",
98+
"2019-12-24",
99+
"2019-12-27",
100+
"2020-08-21",
101+
"2020-12-24",
102+
"2021-12-24",
103+
"2022-03-14",
104+
"2022-10-31",
105+
"2024-08-19",
106+
"2024-12-24",
107+
"2024-12-27",
108+
"2025-05-02",
109+
"2025-10-24",
110+
"2025-12-24",
111+
"2026-01-02",
112+
"2026-08-21",
113+
"2026-12-24",
114+
)
115+
116+
def test_workdays(self):
117+
self.assertWorkingDay(
118+
"1991-08-17",
119+
"1992-08-29",
120+
"1992-12-19",
121+
"1993-12-18",
122+
"1994-03-12",
123+
"1997-04-26",
124+
"1997-10-18",
125+
"1997-12-20",
126+
"1998-01-10",
127+
"1998-08-15",
128+
"1998-12-19",
129+
"1999-12-18",
130+
"2001-03-10",
131+
"2001-04-28",
132+
"2001-10-20",
133+
"2001-10-27",
134+
"2001-12-22",
135+
"2001-12-29",
136+
"2002-08-10",
137+
"2002-12-28",
138+
"2003-04-26",
139+
"2003-10-18",
140+
"2003-12-13",
141+
"2004-01-10",
142+
"2004-12-18",
143+
"2005-03-19",
144+
"2005-11-05",
145+
"2007-03-10",
146+
"2007-04-21",
147+
"2007-10-20",
148+
"2007-10-27",
149+
"2007-12-22",
150+
"2007-12-29",
151+
"2008-04-26",
152+
"2008-10-18",
153+
"2008-12-20",
154+
"2009-03-28",
155+
"2009-08-29",
156+
"2009-12-19",
157+
"2010-12-11",
158+
"2011-03-19",
159+
"2011-11-05",
160+
"2012-03-24",
161+
"2012-04-21",
162+
"2012-10-27",
163+
"2012-11-10",
164+
"2012-12-15",
165+
"2012-12-01",
166+
"2013-08-24",
167+
"2013-12-07",
168+
"2013-12-21",
169+
"2014-05-10",
170+
"2014-10-18",
171+
"2014-12-13",
172+
"2015-01-10",
173+
"2015-08-08",
174+
"2015-12-12",
175+
"2016-03-05",
176+
"2016-10-15",
177+
"2018-03-10",
178+
"2018-04-21",
179+
"2018-10-13",
180+
"2018-11-10",
181+
"2018-12-01",
182+
"2018-12-15",
183+
"2019-08-10",
184+
"2019-12-07",
185+
"2019-12-14",
186+
"2020-08-29",
187+
"2020-12-12",
188+
"2021-12-11",
189+
"2022-03-26",
190+
"2022-10-15",
191+
"2024-08-03",
192+
"2024-12-07",
193+
"2024-12-14",
194+
"2025-05-17",
195+
"2025-10-18",
196+
"2025-12-13",
197+
"2026-01-10",
198+
"2026-08-08",
199+
"2026-12-12",
200+
)
201+
27202
def test_new_years_day(self):
28203
self.assertHolidayName("Újév", (f"{year}-01-01" for year in range(1945, 2050)))
29204

@@ -48,6 +223,7 @@ def test_good_friday(self):
48223
"2022-04-15",
49224
"2023-04-07",
50225
)
226+
self.assertHolidayName(name, range(2017, 2050))
51227
self.assertNoHolidayName(name, range(1945, 2017))
52228

53229
def test_easter(self):
@@ -182,93 +358,6 @@ def test_october_socialist_revolution_day(self):
182358
self.assertNoHoliday(f"{year}-11-07" for year in years_absent)
183359
self.assertNoHolidayName(name, years_absent)
184360

185-
def test_substituted(self):
186-
dt = (
187-
"1991-08-19",
188-
"1992-08-21",
189-
"1992-12-24",
190-
"1993-12-24",
191-
"1994-03-14",
192-
"1997-05-02",
193-
"1997-10-24",
194-
"1997-12-24",
195-
"1998-01-02",
196-
"1998-08-21",
197-
"1998-12-24",
198-
"1999-12-24",
199-
"2001-03-16",
200-
"2001-04-30",
201-
"2001-10-22",
202-
"2001-11-02",
203-
"2001-12-24",
204-
"2001-12-31",
205-
"2002-08-19",
206-
"2002-12-24",
207-
"2003-05-02",
208-
"2003-10-24",
209-
"2003-12-24",
210-
"2004-01-02",
211-
"2004-12-24",
212-
"2005-03-14",
213-
"2005-10-31",
214-
"2007-03-16",
215-
"2007-04-30",
216-
"2007-10-22",
217-
"2007-11-02",
218-
"2007-12-24",
219-
"2007-12-31",
220-
"2008-05-02",
221-
"2008-10-24",
222-
"2008-12-24",
223-
"2009-01-02",
224-
"2009-08-21",
225-
"2009-12-24",
226-
"2010-12-24",
227-
"2011-03-14",
228-
"2011-10-31",
229-
"2012-03-16",
230-
"2012-04-30",
231-
"2012-10-22",
232-
"2012-11-02",
233-
"2012-12-24",
234-
"2012-12-31",
235-
"2013-08-19",
236-
"2013-12-24",
237-
"2013-12-27",
238-
"2014-05-02",
239-
"2014-10-24",
240-
"2014-12-24",
241-
"2015-01-02",
242-
"2015-08-21",
243-
"2015-12-24",
244-
"2016-03-14",
245-
"2016-10-31",
246-
"2018-03-16",
247-
"2018-04-30",
248-
"2018-10-22",
249-
"2018-11-02",
250-
"2018-12-24",
251-
"2018-12-31",
252-
"2019-08-19",
253-
"2019-12-24",
254-
"2019-12-27",
255-
"2020-08-21",
256-
"2020-12-24",
257-
"2021-12-24",
258-
"2022-03-14",
259-
"2022-10-31",
260-
"2024-08-19",
261-
"2024-12-24",
262-
"2024-12-27",
263-
"2025-05-02",
264-
"2025-10-24",
265-
"2025-12-24",
266-
"2026-01-02",
267-
"2026-08-21",
268-
"2026-12-24",
269-
)
270-
self.assertHoliday(dt)
271-
272361
def test_2021(self):
273362
self.assertHolidays(
274363
Hungary(years=2021),

0 commit comments

Comments
 (0)