Skip to content

Commit 1e32e83

Browse files
committed
Created test file for each country and moved corresponding tests there
1 parent 5b5bcf9 commit 1e32e83

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

71 files changed

+10195
-6817
lines changed

tests.py

-6,817
This file was deleted.

tests/countries/__init__.py

+27
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
# -*- coding: utf-8 -*-
2+
3+
# python-holidays
4+
# ---------------
5+
# A fast, efficient Python library for generating country, province and state
6+
# specific sets of holidays on the fly. It aims to make determining whether a
7+
# specific date is a holiday as fast and flexible as possible.
8+
#
9+
# Author: ryanss <[email protected]> (c) 2014-2017
10+
# dr-prodigy <[email protected]> (c) 2017-2020
11+
# Website: https://github.com/dr-prodigy/python-holidays
12+
# License: MIT (see LICENSE file)
13+
14+
import os
15+
import sys
16+
import unittest
17+
import warnings
18+
from glob import glob
19+
from itertools import product
20+
21+
from datetime import date, datetime, timedelta
22+
from dateutil.relativedelta import relativedelta, MO
23+
from flake8.api import legacy as flake8
24+
25+
import holidays
26+
27+

tests/countries/test_angola.py

+55
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
# -*- coding: utf-8 -*-
2+
3+
# python-holidays
4+
# ---------------
5+
# A fast, efficient Python library for generating country, province and state
6+
# specific sets of holidays on the fly. It aims to make determining whether a
7+
# specific date is a holiday as fast and flexible as possible.
8+
#
9+
# Author: ryanss <[email protected]> (c) 2014-2017
10+
# dr-prodigy <[email protected]> (c) 2017-2020
11+
# Website: https://github.com/dr-prodigy/python-holidays
12+
# License: MIT (see LICENSE file)
13+
14+
import os
15+
import sys
16+
import unittest
17+
import warnings
18+
from glob import glob
19+
from itertools import product
20+
21+
from datetime import date, datetime, timedelta
22+
from dateutil.relativedelta import relativedelta, MO
23+
from flake8.api import legacy as flake8
24+
25+
import holidays
26+
27+
28+
class TestAngola(unittest.TestCase):
29+
def setUp(self):
30+
self.holidays = holidays.AO()
31+
32+
def test_new_years(self):
33+
self.assertIn("1975-01-01", self.holidays)
34+
self.assertIn("2017-01-01", self.holidays)
35+
self.assertIn("2999-01-01", self.holidays)
36+
self.assertIn("2017-01-02", self.holidays) # sunday
37+
38+
def test_easter(self):
39+
self.assertIn(date(2017, 4, 14), self.holidays)
40+
self.assertIn(date(2020, 4, 10), self.holidays)
41+
self.assertIn(date(1994, 4, 1), self.holidays)
42+
43+
def test_static(self):
44+
self.assertIn("2004-03-08", self.holidays)
45+
self.assertIn("2020-03-23", self.holidays)
46+
47+
def test_long_weekend(self):
48+
self.assertIn("2020-02-03", self.holidays)
49+
self.assertIn("2019-04-05", self.holidays)
50+
self.assertIn("2050-03-07", self.holidays)
51+
52+
def test_not_holiday(self):
53+
self.assertNotIn("2016-12-28", self.holidays)
54+
self.assertNotIn("2015-03-02", self.holidays)
55+
self.assertNotIn("2018-03-23", self.holidays)

tests/countries/test_argentina.py

