Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def test_nevada_day(self):
nv_holidays = holidays.US(state='NV')
self.assertFalse(date(1932, 10, 31) in nv_holidays)
for dt in [date(1933, 10, 31), date(1999, 10, 31), date(2000, 10, 27),
date(2002, 10, 25), date(2014, 10, 31), date(2015, 10, 30)]:
self.assertFalse(dt in self.holidays)
self.assertTrue(dt in nv_holidays)
self.assertTrue("Nevada Day (Observed)" in
nv_holidays.get_list(date(1998, 10, 30)))
self.assertTrue("Nevada Day (Observed)" in
nv_holidays.get_list(date(1999, 11, 1)))
nv_holidays.observed = False
self.assertFalse("Nevada Day (Observed)" in
nv_holidays.get_list(date(1998, 10, 30)))
self.assertFalse("Nevada Day (Observed)" in
nv_holidays.get_list(date(1999, 11, 1)))
def test_jefferson_davis_birthday(self):
al_holidays = holidays.US(state='AL')
self.assertFalse(date(1889, 6, 3) in self.holidays)
self.assertFalse(date(1889, 6, 3) in al_holidays)
for dt in [date(1890, 6, 2), date(1891, 6, 1), date(1897, 6, 7),
date(2014, 6, 2), date(2015, 6, 1), date(2016, 6, 6)]:
self.assertFalse(dt in self.holidays)
self.assertTrue(dt in al_holidays)
def test_lady_of_camarin_day(self):
gu_holidays = holidays.US(state='GU')
for year in range(1945, 2100):
self.assertFalse(date(year, 12, 8) in self.holidays)
self.assertTrue(date(year, 12, 8) in gu_holidays)
def test_good_friday(self):
ct_holidays = holidays.US(state='CT')
de_holidays = holidays.US(state='DE')
gu_holidays = holidays.US(state='GU')
in_holidays = holidays.US(state='IN')
ky_holidays = holidays.US(state='IN')
la_holidays = holidays.US(state='LA')
nj_holidays = holidays.US(state='NJ')
nc_holidays = holidays.US(state='NC')
tn_holidays = holidays.US(state='TN')
tx_holidays = holidays.US(state='TX')
vi_holidays = holidays.US(state='VI')
for dt in [date(1900, 4, 13), date(1901, 4, 5), date(1902, 3, 28),
date(1999, 4, 2), date(2000, 4, 21), date(2010, 4, 2),
date(2018, 3, 30), date(2019, 4, 19), date(2020, 4, 10)]:
self.assertFalse(dt in self.holidays)
self.assertTrue(dt in ct_holidays)
self.assertTrue(dt in de_holidays)
self.assertTrue(dt in gu_holidays)
self.assertTrue(dt in in_holidays)
self.assertTrue(dt in ky_holidays)
self.assertTrue(dt in la_holidays)
self.assertTrue(dt in nj_holidays)
self.assertTrue(dt in nc_holidays)
self.assertTrue(dt in tn_holidays)
self.assertTrue(dt in tx_holidays)
self.assertTrue(dt in vi_holidays)
def test_good_friday(self):
ct_holidays = holidays.US(state='CT')
de_holidays = holidays.US(state='DE')
gu_holidays = holidays.US(state='GU')
in_holidays = holidays.US(state='IN')
ky_holidays = holidays.US(state='IN')
la_holidays = holidays.US(state='LA')
nj_holidays = holidays.US(state='NJ')
nc_holidays = holidays.US(state='NC')
tn_holidays = holidays.US(state='TN')
tx_holidays = holidays.US(state='TX')
vi_holidays = holidays.US(state='VI')
for dt in [date(1900, 4, 13), date(1901, 4, 5), date(1902, 3, 28),
date(1999, 4, 2), date(2000, 4, 21), date(2010, 4, 2),
date(2018, 3, 30), date(2019, 4, 19), date(2020, 4, 10)]:
self.assertFalse(dt in self.holidays)
self.assertTrue(dt in ct_holidays)
self.assertTrue(dt in de_holidays)
self.assertTrue(dt in gu_holidays)
self.assertTrue(dt in in_holidays)
self.assertTrue(dt in ky_holidays)
self.assertTrue(dt in la_holidays)
self.assertTrue(dt in nj_holidays)
def test_good_friday(self):
ct_holidays = holidays.US(state='CT')
de_holidays = holidays.US(state='DE')
gu_holidays = holidays.US(state='GU')
in_holidays = holidays.US(state='IN')
ky_holidays = holidays.US(state='IN')
la_holidays = holidays.US(state='LA')
nj_holidays = holidays.US(state='NJ')
nc_holidays = holidays.US(state='NC')
tn_holidays = holidays.US(state='TN')
tx_holidays = holidays.US(state='TX')
vi_holidays = holidays.US(state='VI')
for dt in [date(1900, 4, 13), date(1901, 4, 5), date(1902, 3, 28),
date(1999, 4, 2), date(2000, 4, 21), date(2010, 4, 2),
date(2018, 3, 30), date(2019, 4, 19), date(2020, 4, 10)]:
self.assertFalse(dt in self.holidays)
self.assertTrue(dt in ct_holidays)
self.assertTrue(dt in de_holidays)
self.assertTrue(dt in gu_holidays)
self.assertTrue(dt in in_holidays)
self.assertTrue(dt in ky_holidays)
self.assertTrue(dt in la_holidays)
self.assertTrue(dt in nj_holidays)
self.assertTrue(dt in nc_holidays)
self.assertTrue(dt in tn_holidays)
def test_truman_day(self):
mo_holidays = holidays.US(state='MO', observed=False)
self.assertFalse(date(1948, 5, 8) in self.holidays)
self.assertFalse(date(1948, 5, 8) in mo_holidays)
for year in range(1949, 2100):
dt = date(year, 5, 8)
self.assertFalse(dt in self.holidays)
self.assertTrue(dt in mo_holidays)
self.assertFalse(dt + relativedelta(days=-1) in mo_holidays)
self.assertFalse(dt + relativedelta(days=+1) in mo_holidays)
self.assertFalse(date(2004, 5, 7) in mo_holidays)
self.assertFalse(date(2005, 5, 10) in mo_holidays)
mo_holidays.observed = True
self.assertTrue(date(2004, 5, 7) in mo_holidays)
self.assertTrue(date(2005, 5, 10) in mo_holidays)
def test_election_day(self):
de_holidays = holidays.US(state='DE')
hi_holidays = holidays.US(state='HI')
il_holidays = holidays.US(state='IL')
in_holidays = holidays.US(state='IN')
la_holidays = holidays.US(state='LA')
mt_holidays = holidays.US(state='MT')
nh_holidays = holidays.US(state='NH')
nj_holidays = holidays.US(state='NJ')
ny_holidays = holidays.US(state='NY')
wv_holidays = holidays.US(state='WV')
self.assertFalse(date(2004, 11, 2) in de_holidays)
for dt in [date(2008, 11, 4), date(2010, 11, 2), date(2012, 11, 6),
date(2014, 11, 4), date(2016, 11, 8), date(2018, 11, 6)]:
self.assertFalse(dt in self.holidays)
self.assertTrue(dt in de_holidays)
self.assertTrue(dt in hi_holidays)
self.assertTrue(dt in il_holidays)
self.assertTrue(dt in in_holidays)
self.assertTrue(dt in la_holidays)
self.assertTrue(dt in mt_holidays)
self.assertTrue(dt in nh_holidays)
self.assertTrue(dt in nj_holidays)
self.assertTrue(dt in ny_holidays)
self.assertTrue(dt in wv_holidays)
def test_inheritance(self):
class NoColumbusHolidays(holidays.US):
def _populate(self, year):
holidays.US._populate(self, year)
self.pop(date(year, 10, 1) + relativedelta(weekday=MO(+2)))
hdays = NoColumbusHolidays()
self.assertTrue(date(2014, 10, 13) in self.holidays)
self.assertFalse(date(2014, 10, 13) in hdays)
self.assertTrue(date(2014, 1, 1) in hdays)
self.assertTrue(date(2020, 10, 12) in self.holidays)
self.assertFalse(date(2020, 10, 12) in hdays)
self.assertTrue(date(2020, 1, 1) in hdays)
class NinjaTurtlesHolidays(holidays.US):
def _populate(self, year):
holidays.US._populate(self, year)
self[date(year, 7, 13)] = "Ninja Turtle's Day"
hdays = NinjaTurtlesHolidays()