+178
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,178 @@
1+
# -*- coding: utf-8 -*-
2+
3+
# python-holidays
4+
# ---------------
5+
# A fast, efficient Python library for generating country, province and state
6+
# specific sets of holidays on the fly. It aims to make determining whether a
7+
# specific date is a holiday as fast and flexible as possible.
8+
#
9+
# Author: ryanss <[email protected]> (c) 2014-2017
10+
# dr-prodigy <[email protected]> (c) 2017-2020
11+
# Website: https://github.com/dr-prodigy/python-holidays
12+
# License: MIT (see LICENSE file)
13+
14+
import os
15+
import sys
16+
import unittest
17+
import warnings
18+
from glob import glob
19+
from itertools import product
20+
21+
from datetime import date, datetime, timedelta
22+
from dateutil.relativedelta import relativedelta, MO
23+
from flake8.api import legacy as flake8
24+
25+
import holidays
26+
27+
28+
class TestAR(unittest.TestCase):
29+
def setUp(self):
30+
self.holidays = holidays.AR(observed=True)
31+
32+
def test_new_years(self):
33+
self.holidays.observed = False
34+
self.assertNotIn(date(2010, 12, 31), self.holidays)
35+
self.assertNotIn(date(2017, 1, 2), self.holidays)
36+
self.holidays.observed = True
37+
self.assertIn(date(2017, 1, 1), self.holidays)
38+
for year in range(1900, 2100):
39+
dt = date(year, 1, 1)
40+
self.assertIn(dt, self.holidays)
41+
self.assertNotIn(dt + relativedelta(days=-1), self.holidays)
42+
self.assertNotIn(dt + relativedelta(days=+1), self.holidays)
43+
44+
def test_carnival_day(self):
45+
for dt in [
46+
date(2018, 2, 12),
47+
date(2018, 2, 13),
48+
date(2017, 2, 27),
49+
date(2017, 2, 28),
50+
date(2016, 2, 8),
51+
date(2016, 2, 9),
52+
]:
53+
self.assertIn(dt, self.holidays)
54+
55+
def test_memory_national_day(self):
56+
self.holidays.observed = False
57+
self.assertNotIn(date(1907, 3, 24), self.holidays)
58+
self.assertNotIn(date(2002, 3, 24), self.holidays)
59+
self.holidays.observed = True
60+
for dt in [date(2018, 3, 24), date(2017, 3, 24), date(2016, 3, 24)]:
61+
self.assertIn(dt, self.holidays)
62+
63+
def test_holy_week_day(self):
64+
for dt in [
65+
date(2018, 3, 29),
66+
date(2018, 3, 30),
67+
date(2017, 4, 13),
68+
date(2017, 4, 14),
69+
date(2016, 3, 24),
70+
date(2016, 3, 25),
71+
]:
72+
self.assertIn(dt, self.holidays)
73+
74+
def test_malvinas_war_day(self):
75+
for year in range(1900, 2100):
76+
dt = date(year, 4, 2)
77+
self.assertIn(dt, self.holidays)
78+
79+
def test_labor_day(self):
80+
self.holidays.observed = False
81+
self.assertNotIn(date(2010, 4, 30), self.holidays)
82+
self.assertNotIn(date(2011, 5, 2), self.holidays)
83+
self.holidays.observed = True
84+
self.assertIn(date(1922, 5, 1), self.holidays)
85+
for year in range(1900, 2100):
86+
dt = date(year, 5, 1)
87+
self.assertIn(dt, self.holidays)
88+
self.assertNotIn(dt + relativedelta(days=-1), self.holidays)
89+
self.assertNotIn(dt + relativedelta(days=+1), self.holidays)
90+
91+
def test_may_revolution_day(self):
92+
self.holidays.observed = False
93+
self.assertNotIn(date(1930, 5, 25), self.holidays)
94+
self.assertNotIn(date(2014, 5, 25), self.holidays)
95+
self.holidays.observed = True
96+
for year in range(1900, 2100):
97+
dt = date(year, 5, 1)
98+
self.assertIn(dt, self.holidays)
99+
self.assertNotIn(dt + relativedelta(days=-1), self.holidays)
100+
self.assertNotIn(dt + relativedelta(days=+1), self.holidays)
101+
102+
def test_guemes_day(self):
103+
for year in range(1900, 2100):
104+
dt = date(year, 6, 17)
105+
self.assertIn(dt, self.holidays)
106+
self.assertNotIn(dt + relativedelta(days=-1), self.holidays)
107+
self.assertNotIn(dt + relativedelta(days=+1), self.holidays)
108+
109+
def test_belgrano_day(self):
110+
for year in range(1900, 2100):
111+
dt = date(year, 6, 20)
112+
self.assertIn(dt, self.holidays)
113+
self.assertNotIn(dt + relativedelta(days=-1), self.holidays)
114+
self.assertNotIn(dt + relativedelta(days=+1), self.holidays)
115+
116+
def test_independence_day(self):
117+
self.holidays.observed = False
118+
self.assertNotIn(date(2017, 7, 9), self.holidays)
119+
self.assertNotIn(date(2011, 7, 9), self.holidays)
120+
self.holidays.observed = True
121+
self.assertIn(date(2017, 7, 9), self.holidays)
122+
self.assertIn(date(2011, 7, 9), self.holidays)
123+
for year in range(1900, 2100):
124+
dt = date(year, 7, 9)
125+
self.assertIn(dt, self.holidays)
126+
self.assertNotIn(dt + relativedelta(days=-1), self.holidays)
127+
self.assertNotIn(dt + relativedelta(days=+1), self.holidays)
128+
129+
def test_san_martin_day(self):
130+
self.holidays.observed = False
131+
self.assertNotIn(date(1930, 8, 10), self.holidays)
132+
self.assertNotIn(date(2008, 8, 10), self.holidays)
133+
self.holidays.observed = True
134+
for year in range(1900, 2100):
135+
dt = date(year, 8, 17)
136+
self.assertIn(dt, self.holidays)
137+
self.assertNotIn(dt + relativedelta(days=-1), self.holidays)
138+
self.assertNotIn(dt + relativedelta(days=+1), self.holidays)
139+
140+
def test_cultural_day(self):
141+
self.holidays.observed = False
142+
self.assertNotIn(date(2014, 10, 12), self.holidays)
143+
self.assertNotIn(date(1913, 10, 12), self.holidays)
144+
self.holidays.observed = True
145+
for year in range(1900, 2100):
146+
dt = date(year, 10, 12)
147+
self.assertIn(dt, self.holidays)
148+
self.assertNotIn(dt + relativedelta(days=-1), self.holidays)
149+
self.assertNotIn(dt + relativedelta(days=+1), self.holidays)
150+
151+
def test_national_sovereignty_day(self):
152+
for year in range(1900, 2100):
153+
dt = date(year, 11, 20)
154+
if year < 2010:
155+
self.assertNotIn(dt, self.holidays)
156+
else:
157+
self.assertIn(dt, self.holidays)
158+
self.assertNotIn(dt + relativedelta(days=-1), self.holidays)
159+
self.assertNotIn(dt + relativedelta(days=+1), self.holidays)
160+
161+
def test_inmaculate_conception_day(self):
162+
self.holidays.observed = False
163+
self.assertNotIn(date(1940, 12, 8), self.holidays)
164+
self.assertNotIn(date(2013, 12, 8), self.holidays)
165+
self.holidays.observed = True
166+
for year in range(1900, 2100):
167+
dt = date(year, 12, 8)
168+
self.assertIn(dt, self.holidays)
169+
self.assertNotIn(dt + relativedelta(days=-1), self.holidays)
170+
self.assertNotIn(dt + relativedelta(days=+1), self.holidays)
171+
172+
def test_christmas(self):
173+
for year in range(1900, 2100):
174+
dt = date(year, 12, 25)
175+
self.assertIn(dt, self.holidays)
176+
self.assertNotIn(dt + relativedelta(days=-1), self.holidays)
177+
self.assertNotIn(dt + relativedelta(days=+1), self.holidays)
178+

tests/countries/test_aruba.py

+110
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,110 @@
1+
# -*- coding: utf-8 -*-
2+
3+
# python-holidays
4+
# ---------------
5+
# A fast, efficient Python library for generating country, province and state
6+
# specific sets of holidays on the fly. It aims to make determining whether a
7+
# specific date is a holiday as fast and flexible as possible.
8+
#
9+
# Author: ryanss <[email protected]> (c) 2014-2017
10+
# dr-prodigy <[email protected]> (c) 2017-2020
11+
# Website: https://github.com/dr-prodigy/python-holidays
12+
# License: MIT (see LICENSE file)
13+
14+
import os
15+
import sys
16+
import unittest
17+
import warnings
18+
from glob import glob
19+
from itertools import product
20+
21+
from datetime import date, datetime, timedelta
22+
from dateutil.relativedelta import relativedelta, MO
23+
from flake8.api import legacy as flake8
24+
25+
import holidays
26+
27+
28+
class TestAruba(unittest.TestCase):
29+
def setUp(self):
30+
self.holidays = holidays.AW()
31+
32+
def test_2017(self):
33+
self.assertIn(date(2017, 1, 1), self.holidays)
34+
self.assertIn(date(2017, 1, 25), self.holidays)
35+
self.assertIn(date(2017, 3, 18), self.holidays)
36+
self.assertIn(date(2017, 2, 27), self.holidays)
37+
self.assertIn(date(2017, 4, 14), self.holidays)
38+
self.assertIn(date(2017, 4, 17), self.holidays)
39+
self.assertIn(date(2017, 4, 27), self.holidays)
40+
self.assertIn(date(2017, 5, 1), self.holidays)
41+
self.assertIn(date(2017, 5, 25), self.holidays)
42+
self.assertIn(date(2017, 12, 25), self.holidays)
43+
self.assertIn(date(2017, 12, 26), self.holidays)
44+
45+
def test_new_years(self):
46+
self.assertIn(date(2017, 1, 1), self.holidays)
47+
48+
def test_betico_day(self):
49+
self.assertIn(date(2017, 1, 25), self.holidays)
50+
51+
def test_carnaval_monday(self):
52+
self.assertIn(date(2017, 2, 27), self.holidays)
53+
54+
def test_anthem_and_flag_day(self):
55+
self.assertIn(date(2017, 3, 18), self.holidays)
56+
57+
def test_good_friday(self):
58+
self.assertIn(date(2017, 4, 14), self.holidays)
59+
60+
def test_easter_monday(self):
61+
self.assertIn(date(2017, 4, 17), self.holidays)
62+
63+
def test_labour_day(self):
64+
self.assertIn(date(2017, 5, 1), self.holidays)
65+
66+
def test_queens_day_between_1891_and_1948(self):
67+
# Between 1891 and 1948 Queens Day was celebrated on 8-31
68+
self.holidays = holidays.AW(years=[1901])
69+
self.assertIn(date(1901, 8, 31), self.holidays)
70+
71+
def test_queens_day_between_1891_and_1948_substituted_later(self):
72+
# Between 1891 and 1948 Queens Day was celebrated on 9-1
73+
# (one day later) when Queens Day falls on a Sunday
74+
self.holidays = holidays.AW(years=[1947])
75+
self.assertIn(date(1947, 9, 1), self.holidays)
76+
77+
def test_queens_day_between_1949_and_2013(self):
78+
self.holidays = holidays.AW(years=[1965])
79+
self.assertIn(date(1965, 4, 30), self.holidays)
80+
81+
def test_queens_day_between_1949_and_1980_substituted_later(self):
82+
self.holidays = holidays.AW(years=[1967])
83+
self.assertIn(date(1967, 5, 1), self.holidays)
84+
85+
def test_queens_day_between_1980_and_2013_substituted_earlier(self):
86+
self.holidays = holidays.AW(years=[2006])
87+
self.assertIn(date(2006, 4, 29), self.holidays)
88+
89+
def test_kings_day_after_2014(self):
90+
self.holidays = holidays.AW(years=[2013])
91+
self.assertNotIn(date(2013, 4, 27), self.holidays)
92+
93+
self.holidays = holidays.AW(years=[2017])
94+
self.assertIn(date(2017, 4, 27), self.holidays)
95+
96+
def test_kings_day_after_2014_substituted_earlier(self):
97+
self.holidays = holidays.AW(years=[2188])
98+
self.assertIn(date(2188, 4, 26), self.holidays)
99+
100+
def test_ascension_day(self):
101+
self.holidays = holidays.AW(years=2017)
102+
self.assertIn(date(2017, 5, 25), self.holidays)
103+
104+
def test_christmas(self):
105+
self.holidays = holidays.AW(years=2017)
106+
self.assertIn(date(2017, 12, 25), self.holidays)
107+
108+
def test_second_christmas(self):
109+
self.holidays = holidays.AW(years=2017)
110+
self.assertIn(date(2017, 12, 26), self.holidays)

0 commit comments

Comments
 (0)