diff --git a/.flake8 b/.flake8 deleted file mode 100644 index dd011c7e6..000000000 --- a/.flake8 +++ /dev/null @@ -1,4 +0,0 @@ -[flake8] -ignore = F401,W504 -exclude = __init__.py,*.pyc,tests.py -paths = ./holidays/ \ No newline at end of file diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 000000000..236de7e77 --- /dev/null +++ b/.gitattributes @@ -0,0 +1,2 @@ +* text=lf +*.bat text eol=crlf diff --git a/.github/dependabot.yml b/.github/dependabot.yml new file mode 100644 index 000000000..f7e4ce290 --- /dev/null +++ b/.github/dependabot.yml @@ -0,0 +1,14 @@ +version: 2 +updates: + - package-ecosystem: pip + directory: / + schedule: + interval: weekly + day: friday + + # Maintain dependencies for GitHub Actions + - package-ecosystem: github-actions + directory: / + schedule: + interval: weekly + day: friday diff --git a/.github/workflows/ci-cd.yml b/.github/workflows/ci-cd.yml new file mode 100644 index 000000000..15135b8e9 --- /dev/null +++ b/.github/workflows/ci-cd.yml @@ -0,0 +1,81 @@ +name: "Tests" +on: [push, pull_request, workflow_dispatch] + +jobs: + pre-commit: + name: Run Quality Assurance + runs-on: ubuntu-latest + steps: + - name: Check out repo + uses: actions/checkout@v2 + - name: Set up Python + uses: actions/setup-python@v2 + - name: Run pre-commit + uses: pre-commit/action@v2.0.0 + + test: + name: "Test: python=${{ matrix.python-version }} on ${{ matrix.os }}" + runs-on: ${{ matrix.os }} + needs: [pre-commit] + strategy: + matrix: + os: [ubuntu-latest, windows-latest, macOS-latest] + python-version: [3.6, 3.7, 3.8, 3.9, pypy3] + + steps: + - uses: actions/checkout@v2 + - name: Set up Python ${{ matrix.python-version }} + uses: actions/setup-python@v2 + with: + python-version: ${{ matrix.python-version }} + - name: Install dependencies + run: | + python -m pip install -U pip wheel 'coveralls>=3' + python -m pip install -U -r requirements_dev.txt + python -m pip install -e . + - name: Run tests + run: | + py.test + - name: Upload Coverage + run: coveralls --service=github + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + COVERALLS_FLAG_NAME: tests-${{ matrix.python-version }}-${{ matrix.os }} + COVERALLS_PARALLEL: true + + coveralls: + name: Finish Coveralls + needs: [test] + runs-on: ubuntu-latest + container: python:3-slim + steps: + - name: Finished + run: | + pip3 install -U 'coveralls>=3' + coveralls --finish --service=github + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + + deploy: + runs-on: ubuntu-latest + if: github.event_name == 'push' && startsWith(github.event.ref, 'refs/tags') + needs: [test] + steps: + - uses: actions/checkout@v2 + - name: Set up Python 3.7 + uses: actions/setup-python@v2 + with: + python-version: 3.7 + - name: Install dependencies + run: | + python -m pip install -U pip wheel + pip install -U . + - name: Build dist + run: | + python setup.py sdist bdist_wheel + + - name: Publish package + uses: pypa/gh-action-pypi-publish@v1.4.1 + with: + user: __token__ + password: ${{ secrets.pypi_password }} diff --git a/.gitignore b/.gitignore index a467cdbdc..9dd956f9f 100644 --- a/.gitignore +++ b/.gitignore @@ -6,8 +6,14 @@ MANIFEST *.egg-info *.pyc .idea +<<<<<<< HEAD # IDE Stuff .vscode/ *.DS_Store +======= +.vscode/ +coverage.xml +.tox +>>>>>>> 10aa24a6058b8a4c65e533b7fcd10948a0ffadf1 diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml new file mode 100644 index 000000000..e5e295aea --- /dev/null +++ b/.pre-commit-config.yaml @@ -0,0 +1,33 @@ +repos: + - repo: https://github.com/pre-commit/pre-commit-hooks + rev: v3.3.0 + hooks: + - id: check-ast + - id: check-builtin-literals + - id: end-of-file-fixer + - id: trailing-whitespace + - id: fix-encoding-pragma + - id: mixed-line-ending + args: [--fix=lf] + + - repo: https://github.com/python/black + rev: 20.8b1 + hooks: + - id: black + language_version: python3 + + - repo: https://gitlab.com/pycqa/flake8 + rev: 3.8.4 + hooks: + - id: flake8 + + - repo: https://github.com/pre-commit/pygrep-hooks + rev: v1.7.0 + hooks: + - id: rst-backticks + + - repo: https://github.com/myint/rstcheck + rev: 3f92957478422df87bd730abde66f089cc1ee19b + hooks: + - id: rstcheck + additional_dependencies: [rstcheck] diff --git a/.travis.yml b/.travis.yml index a90cd0412..445fd2d32 100644 --- a/.travis.yml +++ b/.travis.yml @@ -9,6 +9,7 @@ before_install: install: - pip install flake8 - pip install coveralls + - pip install toml - python setup.py install @@ -20,9 +21,6 @@ matrix: - python: '3.6' - python: 'pypy3' -before_script: - - flake8 - script: - coverage run --omit=*site-packages*,*pypy* tests.py diff --git a/CHANGES b/CHANGES index 0cc63b6b9..6e288c91b 100644 --- a/CHANGES +++ b/CHANGES @@ -3,6 +3,7 @@ Version 0.10.5.3 Released - +- Github Actions CI/CD integration (s-weigand, dr-p) - Support for Saudi Arabia #429 (OsaydAbdu) - __init.py__ flake8 issue fix #423 (dr-p) - Korea 2020 fix #414, #415 (dr-p, janggiKim, spar7453) diff --git a/README.rst b/README.rst index b3143ec42..8236fd7d2 100644 --- a/README.rst +++ b/README.rst @@ -6,8 +6,8 @@ A fast, efficient Python library for generating country, province and state specific sets of holidays on the fly. It aims to make determining whether a specific date is a holiday as fast and flexible as possible. -.. image:: http://img.shields.io/travis/dr-prodigy/python-holidays/master - :target: https://travis-ci.org/dr-prodigy/python-holidays +.. image:: https://github.com/dr-prodigy/python-holidays/workflows/Tests/badge.svg + :target: https://github.com/dr-prodigy/python-holidays/actions .. image:: http://img.shields.io/coveralls/dr-prodigy/python-holidays/master :target: https://coveralls.io/r/dr-prodigy/python-holidays @@ -225,30 +225,30 @@ state Methods: get(key, default=None) - Returns a string containing the name of the holiday(s) in date `key`, which + Returns a string containing the name of the holiday(s) in date ``key``, which can be of date, datetime, string, unicode, bytes, integer or float type. If multiple holidays fall on the same date the names will be separated by commas get(key, default=None) - Returns a string containing the name of the holiday(s) in date `key`, which + Returns a string containing the name of the holiday(s) in date ``key``, which can be of date, datetime, string, unicode, bytes, integer or float type. If multiple holidays fall on the same date the names will be separated by commas get_list(key) - Same as `get` except returns a `list` of holiday names instead of a comma + Same as ``get`` except returns a ``list`` of holiday names instead of a comma separated string get_named(name) - Returns a `list` of holidays matching (even partially) the provided name + Returns a ``list`` of holidays matching (even partially) the provided name (case insensitive check) pop(key, default=None) - Same as `get` except the key is removed from the holiday object + Same as ``get`` except the key is removed from the holiday object pop_named(name) - Same as `pop` but takes the name of the holiday (or part of it) rather than + Same as ``pop`` but takes the name of the holiday (or part of it) rather than the date update/append @@ -267,7 +267,7 @@ More Examples >>> import holidays >>> date(2014, 1, 1) in holidays.US() True - >> date(2014, 1, 2) in holidays.US() + >>> date(2014, 1, 2) in holidays.US() False # But this is not efficient because it is initializing a new Holiday object @@ -316,7 +316,7 @@ More Examples >>> len(us_holidays) 10 - # Because by default the `expand` param is True the Holiday object will add + # Because by default the ``expand`` param is True the Holiday object will add # holidays from other years as they are required. >>> date(2013, 1, 1) in us_holidays @@ -326,7 +326,7 @@ More Examples >>> len(us_holidays) 20 - # If we change the `expand` param to False the Holiday object will no longer + # If we change the ``expand`` param to False the Holiday object will no longer # add holidays from new years >>> us_holidays.expand = False @@ -337,7 +337,7 @@ More Examples True # January 1st, 2012 fell on a Sunday so the statutory holiday was observed - # on the 2nd. By default the `observed` param is True so the holiday list + # on the 2nd. By default the ``observed`` param is True so the holiday list # will include January 2nd, 2012 as a holiday. >>> date(2012, 1, 1) in us_holidays @@ -349,7 +349,7 @@ More Examples >>> us_holidays.get(date(2012 ,1, 2)) "New Year's Day (Observed)" - # The `observed` and `expand` values can both be changed on the fly and the + # The ``observed`` and ``expand`` values can both be changed on the fly and the # holiday list will be adjusted accordingly >>> us_holidays.observed = False @@ -384,7 +384,7 @@ More Examples 'QC', 'SK', 'YU'] # Holidays can be retrieved using their name too. - # `get_named(key)` receives a string and returns a list of holidays + # ``get_named(key)`` receives a string and returns a list of holidays # matching it (even partially, with case insensitive check) >>> us_holidays = holidays.UnitedStates(years=2020) @@ -476,24 +476,33 @@ The latest development (beta) version can be installed directly from GitHub: All new features are always first pushed to beta branch, then released on master branch upon official version upgrades. -Running Tests -------------- +Running Tests and Coverage +-------------------------- .. code-block:: bash - $ pip install flake8 - $ flake8 - $ python tests.py + $ pip install -r requirements_dev.txt + $ python -m pytest . + + +Ensure all staged files are up to standard +------------------------------------------ + +.. _pre-commit: https://github.com/dr-prodigy/python-holidays/issues + +Install the githooks with `pre-commit`_, after that the quality assurance +tests will run on all staged files before you commit them and intercept +the commit if the staged files aren't up to standard. + +.. code-block:: bash + $ pre-commit install -Coverage --------- +Manually run the quality assurance tests on all tracked files. .. code-block:: bash - $ pip install coverage - $ coverage run --omit=*site-packages* tests.py - $ coverage report -m + $ pre-commit run -a Contributions diff --git a/__init__.py b/__init__.py deleted file mode 100644 index e69de29bb..000000000 diff --git a/holidays/__init__.py b/holidays/__init__.py index 3668c45b6..cf7c0c83d 100644 --- a/holidays/__init__.py +++ b/holidays/__init__.py @@ -12,10 +12,21 @@ # License: MIT (see LICENSE file) from holidays.countries import * from holidays.constants import MON, TUE, WED, THU, FRI, SAT, SUN, WEEKEND -from holidays.constants import \ - JAN, FEB, MAR, APR, MAY, JUN, \ - JUL, AUG, SEP, OCT, NOV, DEC +from holidays.constants import ( + JAN, + FEB, + MAR, + APR, + MAY, + JUN, + JUL, + AUG, + SEP, + OCT, + NOV, + DEC, +) from holidays.holiday_base import HolidayBase, createHolidaySum from holidays.utils import list_supported_countries, CountryHoliday -__version__ = '0.10.5.3' +__version__ = "0.10.5.3" diff --git a/holidays/constants.py b/holidays/constants.py index 98a5b5b18..96ac9e4e9 100644 --- a/holidays/constants.py +++ b/holidays/constants.py @@ -14,5 +14,4 @@ MON, TUE, WED, THU, FRI, SAT, SUN = range(7) WEEKEND = (SAT, SUN) -JAN, FEB, MAR, APR, MAY, JUN, JUL, AUG, SEP, OCT, \ - NOV, DEC = range(1, 13) +JAN, FEB, MAR, APR, MAY, JUN, JUL, AUG, SEP, OCT, NOV, DEC = range(1, 13) diff --git a/holidays/countries/__init__.py b/holidays/countries/__init__.py index 7ed883b2d..0ecf3f97e 100644 --- a/holidays/countries/__init__.py +++ b/holidays/countries/__init__.py @@ -1,3 +1,4 @@ +# -*- coding: utf-8 -*- # python-holidays # --------------- # A fast, efficient Python library for generating country, province and state @@ -76,7 +77,16 @@ from .turkey import Turkey, TR, TUR from .ukraine import Ukraine, UA, UKR from .united_arab_emirates import UnitedArabEmirates, AE, ARE -from .united_kingdom import UnitedKingdom, UK, GB, England, Wales, Scotland,\ - IsleOfMan, NorthernIreland, GBR +from .united_kingdom import ( + UnitedKingdom, + UK, + GB, + England, + Wales, + Scotland, + IsleOfMan, + NorthernIreland, + GBR, +) from .united_states import UnitedStates, US, USA from .vietnam import Vietnam, VN, VNM diff --git a/holidays/countries/angola.py b/holidays/countries/angola.py index 1ace74dc4..3f2351fb9 100644 --- a/holidays/countries/angola.py +++ b/holidays/countries/angola.py @@ -23,11 +23,10 @@ class Angola(HolidayBase): - def __init__(self, **kwargs): # https://www.officeholidays.com/countries/angola/ # https://www.timeanddate.com/holidays/angola/ - self.country = 'AO' + self.country = "AO" HolidayBase.__init__(self, **kwargs) def _populate(self, year): diff --git a/holidays/countries/argentina.py b/holidays/countries/argentina.py index 72fe44a4d..2bc2fea78 100644 --- a/holidays/countries/argentina.py +++ b/holidays/countries/argentina.py @@ -17,8 +17,7 @@ from dateutil.relativedelta import relativedelta as rd, FR, TH from holidays.constants import WEEKEND -from holidays.constants import JAN, MAR, APR, MAY, JUN, JUL, AUG, OCT, \ - NOV, DEC +from holidays.constants import JAN, MAR, APR, MAY, JUN, JUL, AUG, OCT, NOV, DEC from holidays.holiday_base import HolidayBase @@ -29,7 +28,7 @@ class Argentina(HolidayBase): # https://www.clarin.com/feriados/ def __init__(self, **kwargs): - self.country = 'AR' + self.country = "AR" HolidayBase.__init__(self, **kwargs) def _populate(self, year): @@ -45,8 +44,10 @@ def _populate(self, year): self[easter(year) - rd(days=47)] = name # Memory's National Day for the Truth and Justice - name = "Día Nacional de la Memoria por la Verdad y la Justicia " \ - "[Memory's National Day for the Truth and Justice]" + name = ( + "Día Nacional de la Memoria por la Verdad y la Justicia " + "[Memory's National Day for the Truth and Justice]" + ) if not self.observed and date(year, MAR, 24).weekday() in WEEKEND: pass @@ -56,7 +57,7 @@ def _populate(self, year): # Holy Week name_thu = "Semana Santa (Jueves Santo) [Holy day (Holy Thursday)]" name_fri = "Semana Santa (Viernes Santo) [Holy day (Holy Friday)]" - name_easter = 'Día de Pascuas [Easter Day]' + name_easter = "Día de Pascuas [Easter Day]" self[easter(year) + rd(weekday=TH(-1))] = name_thu self[easter(year) + rd(weekday=FR(-1))] = name_fri @@ -70,10 +71,12 @@ def _populate(self, year): if not self.observed and date(year, APR, 2).weekday() in WEEKEND: pass else: - self[date(year, APR, 2)] = "Día del Veterano y de los Caidos " \ - "en la Guerra de Malvinas [Veterans" \ - " Day and the Fallen in the" \ + self[date(year, APR, 2)] = ( + "Día del Veterano y de los Caidos " + "en la Guerra de Malvinas [Veterans" + " Day and the Fallen in the" " Malvinas War]" + ) # Labor Day name = "Día del Trabajo [Labour Day]" @@ -90,18 +93,22 @@ def _populate(self, year): self[date(year, MAY, 25)] = name # Day Pass to the Immortality of General Martín Miguel de Güemes. - name = "Día Pase a la Inmortalidad " \ - "del General Martín Miguel de Güemes [Day Pass " \ - "to the Immortality of General Martín Miguel de Güemes]" + name = ( + "Día Pase a la Inmortalidad " + "del General Martín Miguel de Güemes [Day Pass " + "to the Immortality of General Martín Miguel de Güemes]" + ) if not self.observed and date(year, JUN, 17).weekday() in WEEKEND: pass else: self[date(year, JUN, 17)] = name # Day Pass to the Immortality of General D. Manuel Belgrano. - name = "Día Pase a la Inmortalidad " \ - "del General D. Manuel Belgrano [Day Pass " \ - "to the Immortality of General D. Manuel Belgrano]" + name = ( + "Día Pase a la Inmortalidad " + "del General D. Manuel Belgrano [Day Pass " + "to the Immortality of General D. Manuel Belgrano]" + ) if not self.observed and date(year, JUN, 20).weekday() in WEEKEND: pass else: @@ -115,9 +122,11 @@ def _populate(self, year): self[date(year, JUL, 9)] = name # Day Pass to the Immortality of General D. José de San Martin - name = "Día Pase a la Inmortalidad " \ - "del General D. José de San Martin [Day Pass " \ - "to the Immortality of General D. José de San Martin]" + name = ( + "Día Pase a la Inmortalidad " + "del General D. José de San Martin [Day Pass " + "to the Immortality of General D. José de San Martin]" + ) if not self.observed and date(year, AUG, 17).weekday() in WEEKEND: pass else: @@ -129,9 +138,11 @@ def _populate(self, year): elif year < 2010: self[date(year, OCT, 12)] = "Día de la Raza [Columbus day]" else: - self[date(year, OCT, 12)] = "Día del Respeto a la Diversidad" \ - " Cultural [Respect for" \ + self[date(year, OCT, 12)] = ( + "Día del Respeto a la Diversidad" + " Cultural [Respect for" " Cultural Diversity Day]" + ) # National Sovereignty Day name = "Día Nacional de la Soberanía [National Sovereignty Day]" if not self.observed and date(year, NOV, 20).weekday() in WEEKEND: @@ -143,8 +154,9 @@ def _populate(self, year): if not self.observed and date(year, DEC, 8).weekday() in WEEKEND: pass else: - self[date(year, DEC, 8)] = "La Inmaculada Concepción" \ - " [Immaculate Conception]" + self[date(year, DEC, 8)] = ( + "La Inmaculada Concepción" " [Immaculate Conception]" + ) # Christmas self[date(year, DEC, 25)] = "Navidad [Christmas]" diff --git a/holidays/countries/aruba.py b/holidays/countries/aruba.py index 7e15bc8f6..067215ec9 100644 --- a/holidays/countries/aruba.py +++ b/holidays/countries/aruba.py @@ -16,8 +16,7 @@ from dateutil.easter import easter from dateutil.relativedelta import relativedelta as rd, FR -from holidays.constants import JAN, MAR, APR, MAY, AUG, \ - DEC +from holidays.constants import JAN, MAR, APR, MAY, AUG, DEC from holidays.holiday_base import HolidayBase @@ -26,7 +25,7 @@ class Aruba(HolidayBase): # https://www.visitaruba.com/about-aruba/national-holidays-and-celebrations/ def __init__(self, **kwargs): - self.country = 'AW' + self.country = "AW" HolidayBase.__init__(self, **kwargs) def _populate(self, year): @@ -37,18 +36,24 @@ def _populate(self, year): self[date(year, JAN, 25)] = "Dia Di Betico [Betico Day]" # Carnaval Monday - self[easter(year) + rd(days=-48)] = "Dialuna di Carnaval \ + self[ + easter(year) + rd(days=-48) + ] = "Dialuna di Carnaval \ [Carnaval Monday]" # Dia di Himno y Bandera - self[date(year, MAR, 18)] = "Dia di Himno y Bandera \ + self[ + date(year, MAR, 18) + ] = "Dia di Himno y Bandera \ [National Anthem & Flag Day]" # Good Friday self[easter(year) + rd(weekday=FR(-1))] = "Bierna Santo [Good Friday]" # Easter Monday - self[easter(year) + rd(days=1)] = "Di Dos Dia di Pasco di Resureccion \ + self[ + easter(year) + rd(days=1) + ] = "Di Dos Dia di Pasco di Resureccion \ [Easter Monday]" # King's Day @@ -83,7 +88,9 @@ def _populate(self, year): self[date(year, DEC, 25)] = "Pasco di Nacemento [Christmas]" # Second Christmas - self[date(year, DEC, 26)] = "Di Dos Dia di Pasco di \ + self[ + date(year, DEC, 26) + ] = "Di Dos Dia di Pasco di \ Nacemento [Second Christmas]" diff --git a/holidays/countries/australia.py b/holidays/countries/australia.py index ee1d7be9a..057078d93 100644 --- a/holidays/countries/australia.py +++ b/holidays/countries/australia.py @@ -16,18 +16,17 @@ from dateutil.easter import easter from dateutil.relativedelta import relativedelta as rd, MO, SA, FR, WE, TU -from holidays.constants import JAN, MAR, APR, MAY, JUN, AUG, SEP, OCT, \ - NOV, DEC +from holidays.constants import JAN, MAR, APR, MAY, JUN, AUG, SEP, OCT, NOV, DEC from holidays.constants import SAT, SUN, WEEKEND from holidays.holiday_base import HolidayBase class Australia(HolidayBase): - PROVINCES = ['ACT', 'NSW', 'NT', 'QLD', 'SA', 'TAS', 'VIC', 'WA'] + PROVINCES = ["ACT", "NSW", "NT", "QLD", "SA", "TAS", "VIC", "WA"] def __init__(self, **kwargs): - self.country = 'AU' - self.prov = kwargs.pop('prov', None) + self.country = "AU" + self.prov = kwargs.pop("prov", None) HolidayBase.__init__(self, **kwargs) def _populate(self, year): @@ -52,19 +51,19 @@ def _populate(self, year): # Australia Day jan26 = date(year, JAN, 26) if year >= 1935: - if self.prov == 'NSW' and year < 1946: + if self.prov == "NSW" and year < 1946: name = "Anniversary Day" else: name = "Australia Day" self[jan26] = name if self.observed and year >= 1946 and jan26.weekday() in WEEKEND: self[jan26 + rd(weekday=MO)] = name + " (Observed)" - elif year >= 1888 and self.prov != 'SA': + elif year >= 1888 and self.prov != "SA": name = "Anniversary Day" self[jan26] = name # Adelaide Cup - if self.prov == 'SA': + if self.prov == "SA": name = "Adelaide Cup" if year >= 2006: # subject to proclamation ?!?! @@ -75,7 +74,7 @@ def _populate(self, year): # Canberra Day # Info from https://www.timeanddate.com/holidays/australia/canberra-day # and https://en.wikipedia.org/wiki/Canberra_Day - if self.prov == 'ACT' and year >= 1913: + if self.prov == "ACT" and year >= 1913: name = "Canberra Day" if year >= 1913 and year <= 1957: self[date(year, MAR, 12)] = name @@ -88,9 +87,9 @@ def _populate(self, year): # Easter self[easter(year) + rd(weekday=FR(-1))] = "Good Friday" - if self.prov in ('ACT', 'NSW', 'NT', 'QLD', 'SA', 'VIC'): + if self.prov in ("ACT", "NSW", "NT", "QLD", "SA", "VIC"): self[easter(year) + rd(weekday=SA(-1))] = "Easter Saturday" - if self.prov in ('ACT', 'NSW', 'QLD', 'VIC'): + if self.prov in ("ACT", "NSW", "QLD", "VIC"): self[easter(year)] = "Easter Sunday" self[easter(year) + rd(weekday=MO)] = "Easter Monday" @@ -100,14 +99,19 @@ def _populate(self, year): apr25 = date(year, APR, 25) self[apr25] = name if self.observed: - if apr25.weekday() == SAT and self.prov in ('WA', 'NT'): + if apr25.weekday() == SAT and self.prov in ("WA", "NT"): self[apr25 + rd(weekday=MO)] = name + " (Observed)" - elif (apr25.weekday() == SUN and - self.prov in ('ACT', 'QLD', 'SA', 'WA', 'NT')): + elif apr25.weekday() == SUN and self.prov in ( + "ACT", + "QLD", + "SA", + "WA", + "NT", + ): self[apr25 + rd(weekday=MO)] = name + " (Observed)" # Western Australia Day - if self.prov == 'WA' and year > 1832: + if self.prov == "WA" and year > 1832: if year >= 2015: name = "Western Australia Day" else: @@ -121,7 +125,7 @@ def _populate(self, year): name = "King's Birthday" if year >= 1936: name = "Queen's Birthday" - if self.prov == 'QLD': + if self.prov == "QLD": if year == 2012: self[date(year, JUN, 11)] = "Queen's Diamond Jubilee" if year < 2016 and year != 2012: @@ -130,10 +134,10 @@ def _populate(self, year): else: dt = date(year, OCT, 1) + rd(weekday=MO) self[dt] = name - elif self.prov == 'WA': + elif self.prov == "WA": # by proclamation ?!?! self[date(year, OCT, 1) + rd(weekday=MO(-1))] = name - elif self.prov in ('NSW', 'VIC', 'ACT', 'SA', 'NT', 'TAS'): + elif self.prov in ("NSW", "VIC", "ACT", "SA", "NT", "TAS"): dt = date(year, JUN, 1) + rd(weekday=MO(+2)) self[dt] = name elif year > 1911: @@ -142,38 +146,38 @@ def _populate(self, year): self[date(year, NOV, 9)] = name # Edward VII # Picnic Day - if self.prov == 'NT': + if self.prov == "NT": name = "Picnic Day" self[date(year, AUG, 1) + rd(weekday=MO)] = name # Bank Holiday - if self.prov == 'NSW': + if self.prov == "NSW": if year >= 1912: name = "Bank Holiday" self[date(year, 8, 1) + rd(weekday=MO)] = name # Labour Day name = "Labour Day" - if self.prov in ('NSW', 'ACT', 'SA'): + if self.prov in ("NSW", "ACT", "SA"): self[date(year, OCT, 1) + rd(weekday=MO)] = name - elif self.prov == 'WA': + elif self.prov == "WA": self[date(year, MAR, 1) + rd(weekday=MO)] = name - elif self.prov == 'VIC': + elif self.prov == "VIC": self[date(year, MAR, 1) + rd(weekday=MO(+2))] = name - elif self.prov == 'QLD': + elif self.prov == "QLD": if 2013 <= year <= 2015: self[date(year, OCT, 1) + rd(weekday=MO)] = name else: self[date(year, MAY, 1) + rd(weekday=MO)] = name - elif self.prov == 'NT': + elif self.prov == "NT": name = "May Day" self[date(year, MAY, 1) + rd(weekday=MO)] = name - elif self.prov == 'TAS': + elif self.prov == "TAS": name = "Eight Hours Day" self[date(year, MAR, 1) + rd(weekday=MO(+2))] = name # Family & Community Day - if self.prov == 'ACT': + if self.prov == "ACT": name = "Family & Community Day" if 2007 <= year <= 2009: self[date(year, NOV, 1) + rd(weekday=TU)] = name @@ -199,12 +203,12 @@ def _populate(self, year): self[date(year, SEP, 25)] = name # Reconciliation Day - if self.prov == 'ACT': + if self.prov == "ACT": name = "Reconciliation Day" if year >= 2018: self[date(year, 5, 27) + rd(weekday=MO)] = name - if self.prov == 'VIC': + if self.prov == "VIC": # Grand Final Day if year == 2020: # Rescheduled due to COVID-19 @@ -219,13 +223,14 @@ def _populate(self, year): # The Show starts on the first Friday of August - providing this is # not prior to the 5th - in which case it will begin on the second # Friday. The Wednesday during the show is a public holiday. - if self.prov == 'QLD': + if self.prov == "QLD": name = "The Royal Queensland Show" if year == 2020: self[date(year, AUG, 14)] = name else: - self[date(year, AUG, 5) + rd(weekday=FR) + rd(weekday=WE)] = \ - name + self[ + date(year, AUG, 5) + rd(weekday=FR) + rd(weekday=WE) + ] = name # Christmas Day name = "Christmas Day" @@ -235,7 +240,7 @@ def _populate(self, year): self[date(year, DEC, 27)] = name + " (Observed)" # Boxing Day - if self.prov == 'SA': + if self.prov == "SA": name = "Proclamation Day" else: name = "Boxing Day" diff --git a/holidays/countries/austria.py b/holidays/countries/austria.py index ca36e2671..6e62bdfeb 100644 --- a/holidays/countries/austria.py +++ b/holidays/countries/austria.py @@ -16,17 +16,16 @@ from dateutil.easter import easter from dateutil.relativedelta import relativedelta as rd, MO -from holidays.constants import JAN, MAY, AUG, OCT, \ - NOV, DEC +from holidays.constants import JAN, MAY, AUG, OCT, NOV, DEC from holidays.holiday_base import HolidayBase class Austria(HolidayBase): - PROVINCES = ['1', '2', '3', '4', '5', '6', '7', '8', '9'] + PROVINCES = ["1", "2", "3", "4", "5", "6", "7", "8", "9"] def __init__(self, **kwargs): - self.country = 'AT' - self.prov = kwargs.pop('prov', kwargs.pop('state', '9')) + self.country = "AT" + self.prov = kwargs.pop("prov", kwargs.pop("state", "9")) HolidayBase.__init__(self, **kwargs) def _populate(self, year): diff --git a/holidays/countries/bangladesh.py b/holidays/countries/bangladesh.py index 81e18151d..a25a1b590 100644 --- a/holidays/countries/bangladesh.py +++ b/holidays/countries/bangladesh.py @@ -22,7 +22,7 @@ class Bangladesh(HolidayBase): # https://en.wikipedia.org/wiki/Public_holidays_in_Bangladesh def __init__(self, **kwargs): - self.country = 'TR' + self.country = "TR" HolidayBase.__init__(self, **kwargs) def _populate(self, year): @@ -31,8 +31,9 @@ def _populate(self, year): self[date(year, FEB, 21)] = "International Mother's language Day" # 17th March - self[date(year, MAR, 17)] = "Sheikh Mujibur Rahman's Birthday " \ - "and Children's Day" + self[date(year, MAR, 17)] = ( + "Sheikh Mujibur Rahman's Birthday " "and Children's Day" + ) # 26th March self[date(year, MAR, 26)] = "Independence Day" diff --git a/holidays/countries/belarus.py b/holidays/countries/belarus.py index 8efa668d6..6717a2436 100644 --- a/holidays/countries/belarus.py +++ b/holidays/countries/belarus.py @@ -46,8 +46,9 @@ def _populate(self, year): self[date(year, JAN, 2)] = "Новый год" # Christmas Day (Orthodox) - self[date(year, JAN, 7)] = "Рождество Христово " \ - "(православное Рождество)" + self[date(year, JAN, 7)] = ( + "Рождество Христово " "(православное Рождество)" + ) # Women's Day self[date(year, MAR, 8)] = "День женщин" @@ -62,15 +63,17 @@ def _populate(self, year): self[date(year, MAY, 9)] = "День Победы" # Independence Day - self[date(year, JUL, 3)] = "День Независимости Республики Беларусь " \ - "(День Республики)" + self[date(year, JUL, 3)] = ( + "День Независимости Республики Беларусь " "(День Республики)" + ) # October Revolution Day self[date(year, NOV, 7)] = "День Октябрьской революции" # Christmas Day (Catholic) - self[date(year, DEC, 25)] = "Рождество Христово " \ - "(католическое Рождество)" + self[date(year, DEC, 25)] = ( + "Рождество Христово " "(католическое Рождество)" + ) class BY(Belarus): diff --git a/holidays/countries/brazil.py b/holidays/countries/brazil.py index ee3efd9f4..eee9d1ab7 100644 --- a/holidays/countries/brazil.py +++ b/holidays/countries/brazil.py @@ -16,8 +16,19 @@ from dateutil.easter import easter from dateutil.relativedelta import relativedelta as rd, TU -from holidays.constants import JAN, MAR, APR, MAY, JUN, JUL, AUG, SEP, OCT, \ - NOV, DEC +from holidays.constants import ( + JAN, + MAR, + APR, + MAY, + JUN, + JUL, + AUG, + SEP, + OCT, + NOV, + DEC, +) from holidays.holiday_base import HolidayBase @@ -26,12 +37,38 @@ class Brazil(HolidayBase): https://pt.wikipedia.org/wiki/Feriados_no_Brasil """ - STATES = ['AC', 'AL', 'AP', 'AM', 'BA', 'CE', 'DF', 'ES', 'GO', 'MA', 'MT', - 'MS', 'MG', 'PA', 'PB', 'PE', 'PI', 'PR', 'RJ', 'RN', 'RS', 'RO', - 'RR', 'SC', 'SP', 'SE', 'TO'] + STATES = [ + "AC", + "AL", + "AP", + "AM", + "BA", + "CE", + "DF", + "ES", + "GO", + "MA", + "MT", + "MS", + "MG", + "PA", + "PB", + "PE", + "PI", + "PR", + "RJ", + "RN", + "RS", + "RO", + "RR", + "SC", + "SP", + "SE", + "TO", + ] def __init__(self, **kwargs): - self.country = 'BR' + self.country = "BR" HolidayBase.__init__(self, **kwargs) def _populate(self, year): @@ -64,110 +101,115 @@ def _populate(self, year): self[quaresma - rd(weekday=TU(-1))] = "Carnaval" - if self.state == 'AC': + if self.state == "AC": self[date(year, JAN, 23)] = "Dia do evangélico" self[date(year, JUN, 15)] = "Aniversário do Acre" self[date(year, SEP, 5)] = "Dia da Amazônia" - self[date(year, NOV, 17)] = "Assinatura do Tratado de" \ - " Petrópolis" + self[date(year, NOV, 17)] = ( + "Assinatura do Tratado de" " Petrópolis" + ) - if self.state == 'AL': + if self.state == "AL": self[date(year, JUN, 24)] = "São João" self[date(year, JUN, 29)] = "São Pedro" self[date(year, SEP, 16)] = "Emancipação política de Alagoas" self[date(year, NOV, 20)] = "Consciência Negra" - if self.state == 'AP': + if self.state == "AP": self[date(year, MAR, 19)] = "Dia de São José" self[date(year, JUL, 25)] = "São Tiago" self[date(year, OCT, 5)] = "Criação do estado" self[date(year, NOV, 20)] = "Consciência Negra" - if self.state == 'AM': - self[date(year, SEP, 5)] = "Elevação do Amazonas" \ - " à categoria de província" + if self.state == "AM": + self[date(year, SEP, 5)] = ( + "Elevação do Amazonas" " à categoria de província" + ) self[date(year, NOV, 20)] = "Consciência Negra" self[date(year, DEC, 8)] = "Dia de Nossa Senhora da Conceição" - if self.state == 'BA': + if self.state == "BA": self[date(year, JUL, 2)] = "Independência da Bahia" - if self.state == 'CE': + if self.state == "CE": self[date(year, MAR, 19)] = "São José" self[date(year, MAR, 25)] = "Data Magna do Ceará" - if self.state == 'DF': + if self.state == "DF": self[date(year, APR, 21)] = "Fundação de Brasília" self[date(year, NOV, 30)] = "Dia do Evangélico" - if self.state == 'ES': + if self.state == "ES": self[date(year, OCT, 28)] = "Dia do Servidor Público" - if self.state == 'GO': + if self.state == "GO": self[date(year, OCT, 28)] = "Dia do Servidor Público" - if self.state == 'MA': - self[date(year, JUL, 28)] = "Adesão do Maranhão" \ - " à independência do Brasil" + if self.state == "MA": + self[date(year, JUL, 28)] = ( + "Adesão do Maranhão" " à independência do Brasil" + ) self[date(year, DEC, 8)] = "Dia de Nossa Senhora da Conceição" - if self.state == 'MT': + if self.state == "MT": self[date(year, NOV, 20)] = "Consciência Negra" - if self.state == 'MS': + if self.state == "MS": self[date(year, OCT, 11)] = "Criação do estado" - if self.state == 'MG': + if self.state == "MG": self[date(year, APR, 21)] = "Data Magna de MG" - if self.state == 'PA': - self[date(year, AUG, 15)] = "Adesão do Grão-Pará" \ - " à independência do Brasil" + if self.state == "PA": + self[date(year, AUG, 15)] = ( + "Adesão do Grão-Pará" " à independência do Brasil" + ) - if self.state == 'PB': + if self.state == "PB": self[date(year, AUG, 5)] = "Fundação do Estado" - if self.state == 'PE': + if self.state == "PE": self[date(year, MAR, 6)] = "Revolução Pernambucana (Data Magna)" self[date(year, JUN, 24)] = "São João" - if self.state == 'PI': + if self.state == "PI": self[date(year, MAR, 13)] = "Dia da Batalha do Jenipapo" self[date(year, OCT, 19)] = "Dia do Piauí" - if self.state == 'PR': + if self.state == "PR": self[date(year, DEC, 19)] = "Emancipação do Paraná" - if self.state == 'RJ': + if self.state == "RJ": self[date(year, APR, 23)] = "Dia de São Jorge" self[date(year, OCT, 28)] = "Dia do Funcionário Público" self[date(year, NOV, 20)] = "Zumbi dos Palmares" - if self.state == 'RN': + if self.state == "RN": self[date(year, JUN, 29)] = "Dia de São Pedro" self[date(year, OCT, 3)] = "Mártires de Cunhaú e Uruaçuu" - if self.state == 'RS': + if self.state == "RS": self[date(year, SEP, 20)] = "Revolução Farroupilha" - if self.state == 'RO': + if self.state == "RO": self[date(year, JAN, 4)] = "Criação do estado" self[date(year, JUN, 18)] = "Dia do Evangélico" - if self.state == 'RR': + if self.state == "RR": self[date(year, OCT, 5)] = "Criação de Roraima" - if self.state == 'SC': - self[date(year, AUG, 11)] = "Criação da capitania," \ - " separando-se de SP" + if self.state == "SC": + self[date(year, AUG, 11)] = ( + "Criação da capitania," " separando-se de SP" + ) - if self.state == 'SP': + if self.state == "SP": self[date(year, JUL, 9)] = "Revolução Constitucionalista de 1932" - if self.state == 'SE': + if self.state == "SE": self[date(year, JUL, 8)] = "Autonomia política de Sergipe" - if self.state == 'TO': + if self.state == "TO": self[date(year, JAN, 1)] = "Instalação de Tocantins" self[date(year, SEP, 8)] = "Nossa Senhora da Natividade" self[date(year, OCT, 5)] = "Criação de Tocantins" diff --git a/holidays/countries/bulgaria.py b/holidays/countries/bulgaria.py index 7019dec37..552cbfdd9 100644 --- a/holidays/countries/bulgaria.py +++ b/holidays/countries/bulgaria.py @@ -41,7 +41,7 @@ class Bulgaria(HolidayBase): """ def __init__(self, **kwargs): - self.country = 'BG' + self.country = "BG" HolidayBase.__init__(self, **kwargs) def _populate(self, year): @@ -52,20 +52,24 @@ def _populate(self, year): self[date(year, JAN, 1)] = "Нова година" # Liberation Day - self[date(year, MAR, 3)] = \ - "Ден на Освобождението на България от османско иго" + self[ + date(year, MAR, 3) + ] = "Ден на Освобождението на България от османско иго" # International Workers' Day - self[date(year, MAY, 1)] = \ - "Ден на труда и на международната работническа солидарност" + self[ + date(year, MAY, 1) + ] = "Ден на труда и на международната работническа солидарност" # Saint George's Day - self[date(year, MAY, 6)] = \ - "Гергьовден, Ден на храбростта и Българската армия" + self[ + date(year, MAY, 6) + ] = "Гергьовден, Ден на храбростта и Българската армия" # Bulgarian Education and Culture and Slavonic Literature Day - self[date(year, MAY, 24)] = \ - "Ден на българската просвета и култура и на славянската писменост" + self[ + date(year, MAY, 24) + ] = "Ден на българската просвета и култура и на славянската писменост" # Unification Day self[date(year, SEP, 6)] = "Ден на Съединението" @@ -82,10 +86,12 @@ def _populate(self, year): self[date(year, DEC, 26)] = "Рождество Христово" # Easter - self[easter(year, method=EASTER_ORTHODOX) - rd(days=2)] = \ - "Велики петък" - self[easter(year, method=EASTER_ORTHODOX) - rd(days=1)] = \ - "Велика събота" + self[ + easter(year, method=EASTER_ORTHODOX) - rd(days=2) + ] = "Велики петък" + self[ + easter(year, method=EASTER_ORTHODOX) - rd(days=1) + ] = "Велика събота" self[easter(year, method=EASTER_ORTHODOX)] = "Великден" diff --git a/holidays/countries/burundi.py b/holidays/countries/burundi.py index 9e71e74f8..f96923e35 100644 --- a/holidays/countries/burundi.py +++ b/holidays/countries/burundi.py @@ -34,7 +34,7 @@ class Burundi(HolidayBase): """ def __init__(self, **kwargs): - self.country = 'BI' + self.country = "BI" HolidayBase.__init__(self, **kwargs) def _populate(self, year): @@ -78,7 +78,7 @@ def _populate(self, year): self[hol_date + rd(days=1)] = "Eid Al Adha" # Assumption Day - name = 'Assumption Day' + name = "Assumption Day" self[date(year, AUG, 15)] = name # Prince Louis Rwagasore Day diff --git a/holidays/countries/canada.py b/holidays/countries/canada.py index fdc64465f..f4e6fa138 100644 --- a/holidays/countries/canada.py +++ b/holidays/countries/canada.py @@ -17,19 +17,43 @@ from dateutil.relativedelta import relativedelta as rd, MO, SU, FR from holidays.constants import FRI, SAT, SUN, WEEKEND -from holidays.constants import JAN, FEB, MAR, APR, MAY, JUN, JUL, AUG, SEP, \ - OCT, \ - NOV, DEC +from holidays.constants import ( + JAN, + FEB, + MAR, + APR, + MAY, + JUN, + JUL, + AUG, + SEP, + OCT, + NOV, + DEC, +) from holidays.holiday_base import HolidayBase class Canada(HolidayBase): - PROVINCES = ['AB', 'BC', 'MB', 'NB', 'NL', 'NS', 'NT', 'NU', 'ON', 'PE', - 'QC', 'SK', 'YT'] + PROVINCES = [ + "AB", + "BC", + "MB", + "NB", + "NL", + "NS", + "NT", + "NU", + "ON", + "PE", + "QC", + "SK", + "YT", + ] def __init__(self, **kwargs): - self.country = 'CA' - self.prov = kwargs.pop('prov', 'ON') + self.country = "CA" + self.prov = kwargs.pop("prov", "ON") HolidayBase.__init__(self, **kwargs) def _populate(self, year): @@ -38,16 +62,13 @@ def _populate(self, year): name = "New Year's Day" self[date(year, JAN, 1)] = name if self.observed and date(year, JAN, 1).weekday() == SUN: - self[date(year, JAN, 1) + rd(days=+1)] = name + \ - " (Observed)" - elif self.observed \ - and date(year, JAN, 1).weekday() == SAT: + self[date(year, JAN, 1) + rd(days=+1)] = name + " (Observed)" + elif self.observed and date(year, JAN, 1).weekday() == SAT: # Add Dec 31st from the previous year without triggering # the entire year to be added expand = self.expand self.expand = False - self[date(year, JAN, 1) + rd(days=-1)] = name + \ - " (Observed)" + self[date(year, JAN, 1) + rd(days=-1)] = name + " (Observed)" self.expand = expand # The next year's observed New Year's Day can be in this year # when it falls on a Friday (Jan 1st is a Saturday) @@ -56,32 +77,29 @@ def _populate(self, year): # Family Day / Louis Riel Day (MB) / Islander Day (PE) # / Heritage Day (NS, YT) - if self.prov in ('AB', 'SK', 'ON') and year >= 2008: + if self.prov in ("AB", "SK", "ON") and year >= 2008: self[date(year, FEB, 1) + rd(weekday=MO(+3))] = "Family Day" - elif self.prov in ('AB', 'SK') and year >= 2007: + elif self.prov in ("AB", "SK") and year >= 2007: self[date(year, FEB, 1) + rd(weekday=MO(+3))] = "Family Day" - elif self.prov == 'AB' and year >= 1990: + elif self.prov == "AB" and year >= 1990: self[date(year, FEB, 1) + rd(weekday=MO(+3))] = "Family Day" - elif self.prov == 'NB' and year >= 2018: + elif self.prov == "NB" and year >= 2018: self[date(year, FEB, 1) + rd(weekday=MO(+3))] = "Family Day" - elif self.prov == 'BC': + elif self.prov == "BC": if year >= 2013 and year <= 2018: - self[date(year, FEB, 1) + rd(weekday=MO(+2))] = \ - "Family Day" + self[date(year, FEB, 1) + rd(weekday=MO(+2))] = "Family Day" elif year > 2018: - self[date(year, FEB, 1) + rd(weekday=MO(+3))] = \ - "Family Day" - elif self.prov == 'MB' and year >= 2008: - self[date(year, FEB, 1) + rd(weekday=MO(+3))] = \ - "Louis Riel Day" - elif self.prov == 'PE' and year >= 2010: + self[date(year, FEB, 1) + rd(weekday=MO(+3))] = "Family Day" + elif self.prov == "MB" and year >= 2008: + self[date(year, FEB, 1) + rd(weekday=MO(+3))] = "Louis Riel Day" + elif self.prov == "PE" and year >= 2010: self[date(year, FEB, 1) + rd(weekday=MO(+3))] = "Islander Day" - elif self.prov == 'PE' and year == 2009: + elif self.prov == "PE" and year == 2009: self[date(year, FEB, 1) + rd(weekday=MO(+2))] = "Islander Day" - elif self.prov == 'NS' and year >= 2015: + elif self.prov == "NS" and year >= 2015: # http://novascotia.ca/lae/employmentrights/NovaScotiaHeritageDay.asp self[date(year, FEB, 1) + rd(weekday=MO(+3))] = "Heritage Day" - elif self.prov == 'YT': + elif self.prov == "YT": # start date? # http://heritageyukon.ca/programs/heritage-day # https://en.wikipedia.org/wiki/Family_Day_(Canada)#Yukon_Heritage_Day @@ -90,7 +108,7 @@ def _populate(self, year): self[dt] = "Heritage Day" # St. Patrick's Day - if self.prov == 'NL' and year >= 1900: + if self.prov == "NL" and year >= 1900: dt = date(year, MAR, 17) # Nearest Monday to March 17 dt1 = date(year, MAR, 17) + rd(weekday=MO(-1)) @@ -101,19 +119,19 @@ def _populate(self, year): self[dt1] = "St. Patrick's Day" # Good Friday - if self.prov != 'QC' and year >= 1867: + if self.prov != "QC" and year >= 1867: self[easter(year) + rd(weekday=FR(-1))] = "Good Friday" # Easter Monday - if self.prov == 'QC' and year >= 1867: + if self.prov == "QC" and year >= 1867: self[easter(year) + rd(weekday=MO)] = "Easter Monday" # St. George's Day - if self.prov == 'NL' and year == 2010: + if self.prov == "NL" and year == 2010: # 4/26 is the Monday closer to 4/23 in 2010 # but the holiday was observed on 4/19? Crazy Newfies! self[date(2010, 4, 19)] = "St. George's Day" - elif self.prov == 'NL' and year >= 1990: + elif self.prov == "NL" and year >= 1990: dt = date(year, APR, 23) # Nearest Monday to April 23 dt1 = dt + rd(weekday=MO(-1)) @@ -124,24 +142,24 @@ def _populate(self, year): self[dt1] = "St. George's Day" # Victoria Day / National Patriots' Day (QC) - if self.prov not in ('NB', 'NS', 'PE', 'NL', 'QC') and year >= 1953: + if self.prov not in ("NB", "NS", "PE", "NL", "QC") and year >= 1953: self[date(year, MAY, 24) + rd(weekday=MO(-1))] = "Victoria Day" - elif self.prov == 'QC' and year >= 1953: + elif self.prov == "QC" and year >= 1953: name = "National Patriots' Day" self[date(year, MAY, 24) + rd(weekday=MO(-1))] = name # National Aboriginal Day - if self.prov == 'NT' and year >= 1996: + if self.prov == "NT" and year >= 1996: self[date(year, JUN, 21)] = "National Aboriginal Day" # St. Jean Baptiste Day - if self.prov == 'QC' and year >= 1925: + if self.prov == "QC" and year >= 1925: self[date(year, JUN, 24)] = "St. Jean Baptiste Day" if self.observed and date(year, JUN, 24).weekday() == SUN: self[date(year, JUN, 25)] = "St. Jean Baptiste Day (Observed)" # Discovery Day - if self.prov == 'NL' and year >= 1997: + if self.prov == "NL" and year >= 1997: dt = date(year, JUN, 24) # Nearest Monday to June 24 dt1 = dt + rd(weekday=MO(-1)) @@ -150,53 +168,60 @@ def _populate(self, year): self[dt2] = "Discovery Day" else: self[dt1] = "Discovery Day" - elif self.prov == 'YT' and year >= 1912: + elif self.prov == "YT" and year >= 1912: self[date(year, AUG, 1) + rd(weekday=MO(+3))] = "Discovery Day" # Canada Day / Memorial Day (NL) - if self.prov != 'NL' and year >= 1867: + if self.prov != "NL" and year >= 1867: if year >= 1983: name = "Canada Day" else: name = "Dominion Day" self[date(year, JUL, 1)] = name - if year >= 1879 and self.observed \ - and date(year, JUL, 1).weekday() in WEEKEND: - self[date(year, JUL, 1) + rd(weekday=MO)] = name + \ - " (Observed)" + if ( + year >= 1879 + and self.observed + and date(year, JUL, 1).weekday() in WEEKEND + ): + self[date(year, JUL, 1) + rd(weekday=MO)] = ( + name + " (Observed)" + ) elif year >= 1867: if year >= 1983: name = "Memorial Day" else: name = "Dominion Day" self[date(year, JUL, 1)] = name - if year >= 1879 and self.observed \ - and date(year, JUL, 1).weekday() in WEEKEND: - self[date(year, JUL, 1) + rd(weekday=MO)] = name + \ - " (Observed)" + if ( + year >= 1879 + and self.observed + and date(year, JUL, 1).weekday() in WEEKEND + ): + self[date(year, JUL, 1) + rd(weekday=MO)] = ( + name + " (Observed)" + ) # Nunavut Day - if self.prov == 'NU' and year >= 2001: + if self.prov == "NU" and year >= 2001: self[date(year, JUL, 9)] = "Nunavut Day" if self.observed and date(year, JUL, 9).weekday() == SUN: self[date(year, JUL, 10)] = "Nunavut Day (Observed)" - elif self.prov == 'NU' and year == 2000: + elif self.prov == "NU" and year == 2000: self[date(2000, 4, 1)] = "Nunavut Day" # Civic Holiday - if self.prov in ('ON', 'MB', 'NT') and year >= 1900: + if self.prov in ("ON", "MB", "NT") and year >= 1900: self[date(year, AUG, 1) + rd(weekday=MO)] = "Civic Holiday" - elif self.prov == 'AB' and year >= 1974: + elif self.prov == "AB" and year >= 1974: # https://en.wikipedia.org/wiki/Civic_Holiday#Alberta self[date(year, AUG, 1) + rd(weekday=MO)] = "Heritage Day" - elif self.prov == 'BC' and year >= 1974: + elif self.prov == "BC" and year >= 1974: # https://en.wikipedia.org/wiki/Civic_Holiday - self[date(year, AUG, 1) + rd(weekday=MO)] = \ - "British Columbia Day" - elif self.prov == 'NB' and year >= 1900: + self[date(year, AUG, 1) + rd(weekday=MO)] = "British Columbia Day" + elif self.prov == "NB" and year >= 1900: # https://en.wikipedia.org/wiki/Civic_Holiday self[date(year, AUG, 1) + rd(weekday=MO)] = "New Brunswick Day" - elif self.prov == 'SK' and year >= 1900: + elif self.prov == "SK" and year >= 1900: # https://en.wikipedia.org/wiki/Civic_Holiday self[date(year, AUG, 1) + rd(weekday=MO)] = "Saskatchewan Day" @@ -205,22 +230,21 @@ def _populate(self, year): self[date(year, SEP, 1) + rd(weekday=MO)] = "Labour Day" # Thanksgiving - if self.prov not in ('NB', 'NS', 'PE', 'NL') and year >= 1931: + if self.prov not in ("NB", "NS", "PE", "NL") and year >= 1931: if year == 1935: # in 1935, Canadian Thanksgiving was moved due to the General # Election falling on the second Monday of October # https://books.google.ca/books?id=KcwlQsmheG4C&pg=RA1-PA1940&lpg=RA1-PA1940&dq=canada+thanksgiving+1935&source=bl&ots=j4qYrcfGuY&sig=gxXeAQfXVsOF9fOwjSMswPHJPpM&hl=en&sa=X&ved=0ahUKEwjO0f3J2PjOAhVS4mMKHRzKBLAQ6AEIRDAG#v=onepage&q=canada%20thanksgiving%201935&f=false self[date(1935, 10, 25)] = "Thanksgiving" else: - self[date(year, OCT, 1) + rd(weekday=MO(+2))] = \ - "Thanksgiving" + self[date(year, OCT, 1) + rd(weekday=MO(+2))] = "Thanksgiving" # Remembrance Day name = "Remembrance Day" - provinces = ('ON', 'QC', 'NS', 'NL', 'NT', 'PE', 'SK') + provinces = ("ON", "QC", "NS", "NL", "NT", "PE", "SK") if self.prov not in provinces and year >= 1931: self[date(year, NOV, 11)] = name - elif self.prov in ('NS', 'NL', 'NT', 'PE', 'SK') and year >= 1931: + elif self.prov in ("NS", "NL", "NT", "PE", "SK") and year >= 1931: self[date(year, NOV, 11)] = name if self.observed and date(year, NOV, 11).weekday() == SUN: name = name + " (Observed)" @@ -229,11 +253,9 @@ def _populate(self, year): # Christmas Day if year >= 1867: self[date(year, DEC, 25)] = "Christmas Day" - if self.observed \ - and date(year, DEC, 25).weekday() == SAT: + if self.observed and date(year, DEC, 25).weekday() == SAT: self[date(year, DEC, 24)] = "Christmas Day (Observed)" - elif self.observed \ - and date(year, DEC, 25).weekday() == SUN: + elif self.observed and date(year, DEC, 25).weekday() == SUN: self[date(year, DEC, 26)] = "Christmas Day (Observed)" # Boxing Day diff --git a/holidays/countries/chile.py b/holidays/countries/chile.py index 8ae80ce19..ebc198cc7 100644 --- a/holidays/countries/chile.py +++ b/holidays/countries/chile.py @@ -16,8 +16,7 @@ from dateutil.easter import easter from dateutil.relativedelta import relativedelta as rd, MO, FR, SA -from holidays.constants import JAN, MAY, JUN, JUL, AUG, SEP, OCT, \ - NOV, DEC +from holidays.constants import JAN, MAY, JUN, JUL, AUG, SEP, OCT, NOV, DEC from holidays.constants import TUE, THU, FRI, SAT, SUN from holidays.holiday_base import HolidayBase @@ -28,11 +27,27 @@ class Chile(HolidayBase): # https://es.wikipedia.org/wiki/Anexo:D%C3%ADas_feriados_en_Chile # ISO 3166-2 codes for the principal subdivisions, called regions - STATES = ['AI', 'AN', 'AP', 'AR', 'AT', 'BI', 'CO', 'LI', 'LL', 'LR', - 'MA', 'ML', 'NB', 'RM', 'TA', 'VS'] + STATES = [ + "AI", + "AN", + "AP", + "AR", + "AT", + "BI", + "CO", + "LI", + "LL", + "LR", + "MA", + "ML", + "NB", + "RM", + "TA", + "VS", + ] def __init__(self, **kwargs): - self.country = 'CL' + self.country = "CL" HolidayBase.__init__(self, **kwargs) def _populate(self, year): @@ -45,7 +60,7 @@ def _populate(self, year): # Holy Week (Law 2.977) name_fri = "Semana Santa (Viernes Santo) [Good Friday)]" name_sat = "Semana Santa (Sábado Santo) [Good Saturday)]" - name_easter = 'Día de Pascuas [Easter Day]' + name_easter = "Día de Pascuas [Easter Day]" self[easter(year) + rd(weekday=FR(-1))] = name_fri self[easter(year) + rd(weekday=SA(-1))] = name_sat @@ -66,8 +81,10 @@ def _populate(self, year): else: # floating Monday holiday (Law 19.668) if date(year, JUN, 29).weekday() <= THU: - self[date(year, JUN, 29) + rd(date(year, JUN, 29), - weekday=MO(-1))] = name + self[ + date(year, JUN, 29) + + rd(date(year, JUN, 29), weekday=MO(-1)) + ] = name elif date(year, JUN, 29).weekday() == FRI: self[date(year, JUN, 29) + rd(weekday=MO)] = name else: @@ -106,15 +123,19 @@ def _populate(self, year): if year < 2010: self[date(year, OCT, 12)] = "Día de la Raza [Columbus day]" elif year < 2020: - self[date(year, OCT, 12)] = "Día del Respeto a la Diversidad"\ - " [Day of the Meeting " \ - " of Two Worlds]" + self[date(year, OCT, 12)] = ( + "Día del Respeto a la Diversidad" + " [Day of the Meeting " + " of Two Worlds]" + ) else: # floating Monday holiday (Law 19.668) - name = ("Día del Descubrimiento de dos Mundos [Columbus Day]") + name = "Día del Descubrimiento de dos Mundos [Columbus Day]" if date(year, OCT, 12).weekday() <= THU: - self[date(year, OCT, 12) + rd(date(year, OCT, 12), - weekday=MO(-1))] = name + self[ + date(year, OCT, 12) + + rd(date(year, OCT, 12), weekday=MO(-1)) + ] = name elif date(year, OCT, 12).weekday() == FRI: self[date(year, OCT, 12) + rd(weekday=MO)] = name else: @@ -122,8 +143,10 @@ def _populate(self, year): # National Day of the Evangelical and Protestant Churches (Law 20.299) if year > 2007: - name = ("Día Nacional de las Iglesias Evangélicas y Protestantes " - " [Reformation Day]") + name = ( + "Día Nacional de las Iglesias Evangélicas y Protestantes " + " [Reformation Day]" + ) self[date(year, OCT, 31)] = name # All Saints Day (Law 2.977) @@ -131,25 +154,29 @@ def _populate(self, year): self[date(year, NOV, 1)] = name # Immaculate Conception (Law 2.977) - self[date(year, DEC, 8)] = "La Inmaculada Concepción" \ - " [Immaculate Conception]" + self[date(year, DEC, 8)] = ( + "La Inmaculada Concepción" " [Immaculate Conception]" + ) # Christmas (Law 2.977) self[date(year, DEC, 25)] = "Navidad [Christmas]" # región de Arica y Parinacota - if self.state == 'AP' and year >= 2020: + if self.state == "AP" and year >= 2020: # Law 20.663 - self[date(year, JUN, 7)] = ("Asalto y Toma del Morro de Arica" - " [Assault and Capture of Cape Arica]") + self[date(year, JUN, 7)] = ( + "Asalto y Toma del Morro de Arica" + " [Assault and Capture of Cape Arica]" + ) # región de Ñuble - if self.state == 'NB' and year >= 2014: + if self.state == "NB" and year >= 2014: # Law 20.678 - self[date(year, AUG, 20)] =\ - ("Nacimiento del Prócer de la Independencia" - " (Chillán y Chillán Viejo)" - " [Nativity of Bernardo O'Higgins]") + self[date(year, AUG, 20)] = ( + "Nacimiento del Prócer de la Independencia" + " (Chillán y Chillán Viejo)" + " [Nativity of Bernardo O'Higgins]" + ) class CL(Chile): diff --git a/holidays/countries/colombia.py b/holidays/countries/colombia.py index 5fb464949..cc0589dad 100644 --- a/holidays/countries/colombia.py +++ b/holidays/countries/colombia.py @@ -16,8 +16,7 @@ from dateutil.easter import easter from dateutil.relativedelta import relativedelta as rd, MO, TH, FR -from holidays.constants import JAN, MAR, MAY, JUN, JUL, AUG, OCT, \ - NOV, DEC +from holidays.constants import JAN, MAR, MAY, JUN, JUL, AUG, OCT, NOV, DEC from holidays.constants import MON, WEEKEND from holidays.holiday_base import HolidayBase @@ -26,7 +25,7 @@ class Colombia(HolidayBase): # https://es.wikipedia.org/wiki/Anexo:D%C3%ADas_festivos_en_Colombia def __init__(self, **kwargs): - self.country = 'CO' + self.country = "CO" HolidayBase.__init__(self, **kwargs) def _populate(self, year): @@ -58,8 +57,9 @@ def _populate(self, year): if self.observed and date(year, DEC, 8).weekday() in WEEKEND: pass else: - self[date(year, DEC, 8)] = "La Inmaculada Concepción" \ - " [Immaculate Conception]" + self[date(year, DEC, 8)] = ( + "La Inmaculada Concepción" " [Immaculate Conception]" + ) # Christmas self[date(year, DEC, 25)] = "Navidad [Christmas]" @@ -100,34 +100,31 @@ def _populate(self, year): if date(year, OCT, 12).weekday() == MON or not self.observed: self[date(year, OCT, 12)] = name else: - self[date(year, OCT, 12) + rd(weekday=MO)] = name + \ - "(Observed)" + self[date(year, OCT, 12) + rd(weekday=MO)] = name + "(Observed)" # All Saints’ Day name = "Dia de Todos los Santos [All Saint's Day]" if date(year, NOV, 1).weekday() == MON or not self.observed: self[date(year, NOV, 1)] = name else: - self[date(year, NOV, 1) + rd(weekday=MO)] = name + \ - "(Observed)" + self[date(year, NOV, 1) + rd(weekday=MO)] = name + "(Observed)" # Independence of Cartagena name = "Independencia de Cartagena [Independence of Cartagena]" if date(year, NOV, 11).weekday() == MON or not self.observed: self[date(year, NOV, 11)] = name else: - self[date(year, NOV, 11) + rd(weekday=MO)] = name + \ - "(Observed)" + self[date(year, NOV, 11) + rd(weekday=MO)] = name + "(Observed)" # Holidays based on Easter # Maundy Thursday - self[easter(year) + rd(weekday=TH(-1)) - ] = "Jueves Santo [Maundy Thursday]" + self[ + easter(year) + rd(weekday=TH(-1)) + ] = "Jueves Santo [Maundy Thursday]" # Good Friday - self[easter(year) + rd(weekday=FR(-1)) - ] = "Viernes Santo [Good Friday]" + self[easter(year) + rd(weekday=FR(-1))] = "Viernes Santo [Good Friday]" # Holidays based on Easter but are observed the following monday # (unless they occur on a monday) diff --git a/holidays/countries/czechia.py b/holidays/countries/czechia.py index bdd47ae97..5ebaea424 100644 --- a/holidays/countries/czechia.py +++ b/holidays/countries/czechia.py @@ -17,8 +17,7 @@ from dateutil.easter import easter from dateutil.relativedelta import relativedelta as rd -from holidays.constants import JAN, MAY, JUL, SEP, OCT, \ - NOV, DEC +from holidays.constants import JAN, MAY, JUL, SEP, OCT, NOV, DEC from holidays.holiday_base import HolidayBase @@ -26,14 +25,15 @@ class Czechia(HolidayBase): # https://en.wikipedia.org/wiki/Public_holidays_in_the_Czech_Republic def __init__(self, **kwargs): - self.country = 'CZ' + self.country = "CZ" HolidayBase.__init__(self, **kwargs) def _populate(self, year): - self[date(year, JAN, 1)] = "Den obnovy samostatného českého" \ - " státu" \ - if year >= 2000 else \ - "Nový rok" + self[date(year, JAN, 1)] = ( + "Den obnovy samostatného českého" " státu" + if year >= 2000 + else "Nový rok" + ) e = easter(year) if year <= 1951 or year >= 2016: @@ -45,17 +45,20 @@ def _populate(self, year): if year >= 1992: self[date(year, MAY, 8)] = "Den vítězství" elif year >= 1947: - self[date(year, MAY, 9)] = "Den vítězství nad hitlerovským" \ - " fašismem" + self[date(year, MAY, 9)] = ( + "Den vítězství nad hitlerovským" " fašismem" + ) if year >= 1951: - self[date(year, JUL, 5)] = "Den slovanských věrozvěstů " \ - "Cyrila a Metoděje" + self[date(year, JUL, 5)] = ( + "Den slovanských věrozvěstů " "Cyrila a Metoděje" + ) self[date(year, JUL, 6)] = "Den upálení mistra Jana Husa" if year >= 2000: self[date(year, SEP, 28)] = "Den české státnosti" if year >= 1951: - self[date(year, OCT, 28)] = "Den vzniku samostatného " \ - "československého státu" + self[date(year, OCT, 28)] = ( + "Den vzniku samostatného " "československého státu" + ) if year >= 1990: self[date(year, NOV, 17)] = "Den boje za svobodu a demokracii" @@ -76,6 +79,7 @@ class CZE(Czechia): class Czech(Czechia): def __init__(self, **kwargs): - warnings.warn("Czech is deprecated, use Czechia instead.", - DeprecationWarning) + warnings.warn( + "Czech is deprecated, use Czechia instead.", DeprecationWarning + ) super(Czech, self).__init__(**kwargs) diff --git a/holidays/countries/denmark.py b/holidays/countries/denmark.py index aeec0a855..02a158058 100644 --- a/holidays/countries/denmark.py +++ b/holidays/countries/denmark.py @@ -24,7 +24,7 @@ class Denmark(HolidayBase): # https://en.wikipedia.org/wiki/Public_holidays_in_Denmark def __init__(self, **kwargs): - self.country = 'DK' + self.country = "DK" HolidayBase.__init__(self, **kwargs) def _populate(self, year): diff --git a/holidays/countries/djibouti.py b/holidays/countries/djibouti.py index 4162c195d..8d15386ab 100644 --- a/holidays/countries/djibouti.py +++ b/holidays/countries/djibouti.py @@ -43,7 +43,7 @@ class Djibouti(HolidayBase): # is_weekend function is there, however not activated for accuracy. def __init__(self, **kwargs): - self.country = 'DJ' + self.country = "DJ" HolidayBase.__init__(self, **kwargs) def _populate(self, year): diff --git a/holidays/countries/dominican_republic.py b/holidays/countries/dominican_republic.py index 798b598f2..d9ff10752 100644 --- a/holidays/countries/dominican_republic.py +++ b/holidays/countries/dominican_republic.py @@ -25,7 +25,7 @@ class DominicanRepublic(HolidayBase): # https://es.wikipedia.org/wiki/Rep%C3%BAblica_Dominicana#D%C3%ADas_festivos_nacionales def __init__(self, **kwargs): - self.country = 'DO' + self.country = "DO" HolidayBase.__init__(self, **kwargs) @staticmethod @@ -68,12 +68,17 @@ def _populate(self, year): # Restoration Day # Judgment No. 14 of Feb 20, 2008 of the Supreme Court of Justice - restoration_day = date(year, AUG, 16) if ((year - 2000) % 4 == 0) \ - and year < 2008 else self.__change_day_by_law(date(year, AUG, 16)) + restoration_day = ( + date(year, AUG, 16) + if ((year - 2000) % 4 == 0) and year < 2008 + else self.__change_day_by_law(date(year, AUG, 16)) + ) self[restoration_day] = "Día de la Restauración [Restoration Day]" # Our Lady of Mercedes Day - self[date(year, SEP, 24)] = "Día de las Mercedes \ + self[ + date(year, SEP, 24) + ] = "Día de las Mercedes \ [Our Lady of Mercedes Day]" # Constitution Day diff --git a/holidays/countries/egypt.py b/holidays/countries/egypt.py index 10dd1a110..10898e080 100644 --- a/holidays/countries/egypt.py +++ b/holidays/countries/egypt.py @@ -39,7 +39,7 @@ class Egypt(HolidayBase): # is_weekend function is there, however not activated for accuracy. def __init__(self, **kwargs): - self.country = 'EG' + self.country = "EG" HolidayBase.__init__(self, **kwargs) def _populate(self, year): diff --git a/holidays/countries/european_central_bank.py b/holidays/countries/european_central_bank.py index d49c8878b..7daefe3d2 100644 --- a/holidays/countries/european_central_bank.py +++ b/holidays/countries/european_central_bank.py @@ -25,7 +25,7 @@ class EuropeanCentralBank(HolidayBase): # http://www.ecb.europa.eu/press/pr/date/2000/html/pr001214_4.en.html def __init__(self, **kwargs): - self.country = 'EU' + self.country = "EU" HolidayBase.__init__(self, **kwargs) def _populate(self, year): diff --git a/holidays/countries/finland.py b/holidays/countries/finland.py index 7724a0dec..305a220d1 100644 --- a/holidays/countries/finland.py +++ b/holidays/countries/finland.py @@ -16,8 +16,7 @@ from dateutil.easter import easter from dateutil.relativedelta import relativedelta as rd, SA, FR -from holidays.constants import JAN, MAY, JUN, OCT, \ - DEC +from holidays.constants import JAN, MAY, JUN, OCT, DEC from holidays.holiday_base import HolidayBase diff --git a/holidays/countries/france.py b/holidays/countries/france.py index 03b5d9898..40546f96c 100644 --- a/holidays/countries/france.py +++ b/holidays/countries/france.py @@ -16,8 +16,7 @@ from dateutil.easter import easter from dateutil.relativedelta import relativedelta as rd -from holidays.constants import JAN, APR, MAY, JUN, JUL, AUG, SEP, OCT, \ - NOV, DEC +from holidays.constants import JAN, APR, MAY, JUN, JUL, AUG, SEP, OCT, NOV, DEC from holidays.holiday_base import HolidayBase @@ -36,14 +35,24 @@ class France(HolidayBase): https://www.service-public.fr/particuliers/vosdroits/F2405 """ - PROVINCES = ['Métropole', 'Alsace-Moselle', 'Guadeloupe', 'Guyane', - 'Martinique', 'Mayotte', 'Nouvelle-Calédonie', 'La Réunion', - 'Polynésie Française', 'Saint-Barthélémy', 'Saint-Martin', - 'Wallis-et-Futuna'] + PROVINCES = [ + "Métropole", + "Alsace-Moselle", + "Guadeloupe", + "Guyane", + "Martinique", + "Mayotte", + "Nouvelle-Calédonie", + "La Réunion", + "Polynésie Française", + "Saint-Barthélémy", + "Saint-Martin", + "Wallis-et-Futuna", + ] def __init__(self, **kwargs): - self.country = 'FR' - self.prov = kwargs.pop('prov', 'Métropole') + self.country = "FR" + self.prov = kwargs.pop("prov", "Métropole") HolidayBase.__init__(self, **kwargs) def _populate(self, year): @@ -52,74 +61,79 @@ def _populate(self, year): self[date(year, JAN, 1)] = "Jour de l'an" if year > 1919: - name = 'Fête du Travail' + name = "Fête du Travail" if year <= 1948: - name += ' et de la Concorde sociale' + name += " et de la Concorde sociale" self[date(year, MAY, 1)] = name if (1953 <= year <= 1959) or year > 1981: - self[date(year, MAY, 8)] = 'Armistice 1945' + self[date(year, MAY, 8)] = "Armistice 1945" if year >= 1880: - self[date(year, JUL, 14)] = 'Fête nationale' + self[date(year, JUL, 14)] = "Fête nationale" if year >= 1918: - self[date(year, NOV, 11)] = 'Armistice 1918' + self[date(year, NOV, 11)] = "Armistice 1918" # Religious holidays - if self.prov in ['Alsace-Moselle', 'Guadeloupe', 'Guyane', - 'Martinique', 'Polynésie Française']: - self[easter(year) - rd(days=2)] = 'Vendredi saint' - - if self.prov == 'Alsace-Moselle': - self[date(year, DEC, 26)] = 'Deuxième jour de Noël' + if self.prov in [ + "Alsace-Moselle", + "Guadeloupe", + "Guyane", + "Martinique", + "Polynésie Française", + ]: + self[easter(year) - rd(days=2)] = "Vendredi saint" + + if self.prov == "Alsace-Moselle": + self[date(year, DEC, 26)] = "Deuxième jour de Noël" if year >= 1886: - self[easter(year) + rd(days=1)] = 'Lundi de Pâques' - self[easter(year) + rd(days=50)] = 'Lundi de Pentecôte' + self[easter(year) + rd(days=1)] = "Lundi de Pâques" + self[easter(year) + rd(days=50)] = "Lundi de Pentecôte" if year >= 1802: - self[easter(year) + rd(days=39)] = 'Ascension' - self[date(year, AUG, 15)] = 'Assomption' - self[date(year, NOV, 1)] = 'Toussaint' + self[easter(year) + rd(days=39)] = "Ascension" + self[date(year, AUG, 15)] = "Assomption" + self[date(year, NOV, 1)] = "Toussaint" - name = 'Noël' - if self.prov == 'Alsace-Moselle': - name = 'Premier jour de ' + name + name = "Noël" + if self.prov == "Alsace-Moselle": + name = "Premier jour de " + name self[date(year, DEC, 25)] = name # Non-metropolitan holidays (starting dates missing) - if self.prov == 'Mayotte': + if self.prov == "Mayotte": self[date(year, APR, 27)] = "Abolition de l'esclavage" - if self.prov == 'Wallis-et-Futuna': - self[date(year, APR, 28)] = 'Saint Pierre Chanel' + if self.prov == "Wallis-et-Futuna": + self[date(year, APR, 28)] = "Saint Pierre Chanel" - if self.prov == 'Martinique': + if self.prov == "Martinique": self[date(year, MAY, 22)] = "Abolition de l'esclavage" - if self.prov in ['Guadeloupe', 'Saint-Martin']: + if self.prov in ["Guadeloupe", "Saint-Martin"]: self[date(year, MAY, 27)] = "Abolition de l'esclavage" - if self.prov == 'Guyane': + if self.prov == "Guyane": self[date(year, JUN, 10)] = "Abolition de l'esclavage" - if self.prov == 'Polynésie Française': + if self.prov == "Polynésie Française": self[date(year, JUN, 29)] = "Fête de l'autonomie" - if self.prov in ['Guadeloupe', 'Martinique']: - self[date(year, JUL, 21)] = 'Fête Victor Schoelcher' + if self.prov in ["Guadeloupe", "Martinique"]: + self[date(year, JUL, 21)] = "Fête Victor Schoelcher" - if self.prov == 'Wallis-et-Futuna': - self[date(year, JUL, 29)] = 'Fête du Territoire' + if self.prov == "Wallis-et-Futuna": + self[date(year, JUL, 29)] = "Fête du Territoire" - if self.prov == 'Nouvelle-Calédonie': - self[date(year, SEP, 24)] = 'Fête de la Citoyenneté' + if self.prov == "Nouvelle-Calédonie": + self[date(year, SEP, 24)] = "Fête de la Citoyenneté" - if self.prov == 'Saint-Barthélémy': + if self.prov == "Saint-Barthélémy": self[date(year, OCT, 9)] = "Abolition de l'esclavage" - if self.prov == 'La Réunion' and year >= 1981: + if self.prov == "La Réunion" and year >= 1981: self[date(year, DEC, 20)] = "Abolition de l'esclavage" diff --git a/holidays/countries/germany.py b/holidays/countries/germany.py index 8078c45ab..89008bda1 100644 --- a/holidays/countries/germany.py +++ b/holidays/countries/germany.py @@ -16,8 +16,7 @@ from dateutil.easter import easter from dateutil.relativedelta import relativedelta as rd, WE -from holidays.constants import JAN, MAR, MAY, AUG, SEP, OCT, \ - NOV, DEC +from holidays.constants import JAN, MAR, MAY, AUG, SEP, OCT, NOV, DEC from holidays.holiday_base import HolidayBase @@ -56,12 +55,29 @@ class Germany(HolidayBase): both provinces. """ - PROVINCES = ['BW', 'BY', 'BYP', 'BE', 'BB', 'HB', 'HH', 'HE', 'MV', 'NI', - 'NW', 'RP', 'SL', 'SN', 'ST', 'SH', 'TH'] + PROVINCES = [ + "BW", + "BY", + "BYP", + "BE", + "BB", + "HB", + "HH", + "HE", + "MV", + "NI", + "NW", + "RP", + "SL", + "SN", + "ST", + "SH", + "TH", + ] def __init__(self, **kwargs): - self.country = 'DE' - self.prov = kwargs.pop('prov', None) + self.country = "DE" + self.prov = kwargs.pop("prov", None) HolidayBase.__init__(self, **kwargs) def _populate(self, year): @@ -70,12 +86,12 @@ def _populate(self, year): if year > 1990: - self[date(year, JAN, 1)] = 'Neujahr' + self[date(year, JAN, 1)] = "Neujahr" - if self.prov in ('BW', 'BY', 'BYP', 'ST'): - self[date(year, JAN, 6)] = 'Heilige Drei Könige' + if self.prov in ("BW", "BY", "BYP", "ST"): + self[date(year, JAN, 6)] = "Heilige Drei Könige" - self[easter(year) - rd(days=2)] = 'Karfreitag' + self[easter(year) - rd(days=2)] = "Karfreitag" if self.prov == "BB": # will always be a Sunday and we have no "observed" rule so @@ -83,16 +99,17 @@ def _populate(self, year): # holiday by law self[easter(year)] = "Ostersonntag" - self[easter(year) + rd(days=1)] = 'Ostermontag' + self[easter(year) + rd(days=1)] = "Ostermontag" - self[date(year, MAY, 1)] = 'Erster Mai' + self[date(year, MAY, 1)] = "Erster Mai" if self.prov == "BE" and year == 2020: - self[date(year, MAY, 8)] = \ - "75. Jahrestag der Befreiung vom Nationalsozialismus " \ + self[date(year, MAY, 8)] = ( + "75. Jahrestag der Befreiung vom Nationalsozialismus " "und der Beendigung des Zweiten Weltkriegs in Europa" + ) - self[easter(year) + rd(days=39)] = 'Christi Himmelfahrt' + self[easter(year) + rd(days=39)] = "Christi Himmelfahrt" if self.prov == "BB": # will always be a Sunday and we have no "observed" rule so @@ -100,47 +117,47 @@ def _populate(self, year): # holiday by law self[easter(year) + rd(days=49)] = "Pfingstsonntag" - self[easter(year) + rd(days=50)] = 'Pfingstmontag' + self[easter(year) + rd(days=50)] = "Pfingstmontag" - if self.prov in ('BW', 'BY', 'BYP', 'HE', 'NW', 'RP', 'SL'): - self[easter(year) + rd(days=60)] = 'Fronleichnam' + if self.prov in ("BW", "BY", "BYP", "HE", "NW", "RP", "SL"): + self[easter(year) + rd(days=60)] = "Fronleichnam" - if self.prov in ('BY', 'SL'): - self[date(year, AUG, 15)] = 'Mariä Himmelfahrt' + if self.prov in ("BY", "SL"): + self[date(year, AUG, 15)] = "Mariä Himmelfahrt" - self[date(year, OCT, 3)] = 'Tag der Deutschen Einheit' + self[date(year, OCT, 3)] = "Tag der Deutschen Einheit" - if self.prov in ('BB', 'MV', 'SN', 'ST', 'TH'): - self[date(year, OCT, 31)] = 'Reformationstag' + if self.prov in ("BB", "MV", "SN", "ST", "TH"): + self[date(year, OCT, 31)] = "Reformationstag" - if self.prov in ('HB', 'SH', 'NI', 'HH') and year >= 2018: - self[date(year, OCT, 31)] = 'Reformationstag' + if self.prov in ("HB", "SH", "NI", "HH") and year >= 2018: + self[date(year, OCT, 31)] = "Reformationstag" # in 2017 all states got the Reformationstag (500th anniversary of # Luther's thesis) if year == 2017: - self[date(year, OCT, 31)] = 'Reformationstag' + self[date(year, OCT, 31)] = "Reformationstag" - if self.prov in ('BW', 'BY', 'BYP', 'NW', 'RP', 'SL'): - self[date(year, NOV, 1)] = 'Allerheiligen' + if self.prov in ("BW", "BY", "BYP", "NW", "RP", "SL"): + self[date(year, NOV, 1)] = "Allerheiligen" - if year <= 1994 or self.prov == 'SN': + if year <= 1994 or self.prov == "SN": # can be calculated as "last wednesday before year-11-23" which is # why we need to go back two wednesdays if year-11-23 happens to be # a wednesday base_data = date(year, NOV, 23) weekday_delta = WE(-2) if base_data.weekday() == 2 else WE(-1) - self[base_data + rd(weekday=weekday_delta)] = 'Buß- und Bettag' + self[base_data + rd(weekday=weekday_delta)] = "Buß- und Bettag" if year >= 2019: - if self.prov == 'TH': - self[date(year, SEP, 20)] = 'Weltkindertag' + if self.prov == "TH": + self[date(year, SEP, 20)] = "Weltkindertag" - if self.prov == 'BE': - self[date(year, MAR, 8)] = 'Internationaler Frauentag' + if self.prov == "BE": + self[date(year, MAR, 8)] = "Internationaler Frauentag" - self[date(year, DEC, 25)] = 'Erster Weihnachtstag' - self[date(year, DEC, 26)] = 'Zweiter Weihnachtstag' + self[date(year, DEC, 25)] = "Erster Weihnachtstag" + self[date(year, DEC, 26)] = "Zweiter Weihnachtstag" class DE(Germany): diff --git a/holidays/countries/greece.py b/holidays/countries/greece.py index fa9cea979..1d5760f9a 100644 --- a/holidays/countries/greece.py +++ b/holidays/countries/greece.py @@ -24,7 +24,7 @@ class Greece(HolidayBase): # https://en.wikipedia.org/wiki/Public_holidays_in_Greece def __init__(self, **kwargs): - self.country = 'GR' + self.country = "GR" HolidayBase.__init__(self, **kwargs) def _populate(self, year): @@ -49,8 +49,9 @@ def _populate(self, year): self[date(year, MAY, 1)] = "Εργατική Πρωτομαγιά [Labour day]" # Monday of the Holy Spirit - self[eday + rd(days=50)] = \ - "Δευτέρα του Αγίου Πνεύματος [Monday of the Holy Spirit]" + self[ + eday + rd(days=50) + ] = "Δευτέρα του Αγίου Πνεύματος [Monday of the Holy Spirit]" # Assumption of Mary self[date(year, AUG, 15)] = "Κοίμηση της Θεοτόκου [Assumption of Mary]" @@ -62,8 +63,9 @@ def _populate(self, year): self[date(year, DEC, 25)] = "Χριστούγεννα [Christmas]" # Day after Christmas - self[date(year, DEC, 26)] = \ - "Επόμενη ημέρα των Χριστουγέννων [Day after Christmas]" + self[ + date(year, DEC, 26) + ] = "Επόμενη ημέρα των Χριστουγέννων [Day after Christmas]" class GR(Greece): diff --git a/holidays/countries/honduras.py b/holidays/countries/honduras.py index a924426cc..d5335bb48 100644 --- a/holidays/countries/honduras.py +++ b/holidays/countries/honduras.py @@ -16,8 +16,7 @@ from dateutil.easter import easter from dateutil.relativedelta import relativedelta as rd, TH, FR, SA, SU -from holidays.constants import JAN, FEB, MAR, APR, MAY, SEP, OCT, \ - DEC +from holidays.constants import JAN, FEB, MAR, APR, MAY, SEP, OCT, DEC from holidays.holiday_base import HolidayBase @@ -49,20 +48,22 @@ def _populate(self, year): self[date(year, MAR, 19)] = name # Maundy Thursday - self[easter(year) + rd(weekday=TH(-1)) - ] = "Jueves Santo [Maundy Thursday]" + self[ + easter(year) + rd(weekday=TH(-1)) + ] = "Jueves Santo [Maundy Thursday]" # Good Friday - self[easter(year) + rd(weekday=FR(-1)) - ] = "Viernes Santo [Good Friday]" + self[easter(year) + rd(weekday=FR(-1))] = "Viernes Santo [Good Friday]" # Holy Saturday - self[easter(year) + rd(weekday=SA(-1)) - ] = "Sábado de Gloria [Holy Saturday]" + self[ + easter(year) + rd(weekday=SA(-1)) + ] = "Sábado de Gloria [Holy Saturday]" # Easter Sunday - self[easter(year) + rd(weekday=SU(-1)) - ] = "Domingo de Resurrección [Easter Sunday]" + self[ + easter(year) + rd(weekday=SU(-1)) + ] = "Domingo de Resurrección [Easter Sunday]" # America Day if self.observed and date(year, APR, 14): @@ -75,7 +76,7 @@ def _populate(self, year): # Mother's Day may_first = date(int(year), 5, 1) weekday_seq = may_first.weekday() - mom_day = (14 - weekday_seq) + mom_day = 14 - weekday_seq if self.observed and date(year, MAY, mom_day): str_day = "Día de la madre [Mother's Day] (Observed)" self[date(year, MAY, mom_day)] = str_day diff --git a/holidays/countries/hongkong.py b/holidays/countries/hongkong.py index c0809bd63..054737652 100644 --- a/holidays/countries/hongkong.py +++ b/holidays/countries/hongkong.py @@ -16,8 +16,7 @@ from dateutil.easter import easter from dateutil.relativedelta import relativedelta as rd, FR, SA, MO -from holidays.constants import JAN, APR, MAY, JUL, SEP, OCT, \ - DEC +from holidays.constants import JAN, APR, MAY, JUL, SEP, OCT, DEC from holidays.constants import MON, TUE, WED, THU, FRI, SAT, SUN from holidays.holiday_base import HolidayBase @@ -40,8 +39,9 @@ def _populate(self, year): first_date = date(year, JAN, 1) if self.observed: if first_date.weekday() == SUN: - self[first_date + rd(days=+1)] = day_following + \ - self.first_lower(name) + self[ + first_date + rd(days=+1) + ] = day_following + self.first_lower(name) first_date = first_date + rd(days=+1) else: self[first_date] = name @@ -86,8 +86,9 @@ def _populate(self, year): # Ching Ming Festival name = "Ching Ming Festival" - if self.isLeapYear(year) or (self.isLeapYear(year - 1) and - year > 2008): + if self.isLeapYear(year) or ( + self.isLeapYear(year - 1) and year > 2008 + ): ching_ming_date = date(year, APR, 4) else: ching_ming_date = date(year, APR, 5) @@ -105,17 +106,20 @@ def _populate(self, year): easter_monday = "Easter Monday" if self.observed: self[easter(year) + rd(weekday=FR(-1))] = good_friday - self[easter(year) + rd(weekday=SA(-1))] = day_following + \ - good_friday + self[easter(year) + rd(weekday=SA(-1))] = ( + day_following + good_friday + ) if ching_ming_date == easter(year) + rd(weekday=MO): - self[easter(year) + rd(weekday=MO) + rd(days=+1)] = \ + self[easter(year) + rd(weekday=MO) + rd(days=+1)] = ( day_following + easter_monday + ) else: self[easter(year) + rd(weekday=MO)] = easter_monday else: self[easter(year) + rd(weekday=FR(-1))] = good_friday - self[easter(year) + rd(weekday=SA(-1))] = day_following + \ - good_friday + self[easter(year) + rd(weekday=SA(-1))] = ( + day_following + good_friday + ) self[easter(year) + rd(weekday=MO)] = easter_monday # Birthday of the Buddha @@ -166,8 +170,10 @@ def _populate(self, year): # Special holiday on 2015 - The 70th anniversary day of the victory # of the Chinese people's war of resistance against Japanese aggression - name = "The 70th anniversary day of the victory of the Chinese " + \ - "people's war of resistance against Japanese aggression" + name = ( + "The 70th anniversary day of the victory of the Chinese " + + "people's war of resistance against Japanese aggression" + ) if year == 2015: self[date(year, SEP, 3)] = name @@ -179,8 +185,9 @@ def _populate(self, year): if mid_autumn_date.weekday() == SAT: self[mid_autumn_date] = name else: - self[mid_autumn_date + rd(days=+1)] = day_following + \ - "the " + name + self[mid_autumn_date + rd(days=+1)] = ( + day_following + "the " + name + ) mid_autumn_date = mid_autumn_date + rd(days=+1) else: self[mid_autumn_date] = name @@ -189,8 +196,10 @@ def _populate(self, year): name = "National Day" national_date = date(year, OCT, 1) if self.observed: - if (national_date.weekday() == SUN or - national_date == mid_autumn_date): + if ( + national_date.weekday() == SUN + or national_date == mid_autumn_date + ): self[national_date + rd(days=+1)] = day_following + name else: self[national_date] = name @@ -248,46 +257,205 @@ def first_lower(self, s): # 29 days. The 12th to 15th digits indicate the month of the next month. # If it is 0x0F, it means that there is no leap month. g_lunar_month_days = [ - 0xF0EA4, 0xF1D4A, 0x52C94, 0xF0C96, 0xF1536, - 0x42AAC, 0xF0AD4, 0xF16B2, 0x22EA4, 0xF0EA4, # 1901-1910 - 0x6364A, 0xF164A, 0xF1496, 0x52956, 0xF055A, - 0xF0AD6, 0x216D2, 0xF1B52, 0x73B24, 0xF1D24, # 1911-1920 - 0xF1A4A, 0x5349A, 0xF14AC, 0xF056C, 0x42B6A, - 0xF0DA8, 0xF1D52, 0x23D24, 0xF1D24, 0x61A4C, # 1921-1930 - 0xF0A56, 0xF14AE, 0x5256C, 0xF16B4, 0xF0DA8, - 0x31D92, 0xF0E92, 0x72D26, 0xF1526, 0xF0A56, # 1931-1940 - 0x614B6, 0xF155A, 0xF0AD4, 0x436AA, 0xF1748, - 0xF1692, 0x23526, 0xF152A, 0x72A5A, 0xF0A6C, # 1941-1950 - 0xF155A, 0x52B54, 0xF0B64, 0xF1B4A, 0x33A94, - 0xF1A94, 0x8152A, 0xF152E, 0xF0AAC, 0x6156A, # 1951-1960 - 0xF15AA, 0xF0DA4, 0x41D4A, 0xF1D4A, 0xF0C94, - 0x3192E, 0xF1536, 0x72AB4, 0xF0AD4, 0xF16D2, # 1961-1970 - 0x52EA4, 0xF16A4, 0xF164A, 0x42C96, 0xF1496, - 0x82956, 0xF055A, 0xF0ADA, 0x616D2, 0xF1B52, # 1971-1980 - 0xF1B24, 0x43A4A, 0xF1A4A, 0xA349A, 0xF14AC, - 0xF056C, 0x60B6A, 0xF0DAA, 0xF1D92, 0x53D24, # 1981-1990 - 0xF1D24, 0xF1A4C, 0x314AC, 0xF14AE, 0x829AC, - 0xF06B4, 0xF0DAA, 0x52D92, 0xF0E92, 0xF0D26, # 1991-2000 - 0x42A56, 0xF0A56, 0xF14B6, 0x22AB4, 0xF0AD4, - 0x736AA, 0xF1748, 0xF1692, 0x53526, 0xF152A, # 2001-2010 - 0xF0A5A, 0x4155A, 0xF156A, 0x92B54, 0xF0BA4, - 0xF1B4A, 0x63A94, 0xF1A94, 0xF192A, 0x42A5C, # 2011-2020 - 0xF0AAC, 0xF156A, 0x22B64, 0xF0DA4, 0x61D52, - 0xF0E4A, 0xF0C96, 0x5192E, 0xF1956, 0xF0AB4, # 2021-2030 - 0x315AC, 0xF16D2, 0xB2EA4, 0xF16A4, 0xF164A, - 0x63496, 0xF1496, 0xF0956, 0x50AB6, 0xF0B5A, # 2031-2040 - 0xF16D4, 0x236A4, 0xF1B24, 0x73A4A, 0xF1A4A, - 0xF14AA, 0x5295A, 0xF096C, 0xF0B6A, 0x31B54, # 2041-2050 - 0xF1D92, 0x83D24, 0xF1D24, 0xF1A4C, 0x614AC, - 0xF14AE, 0xF09AC, 0x40DAA, 0xF0EAA, 0xF0E92, # 2051-2060 - 0x31D26, 0xF0D26, 0x72A56, 0xF0A56, 0xF14B6, - 0x52AB4, 0xF0AD4, 0xF16CA, 0x42E94, 0xF1694, # 2061-2070 - 0x8352A, 0xF152A, 0xF0A5A, 0x6155A, 0xF156A, - 0xF0B54, 0x4174A, 0xF1B4A, 0xF1A94, 0x3392A, # 2071-2080 - 0xF192C, 0x7329C, 0xF0AAC, 0xF156A, 0x52B64, - 0xF0DA4, 0xF1D4A, 0x41C94, 0xF0C96, 0x8192E, # 2081-2090 - 0xF0956, 0xF0AB6, 0x615AC, 0xF16D4, 0xF0EA4, - 0x42E4A, 0xF164A, 0xF1516, 0x22936, # 2090-2099 + 0xF0EA4, + 0xF1D4A, + 0x52C94, + 0xF0C96, + 0xF1536, + 0x42AAC, + 0xF0AD4, + 0xF16B2, + 0x22EA4, + 0xF0EA4, # 1901-1910 + 0x6364A, + 0xF164A, + 0xF1496, + 0x52956, + 0xF055A, + 0xF0AD6, + 0x216D2, + 0xF1B52, + 0x73B24, + 0xF1D24, # 1911-1920 + 0xF1A4A, + 0x5349A, + 0xF14AC, + 0xF056C, + 0x42B6A, + 0xF0DA8, + 0xF1D52, + 0x23D24, + 0xF1D24, + 0x61A4C, # 1921-1930 + 0xF0A56, + 0xF14AE, + 0x5256C, + 0xF16B4, + 0xF0DA8, + 0x31D92, + 0xF0E92, + 0x72D26, + 0xF1526, + 0xF0A56, # 1931-1940 + 0x614B6, + 0xF155A, + 0xF0AD4, + 0x436AA, + 0xF1748, + 0xF1692, + 0x23526, + 0xF152A, + 0x72A5A, + 0xF0A6C, # 1941-1950 + 0xF155A, + 0x52B54, + 0xF0B64, + 0xF1B4A, + 0x33A94, + 0xF1A94, + 0x8152A, + 0xF152E, + 0xF0AAC, + 0x6156A, # 1951-1960 + 0xF15AA, + 0xF0DA4, + 0x41D4A, + 0xF1D4A, + 0xF0C94, + 0x3192E, + 0xF1536, + 0x72AB4, + 0xF0AD4, + 0xF16D2, # 1961-1970 + 0x52EA4, + 0xF16A4, + 0xF164A, + 0x42C96, + 0xF1496, + 0x82956, + 0xF055A, + 0xF0ADA, + 0x616D2, + 0xF1B52, # 1971-1980 + 0xF1B24, + 0x43A4A, + 0xF1A4A, + 0xA349A, + 0xF14AC, + 0xF056C, + 0x60B6A, + 0xF0DAA, + 0xF1D92, + 0x53D24, # 1981-1990 + 0xF1D24, + 0xF1A4C, + 0x314AC, + 0xF14AE, + 0x829AC, + 0xF06B4, + 0xF0DAA, + 0x52D92, + 0xF0E92, + 0xF0D26, # 1991-2000 + 0x42A56, + 0xF0A56, + 0xF14B6, + 0x22AB4, + 0xF0AD4, + 0x736AA, + 0xF1748, + 0xF1692, + 0x53526, + 0xF152A, # 2001-2010 + 0xF0A5A, + 0x4155A, + 0xF156A, + 0x92B54, + 0xF0BA4, + 0xF1B4A, + 0x63A94, + 0xF1A94, + 0xF192A, + 0x42A5C, # 2011-2020 + 0xF0AAC, + 0xF156A, + 0x22B64, + 0xF0DA4, + 0x61D52, + 0xF0E4A, + 0xF0C96, + 0x5192E, + 0xF1956, + 0xF0AB4, # 2021-2030 + 0x315AC, + 0xF16D2, + 0xB2EA4, + 0xF16A4, + 0xF164A, + 0x63496, + 0xF1496, + 0xF0956, + 0x50AB6, + 0xF0B5A, # 2031-2040 + 0xF16D4, + 0x236A4, + 0xF1B24, + 0x73A4A, + 0xF1A4A, + 0xF14AA, + 0x5295A, + 0xF096C, + 0xF0B6A, + 0x31B54, # 2041-2050 + 0xF1D92, + 0x83D24, + 0xF1D24, + 0xF1A4C, + 0x614AC, + 0xF14AE, + 0xF09AC, + 0x40DAA, + 0xF0EAA, + 0xF0E92, # 2051-2060 + 0x31D26, + 0xF0D26, + 0x72A56, + 0xF0A56, + 0xF14B6, + 0x52AB4, + 0xF0AD4, + 0xF16CA, + 0x42E94, + 0xF1694, # 2061-2070 + 0x8352A, + 0xF152A, + 0xF0A5A, + 0x6155A, + 0xF156A, + 0xF0B54, + 0x4174A, + 0xF1B4A, + 0xF1A94, + 0x3392A, # 2071-2080 + 0xF192C, + 0x7329C, + 0xF0AAC, + 0xF156A, + 0x52B64, + 0xF0DA4, + 0xF1D4A, + 0x41C94, + 0xF0C96, + 0x8192E, # 2081-2090 + 0xF0956, + 0xF0AB6, + 0x615AC, + 0xF16D4, + 0xF0EA4, + 0x42E4A, + 0xF164A, + 0xF1516, + 0x22936, # 2090-2099 ] # Define range of years START_YEAR, END_YEAR = 1901, 1900 + len(g_lunar_month_days) @@ -297,12 +465,18 @@ def first_lower(self, s): LUNAR_END_DATE, SOLAR_END_DATE = (2099, 12, 30), datetime(2100, 2, 18) def get_leap_month(self, lunar_year): - return (self.g_lunar_month_days[lunar_year - self.START_YEAR] >> 16) \ - & 0x0F + return ( + self.g_lunar_month_days[lunar_year - self.START_YEAR] >> 16 + ) & 0x0F def lunar_month_days(self, lunar_year, lunar_month): - return 29 + ((self.g_lunar_month_days[lunar_year - self.START_YEAR] >> - lunar_month) & 0x01) + return 29 + ( + ( + self.g_lunar_month_days[lunar_year - self.START_YEAR] + >> lunar_month + ) + & 0x01 + ) def lunar_year_days(self, year): days = 0 diff --git a/holidays/countries/hungary.py b/holidays/countries/hungary.py index 75c3d20bb..2e6f9fb72 100644 --- a/holidays/countries/hungary.py +++ b/holidays/countries/hungary.py @@ -16,8 +16,7 @@ from dateutil.easter import easter from dateutil.relativedelta import relativedelta as rd, FR -from holidays.constants import JAN, MAR, APR, MAY, AUG, OCT, \ - NOV, DEC +from holidays.constants import JAN, MAR, APR, MAY, AUG, OCT, NOV, DEC from holidays.constants import MON, TUE, THU, WEEKEND from holidays.holiday_base import HolidayBase @@ -44,19 +43,22 @@ def _populate(self, year): # National Day if 1945 <= year <= 1950 or 1989 <= year: self._add_with_observed_day_off( - date(year, MAR, 15), "Nemzeti ünnep") + date(year, MAR, 15), "Nemzeti ünnep" + ) # Soviet era if 1950 <= year <= 1989: # Proclamation of Soviet socialist governing system - self[date(year, MAR, 21)] = \ - "A Tanácsköztársaság kikiáltásának ünnepe" + self[ + date(year, MAR, 21) + ] = "A Tanácsköztársaság kikiáltásának ünnepe" # Liberation Day self[date(year, APR, 4)] = "A felszabadulás ünnepe" # Memorial day of The Great October Soviet Socialist Revolution if year not in (1956, 1989): - self[date(year, NOV, 7)] = \ - "A nagy októberi szocialista forradalom ünnepe" + self[ + date(year, NOV, 7) + ] = "A nagy októberi szocialista forradalom ünnepe" easter_date = easter(year) @@ -81,7 +83,8 @@ def _populate(self, year): # International Workers' Day if 1946 <= year: self._add_with_observed_day_off( - date(year, MAY, 1), "A Munka ünnepe") + date(year, MAY, 1), "A Munka ünnepe" + ) if 1950 <= year <= 1953: self[date(year, MAY, 2)] = "A Munka ünnepe" @@ -90,22 +93,28 @@ def _populate(self, year): self[date(year, AUG, 20)] = "A kenyér ünnepe" else: self._add_with_observed_day_off( - date(year, AUG, 20), "Az államalapítás ünnepe") + date(year, AUG, 20), "Az államalapítás ünnepe" + ) # National Day if 1991 <= year: self._add_with_observed_day_off( - date(year, OCT, 23), "Nemzeti ünnep") + date(year, OCT, 23), "Nemzeti ünnep" + ) # All Saints' Day if 1999 <= year: self._add_with_observed_day_off( - date(year, NOV, 1), "Mindenszentek") + date(year, NOV, 1), "Mindenszentek" + ) # Christmas Eve is not endorsed officially # but nowadays it is usually a day off work - if self.observed and 2010 <= year \ - and date(year, DEC, 24).weekday() not in WEEKEND: + if ( + self.observed + and 2010 <= year + and date(year, DEC, 24).weekday() not in WEEKEND + ): self[date(year, DEC, 24)] = "Szenteste" # First christmas @@ -114,16 +123,24 @@ def _populate(self, year): # Second christmas if 1955 != year: self._add_with_observed_day_off( - date(year, DEC, 26), "Karácsony másnapja", since=2013, - before=False, after=True) + date(year, DEC, 26), + "Karácsony másnapja", + since=2013, + before=False, + after=True, + ) # New Year's Eve - if self.observed and 2014 <= year \ - and date(year, DEC, 31).weekday() == MON: + if ( + self.observed + and 2014 <= year + and date(year, DEC, 31).weekday() == MON + ): self[date(year, DEC, 31)] = "Szilveszter" - def _add_with_observed_day_off(self, day, desc, since=2010, - before=True, after=True): + def _add_with_observed_day_off( + self, day, desc, since=2010, before=True, after=True + ): # Swapped days off were in place earlier but # I haven't found official record yet. self[day] = desc diff --git a/holidays/countries/iceland.py b/holidays/countries/iceland.py index 3c6dab094..d64b9a3a4 100644 --- a/holidays/countries/iceland.py +++ b/holidays/countries/iceland.py @@ -34,16 +34,16 @@ def _populate(self, year): self[easter(year) + rd(weekday=FR(-1))] = "Föstudagurinn langi" self[easter(year)] = "Páskadagur" self[easter(year) + rd(days=1)] = "Annar í páskum" - self[date(year, APR, 19) + rd(weekday=TH(+1))] = \ - "Sumardagurinn fyrsti" + self[date(year, APR, 19) + rd(weekday=TH(+1))] = "Sumardagurinn fyrsti" self[date(year, MAY, 1)] = "Verkalýðsdagurinn" self[easter(year) + rd(days=39)] = "Uppstigningardagur" self[easter(year) + rd(days=49)] = "Hvítasunnudagur" self[easter(year) + rd(days=50)] = "Annar í hvítasunnu" self[date(year, JUN, 17)] = "Þjóðhátíðardagurinn" # First Monday of August - self[date(year, AUG, 1) + rd(weekday=MO(+1))] = \ - "Frídagur verslunarmanna" + self[ + date(year, AUG, 1) + rd(weekday=MO(+1)) + ] = "Frídagur verslunarmanna" self[date(year, DEC, 24)] = "Aðfangadagur" self[date(year, DEC, 25)] = "Jóladagur" self[date(year, DEC, 26)] = "Annar í jólum" diff --git a/holidays/countries/india.py b/holidays/countries/india.py index 4c844ee45..775f14ea6 100644 --- a/holidays/countries/india.py +++ b/holidays/countries/india.py @@ -13,8 +13,7 @@ from datetime import date -from holidays.constants import JAN, MAR, APR, MAY, JUN, AUG, OCT, \ - NOV, DEC +from holidays.constants import JAN, MAR, APR, MAY, JUN, AUG, OCT, NOV, DEC from holidays.holiday_base import HolidayBase @@ -23,8 +22,26 @@ class India(HolidayBase): # https://www.calendarlabs.com/holidays/india/ # https://slusi.dacnet.nic.in/watershedatlas/list_of_state_abbreviation.htm - PROVINCES = ['AS', 'CG', 'SK', 'KA', 'GJ', 'BR', 'RJ', 'OD', - 'TN', 'AP', 'WB', 'KL', 'HR', 'MH', 'MP', 'UP', 'UK', 'TS'] + PROVINCES = [ + "AS", + "CG", + "SK", + "KA", + "GJ", + "BR", + "RJ", + "OD", + "TN", + "AP", + "WB", + "KL", + "HR", + "MH", + "MP", + "UP", + "UK", + "TS", + ] def __init__(self, **kwargs): self.country = "IN" @@ -57,61 +74,72 @@ def _populate(self, year): self[date(year, MAY, 1)] = "Gujarat Day" self[date(year, OCT, 31)] = "Sardar Patel Jayanti" - if self.prov == 'BR': + if self.prov == "BR": self[date(year, MAR, 22)] = "Bihar Day" - if self.prov == 'RJ': + if self.prov == "RJ": self[date(year, MAR, 30)] = "Rajasthan Day" self[date(year, JUN, 15)] = "Maharana Pratap Jayanti" - if self.prov == 'OD': + if self.prov == "OD": self[date(year, APR, 1)] = "Odisha Day (Utkala Dibasa)" - self[date(year, APR, 15)] = "Maha Vishuva Sankranti / Pana" \ - " Sankranti" - - if self.prov in ('OD', 'AP', 'BR', 'WB', 'KL', - 'HR', 'MH', 'UP', 'UK', 'TN'): + self[date(year, APR, 15)] = ( + "Maha Vishuva Sankranti / Pana" " Sankranti" + ) + + if self.prov in ( + "OD", + "AP", + "BR", + "WB", + "KL", + "HR", + "MH", + "UP", + "UK", + "TN", + ): self[date(year, APR, 14)] = "Dr. B. R. Ambedkar's Jayanti" - if self.prov == 'TN': + if self.prov == "TN": self[date(year, APR, 14)] = "Puthandu (Tamil New Year)" self[date(year, APR, 15)] = "Puthandu (Tamil New Year)" - if self.prov == 'WB': + if self.prov == "WB": self[date(year, APR, 14)] = "Pohela Boishakh" self[date(year, APR, 15)] = "Pohela Boishakh" self[date(year, MAY, 9)] = "Rabindra Jayanti" - if self.prov == 'AS': + if self.prov == "AS": self[date(year, APR, 15)] = "Bihu (Assamese New Year)" - if self.prov == 'MH': + if self.prov == "MH": self[date(year, MAY, 1)] = "Maharashtra Day" - if self.prov == 'SK': + if self.prov == "SK": self[date(year, MAY, 16)] = "Annexation Day" - if self.prov == 'KA': + if self.prov == "KA": self[date(year, NOV, 1)] = "Karnataka Rajyotsava" - if self.prov == 'AP': + if self.prov == "AP": self[date(year, NOV, 1)] = "Andhra Pradesh Foundation Day" - if self.prov == 'HR': + if self.prov == "HR": self[date(year, NOV, 1)] = "Haryana Foundation Day" - if self.prov == 'MP': + if self.prov == "MP": self[date(year, NOV, 1)] = "Madhya Pradesh Foundation Day" - if self.prov == 'KL': + if self.prov == "KL": self[date(year, NOV, 1)] = "Kerala Foundation Day" - if self.prov == 'CG': + if self.prov == "CG": self[date(year, NOV, 1)] = "Chhattisgarh Foundation Day" # TS is Telangana State which was bifurcated in 2014 from AP # (AndhraPradesh) - if self.prov == 'TS': + if self.prov == "TS": self[date(year, OCT, 6)] = "Bathukamma Festival" self[date(year, APR, 6)] = "Eid al-Fitr" diff --git a/holidays/countries/ireland.py b/holidays/countries/ireland.py index af5230f18..e61453a7d 100644 --- a/holidays/countries/ireland.py +++ b/holidays/countries/ireland.py @@ -23,9 +23,8 @@ class Ireland(UnitedKingdom): - def __init__(self, **kwargs): - self.country = 'IE' + self.country = "IE" HolidayBase.__init__(self, **kwargs) def _country_specific(self, year): @@ -35,8 +34,7 @@ def _country_specific(self, year): name = "St. Patrick's Day" self[date(year, MAR, 17)] = name if self.observed and date(year, MAR, 17).weekday() in WEEKEND: - self[date(year, MAR, 17) + rd(weekday=MO)] = name + \ - " (Observed)" + self[date(year, MAR, 17) + rd(weekday=MO)] = name + " (Observed)" # Easter Monday self[easter(year) + rd(weekday=MO)] = "Easter Monday" diff --git a/holidays/countries/israel.py b/holidays/countries/israel.py index 4ca0455d0..209e48736 100644 --- a/holidays/countries/israel.py +++ b/holidays/countries/israel.py @@ -13,8 +13,16 @@ from convertdate import gregorian, hebrew -from convertdate.holidays import hanukkah, lag_baomer, passover, purim, \ - rosh_hashanah, shavuot, sukkot, yom_kippur +from convertdate.holidays import ( + hanukkah, + lag_baomer, + passover, + purim, + rosh_hashanah, + shavuot, + sukkot, + yom_kippur, +) from datetime import date from dateutil.relativedelta import relativedelta as rd @@ -23,52 +31,54 @@ class Israel(HolidayBase): def __init__(self, **kwargs): - self.country = 'IL' + self.country = "IL" HolidayBase.__init__(self, **kwargs) def _populate(self, year): # Passover - name = 'Passover I' + name = "Passover I" year, month, day = passover(year, eve=True) passover_start_dt = date(year, month, day) - self[passover_start_dt] = name + ' - Eve' + self[passover_start_dt] = name + " - Eve" self[passover_start_dt + rd(days=1)] = name - name = 'Passover' + name = "Passover" for offset in range(2, 6): - self[passover_start_dt + rd(days=offset)] = \ - name + ' - Chol HaMoed' + self[passover_start_dt + rd(days=offset)] = name + " - Chol HaMoed" - name = 'Passover VII' - self[passover_start_dt + rd(days=6)] = name + ' - Eve' + name = "Passover VII" + self[passover_start_dt + rd(days=6)] = name + " - Eve" self[passover_start_dt + rd(days=7)] = name # Memorial Day - name = 'Memorial Day' + name = "Memorial Day" year, month, day = gregorian.from_jd( - hebrew.to_jd_gregorianyear(year, hebrew.IYYAR, 3)) + hebrew.to_jd_gregorianyear(year, hebrew.IYYAR, 3) + ) self[date(year, month, day) + rd(days=1)] = name observed_delta = 0 if self.observed: day_in_week = date(year, month, day).weekday() if day_in_week in (2, 3): - observed_delta = - (day_in_week - 1) + observed_delta = -(day_in_week - 1) elif 2004 <= year and day_in_week == 5: observed_delta = 1 if observed_delta != 0: - self[date(year, month, day) + rd(days=observed_delta + 1)] = \ - name + ' (Observed)' + self[date(year, month, day) + rd(days=observed_delta + 1)] = ( + name + " (Observed)" + ) # Independence Day - name = 'Independence Day' + name = "Independence Day" self[date(year, month, day) + rd(days=2)] = name if self.observed and observed_delta != 0: - self[date(year, month, day) + rd(days=observed_delta + 2)] = \ - name + ' (Observed)' + self[date(year, month, day) + rd(days=observed_delta + 2)] = ( + name + " (Observed)" + ) # Lag Baomer name = "Lag B'Omer" @@ -76,53 +86,53 @@ def _populate(self, year): self[date(year, month, day)] = name # Shavuot - name = 'Shavuot' + name = "Shavuot" year, month, day = shavuot(year, eve=True) - self[date(year, month, day)] = name + ' - Eve' + self[date(year, month, day)] = name + " - Eve" self[date(year, month, day) + rd(days=1)] = name # Rosh Hashana - name = 'Rosh Hashanah' + name = "Rosh Hashanah" year, month, day = rosh_hashanah(year, eve=True) - self[date(year, month, day)] = name + ' - Eve' + self[date(year, month, day)] = name + " - Eve" self[date(year, month, day) + rd(days=1)] = name self[date(year, month, day) + rd(days=2)] = name # Yom Kippur - name = 'Yom Kippur' + name = "Yom Kippur" year, month, day = yom_kippur(year, eve=True) - self[date(year, month, day)] = name + ' - Eve' + self[date(year, month, day)] = name + " - Eve" self[date(year, month, day) + rd(days=1)] = name # Sukkot - name = 'Sukkot I' + name = "Sukkot I" year, month, day = sukkot(year, eve=True) sukkot_start_dt = date(year, month, day) - self[sukkot_start_dt] = name + ' - Eve' + self[sukkot_start_dt] = name + " - Eve" self[sukkot_start_dt + rd(days=1)] = name - name = 'Sukkot' + name = "Sukkot" for offset in range(2, 7): - self[sukkot_start_dt + rd(days=offset)] = name + ' - Chol HaMoed' + self[sukkot_start_dt + rd(days=offset)] = name + " - Chol HaMoed" - name = 'Sukkot VII' - self[sukkot_start_dt + rd(days=7)] = name + ' - Eve' + name = "Sukkot VII" + self[sukkot_start_dt + rd(days=7)] = name + " - Eve" self[sukkot_start_dt + rd(days=8)] = name # Hanukkah - name = 'Hanukkah' + name = "Hanukkah" year, month, day = hanukkah(year, eve=False) for offset in range(8): self[date(year, month, day) + rd(days=offset)] = name # Purim - name = 'Purim' + name = "Purim" year, month, day = purim(year, eve=True) self[date(year, month, day)] = name - self[date(year, month, day) - rd(days=1)] = name + ' - Eve' + self[date(year, month, day) - rd(days=1)] = name + " - Eve" - name = 'Shushan Purim' + name = "Shushan Purim" self[date(year, month, day) + rd(days=1)] = name diff --git a/holidays/countries/italy.py b/holidays/countries/italy.py index 12830ff13..e9ceb9d7f 100644 --- a/holidays/countries/italy.py +++ b/holidays/countries/italy.py @@ -16,28 +16,86 @@ from dateutil.easter import easter from dateutil.relativedelta import relativedelta as rd, MO -from holidays.constants import JAN, FEB, MAR, APR, MAY, JUN, JUL, AUG, SEP, \ - OCT, \ - NOV, DEC +from holidays.constants import ( + JAN, + FEB, + MAR, + APR, + MAY, + JUN, + JUL, + AUG, + SEP, + OCT, + NOV, + DEC, +) from holidays.holiday_base import HolidayBase class Italy(HolidayBase): - PROVINCES = ['AN', 'AO', 'BA', 'BL', 'BO', - 'BZ', 'BS', 'CB', 'CT', 'Cesena', - 'CH', 'CS', 'KR', 'EN', 'FE', 'FI', - 'FC', 'Forli', 'FR', 'GE', 'GO', 'IS', - 'SP', 'LT', 'MN', 'MS', 'MI', - 'MO', 'MB', 'NA', 'PD', 'PA', - 'PR', 'PG', 'PE', 'PC', 'PI', - 'PD', 'PT', 'RA', 'RE', - 'RI', 'RN', 'RM', 'RO', 'SA', - 'SR', 'TE', 'TO', 'TS', 'Pesaro', 'PU', - 'Urbino', 'VE', 'VC', 'VI'] + PROVINCES = [ + "AN", + "AO", + "BA", + "BL", + "BO", + "BZ", + "BS", + "CB", + "CT", + "Cesena", + "CH", + "CS", + "KR", + "EN", + "FE", + "FI", + "FC", + "Forli", + "FR", + "GE", + "GO", + "IS", + "SP", + "LT", + "MN", + "MS", + "MI", + "MO", + "MB", + "NA", + "PD", + "PA", + "PR", + "PG", + "PE", + "PC", + "PI", + "PD", + "PT", + "RA", + "RE", + "RI", + "RN", + "RM", + "RO", + "SA", + "SR", + "TE", + "TO", + "TS", + "Pesaro", + "PU", + "Urbino", + "VE", + "VC", + "VI", + ] def __init__(self, **kwargs): - self.country = 'IT' - self.prov = kwargs.pop('prov', kwargs.pop('state', '')) + self.country = "IT" + self.prov = kwargs.pop("prov", kwargs.pop("state", "")) HolidayBase.__init__(self, **kwargs) def _populate(self, year): @@ -58,83 +116,83 @@ def _populate(self, year): # Provinces holidays if self.prov: - if self.prov == 'AN': + if self.prov == "AN": self[date(year, MAY, 4)] = "San Ciriaco" - elif self.prov == 'AO': + elif self.prov == "AO": self[date(year, SEP, 7)] = "San Grato" - elif self.prov in ('BA'): + elif self.prov in ("BA"): self[date(year, DEC, 6)] = "San Nicola" - elif self.prov == 'BL': + elif self.prov == "BL": self[date(year, NOV, 11)] = "San Martino" - elif self.prov in ('BO'): + elif self.prov in ("BO"): self[date(year, OCT, 4)] = "San Petronio" - elif self.prov == 'BZ': + elif self.prov == "BZ": self[date(year, AUG, 15)] = "Maria Santissima Assunta" - elif self.prov == 'BS': + elif self.prov == "BS": self[date(year, FEB, 15)] = "Santi Faustino e Giovita" - elif self.prov == 'CB': + elif self.prov == "CB": self[date(year, APR, 23)] = "San Giorgio" - elif self.prov == 'CT': + elif self.prov == "CT": self[date(year, FEB, 5)] = "Sant'Agata" - elif self.prov in ('FC', 'Cesena'): + elif self.prov in ("FC", "Cesena"): self[date(year, JUN, 24)] = "San Giovanni Battista" - if self.prov in ('FC', 'Forlì'): + if self.prov in ("FC", "Forlì"): self[date(year, FEB, 4)] = "Madonna del Fuoco" - elif self.prov == 'CH': + elif self.prov == "CH": self[date(year, MAY, 11)] = "San Giustino di Chieti" - elif self.prov == 'CS': + elif self.prov == "CS": self[date(year, FEB, 12)] = "Madonna del Pilerio" - elif self.prov == 'KR': + elif self.prov == "KR": self[date(year, OCT, 9)] = "San Dionigi" - elif self.prov == 'EN': + elif self.prov == "EN": self[date(year, JUL, 2)] = "Madonna della Visitazione" - elif self.prov == 'FE': + elif self.prov == "FE": self[date(year, APR, 23)] = "San Giorgio" - elif self.prov == 'FI': + elif self.prov == "FI": self[date(year, JUN, 24)] = "San Giovanni Battista" - elif self.prov == 'FR': + elif self.prov == "FR": self[date(year, JUN, 20)] = "San Silverio" - elif self.prov == 'GE': + elif self.prov == "GE": self[date(year, JUN, 24)] = "San Giovanni Battista" - elif self.prov == 'GO': + elif self.prov == "GO": self[date(year, MAR, 16)] = "Santi Ilario e Taziano" - elif self.prov == 'IS': + elif self.prov == "IS": self[date(year, MAY, 19)] = "San Pietro Celestino" - elif self.prov == 'SP': + elif self.prov == "SP": self[date(year, MAR, 19)] = "San Giuseppe" - elif self.prov == 'LT': + elif self.prov == "LT": self[date(year, APR, 25)] = "San Marco evangelista" - elif self.prov == 'ME': + elif self.prov == "ME": self[date(year, JUN, 3)] = "Madonna della Lettera" - elif self.prov == 'MI': + elif self.prov == "MI": self[date(year, DEC, 7)] = "Sant'Ambrogio" - elif self.prov == 'MN': + elif self.prov == "MN": self[date(year, MAR, 18)] = "Sant'Anselmo da Baggio" - elif self.prov == 'MS': + elif self.prov == "MS": self[date(year, OCT, 4)] = "San Francesco d'Assisi" - elif self.prov == 'MO': + elif self.prov == "MO": self[date(year, JAN, 31)] = "San Geminiano" - elif self.prov == 'MB': + elif self.prov == "MB": self[date(year, JUN, 24)] = "San Giovanni Battista" - elif self.prov == 'NA': + elif self.prov == "NA": self[date(year, SEP, 19)] = "San Gennaro" - elif self.prov == 'PD': + elif self.prov == "PD": self[date(year, JUN, 13)] = "Sant'Antonio di Padova" - elif self.prov == 'PA': + elif self.prov == "PA": self[date(year, JUL, 15)] = "San Giovanni" - elif self.prov == 'PR': + elif self.prov == "PR": self[date(year, JAN, 13)] = "Sant'Ilario di Poitiers" - elif self.prov == 'PG': + elif self.prov == "PG": self[date(year, JAN, 29)] = "Sant'Ercolano e San Lorenzo" - elif self.prov == 'PC': + elif self.prov == "PC": self[date(year, JUL, 4)] = "Sant'Antonino di Piacenza" - elif self.prov == 'RM': + elif self.prov == "RM": self[date(year, JUN, 29)] = "Santi Pietro e Paolo" - elif self.prov == 'TO': + elif self.prov == "TO": self[date(year, JUN, 24)] = "San Giovanni Battista" - elif self.prov == 'TS': + elif self.prov == "TS": self[date(year, NOV, 3)] = "San Giusto" - elif self.prov == 'VI': + elif self.prov == "VI": self[date(year, APR, 25)] = "San Marco" # TODO: add missing provinces' holidays: diff --git a/holidays/countries/japan.py b/holidays/countries/japan.py index 989eb8d7b..925dba1f5 100644 --- a/holidays/countries/japan.py +++ b/holidays/countries/japan.py @@ -15,8 +15,20 @@ from dateutil.relativedelta import relativedelta as rd, MO -from holidays.constants import JAN, FEB, MAR, APR, MAY, JUN, JUL, AUG, SEP, \ - OCT, NOV, DEC +from holidays.constants import ( + JAN, + FEB, + MAR, + APR, + MAY, + JUN, + JUL, + AUG, + SEP, + OCT, + NOV, + DEC, +) from holidays.holiday_base import HolidayBase @@ -24,7 +36,7 @@ class Japan(HolidayBase): # https://en.wikipedia.org/wiki/Public_holidays_in_Japan def __init__(self, **kwargs): - self.country = 'JP' + self.country = "JP" HolidayBase.__init__(self, **kwargs) def _populate(self, year): @@ -45,7 +57,7 @@ def _populate(self, year): # Reiwa Emperor's Birthday if year >= 2020: - self[date(year, FEB, 23)] = '天皇誕生日' + self[date(year, FEB, 23)] = "天皇誕生日" # Vernal Equinox Day self[self._vernal_equinox_day(year)] = "春分の日" @@ -128,9 +140,9 @@ def _populate(self, year): self[date(year, JUN, 9)] = "結婚の儀" elif year == 2019: # Enthronement Day - self[date(year, MAY, 1)] = '天皇の即位の日' + self[date(year, MAY, 1)] = "天皇の即位の日" # Enthronement ceremony - self[date(year, OCT, 22)] = '即位礼正殿の儀が行われる日' + self[date(year, OCT, 22)] = "即位礼正殿の儀が行われる日" # A weekday between national holidays becomes a holiday too (国民の休日) self._add_national_holidays(year) @@ -175,8 +187,23 @@ def _autumnal_equinox_day(self, year): return date(year, SEP, day) def _add_national_holidays(self, year): - if year in (1993, 1999, 2004, 1988, 1994, 2005, 1989, 1995, 2000, 2006, - 1990, 2001, 1991, 1996, 2002): + if year in ( + 1993, + 1999, + 2004, + 1988, + 1994, + 2005, + 1989, + 1995, + 2000, + 2006, + 1990, + 2001, + 1991, + 1996, + 2002, + ): self[date(year, MAY, 4)] = "国民の休日" if year in (2032, 2049, 2060, 2077, 2088, 2094): @@ -186,25 +213,85 @@ def _add_national_holidays(self, year): self[date(year, SEP, 22)] = "国民の休日" if year == 2019: - self[date(year, APR, 30)] = '国民の休日' - self[date(year, MAY, 2)] = '国民の休日' + self[date(year, APR, 30)] = "国民の休日" + self[date(year, MAY, 2)] = "国民の休日" def _add_substitute_holidays(self, year): table = ( - (1, 2, (1978, 1984, 1989, 1995, 2006, 2012, 2017, 2023, 2034, 2040, - 2045)), + ( + 1, + 2, + ( + 1978, + 1984, + 1989, + 1995, + 2006, + 2012, + 2017, + 2023, + 2034, + 2040, + 2045, + ), + ), (1, 16, (1978, 1984, 1989, 1995)), - (2, 12, (1979, 1990, 1996, 2001, 2007, 2018, 2024, 2029, 2035, - 2046)), + ( + 2, + 12, + (1979, 1990, 1996, 2001, 2007, 2018, 2024, 2029, 2035, 2046), + ), (2, 24, (2020,)), (3, 21, (1988, 2005, 2016, 2033, 2044, 2050)), (3, 22, (1982, 1999, 2010, 2027)), - (4, 30, (1973, 1979, 1984, 1990, 2001, 2007, 2012, 2018, 2029, - 2035, 2040, 2046)), + ( + 4, + 30, + ( + 1973, + 1979, + 1984, + 1990, + 2001, + 2007, + 2012, + 2018, + 2029, + 2035, + 2040, + 2046, + ), + ), (5, 4, (1981, 1987, 1992, 1998)), - (5, 6, (1985, 1991, 1996, 2002, 2013, 2019, 2024, 2030, 2041, 2047, - 2008, 2014, 2025, 2031, 2036, 2042, 2009, 2015, 2020, 2026, - 2037, 2043, 2048)), + ( + 5, + 6, + ( + 1985, + 1991, + 1996, + 2002, + 2013, + 2019, + 2024, + 2030, + 2041, + 2047, + 2008, + 2014, + 2025, + 2031, + 2036, + 2042, + 2009, + 2015, + 2020, + 2026, + 2037, + 2043, + 2048, + ), + ), (7, 21, (1997,)), (8, 9, (2021,)), (8, 12, (2019, 2024, 2030, 2041, 2047)), @@ -212,10 +299,40 @@ def _add_substitute_holidays(self, year): (9, 23, (2024,)), (9, 24, (1973, 1984, 1990, 2001, 2007, 2018, 2029, 2035, 2046)), (10, 11, (1976, 1982, 1993, 1999)), - (11, 4, (1974, 1985, 1991, 1996, 2002, 2013, 2019, 2024, 2030, - 2041, 2047)), - (11, 24, (1975, 1980, 1986, 1997, 2003, 2008, 2014, 2025, 2031, - 2036, 2042)), + ( + 11, + 4, + ( + 1974, + 1985, + 1991, + 1996, + 2002, + 2013, + 2019, + 2024, + 2030, + 2041, + 2047, + ), + ), + ( + 11, + 24, + ( + 1975, + 1980, + 1986, + 1997, + 2003, + 2008, + 2014, + 2025, + 2031, + 2036, + 2042, + ), + ), (12, 24, (1990, 2001, 2007, 2012, 2018)), ) for holiday in table: diff --git a/holidays/countries/kenya.py b/holidays/countries/kenya.py index 5a1a3a5f3..ca4f5a1de 100644 --- a/holidays/countries/kenya.py +++ b/holidays/countries/kenya.py @@ -16,8 +16,7 @@ from dateutil.easter import easter from dateutil.relativedelta import relativedelta as rd, FR, MO -from holidays.constants import JAN, MAY, JUN, OCT, \ - DEC +from holidays.constants import JAN, MAY, JUN, OCT, DEC from holidays.constants import SUN from holidays.holiday_base import HolidayBase diff --git a/holidays/countries/korea.py b/holidays/countries/korea.py index 11f0eed71..96674f45b 100644 --- a/holidays/countries/korea.py +++ b/holidays/countries/korea.py @@ -45,8 +45,9 @@ def _populate(self, year): if self.observed: self[first_date] = name if first_date.weekday() == SUN: - self[first_date + rd(days=+1)] = alt_holiday + \ - self.first_lower(name) + self[ + first_date + rd(days=+1) + ] = alt_holiday + self.first_lower(name) first_date = first_date + rd(days=+1) else: self[first_date] = name @@ -187,8 +188,11 @@ def _populate(self, year): # convert lunar calendar date to solar def get_solar_date(self, year, month, day): self.korean_cal.setLunarDate(year, month, day, False) - return date(self.korean_cal.solarYear, self.korean_cal.solarMonth, - self.korean_cal.solarDay) + return date( + self.korean_cal.solarYear, + self.korean_cal.solarMonth, + self.korean_cal.solarDay, + ) def first_lower(self, s): return s[0].lower() + s[1:] diff --git a/holidays/countries/latvia.py b/holidays/countries/latvia.py index cbe5463a3..d162d1ba0 100644 --- a/holidays/countries/latvia.py +++ b/holidays/countries/latvia.py @@ -51,7 +51,9 @@ def _populate(self, year): # Latvia proclaimed its independence from the USSR, # and restoration of the Republic of Latvia. if year >= 1990: - self[date(year, 5, 4)] = "Latvijas Republikas \ + self[ + date(year, 5, 4) + ] = "Latvijas Republikas \ Neatkarības atjaunošanas diena" # by law @@ -67,8 +69,9 @@ def _populate(self, year): # Proclamation Day of the Republic of Latvia if year >= 1918: - self[date(year, 11, 18)] = \ - "Latvijas Republikas proklamēšanas diena" + self[ + date(year, 11, 18) + ] = "Latvijas Republikas proklamēšanas diena" # Christmas Eve self[date(year, 12, 24)] = "Ziemassvētku vakars" diff --git a/holidays/countries/lithuania.py b/holidays/countries/lithuania.py index 2429cf5e0..00ab2cc73 100644 --- a/holidays/countries/lithuania.py +++ b/holidays/countries/lithuania.py @@ -34,14 +34,14 @@ def _populate(self, year): # Day of Restoration of the State of Lithuania (1918) if year >= 1918: - self[date(year, 2, 16)] = "Lietuvos valstybės " \ - "atkūrimo diena" + self[date(year, 2, 16)] = "Lietuvos valstybės " "atkūrimo diena" # Day of Restoration of Independence of Lithuania # (from the Soviet Union, 1990) if year >= 1990: - self[date(year, 3, 11)] = "Lietuvos nepriklausomybės " \ - "atkūrimo diena" + self[date(year, 3, 11)] = ( + "Lietuvos nepriklausomybės " "atkūrimo diena" + ) # Easter easter_date = easter(year) @@ -66,13 +66,16 @@ def _populate(self, year): # Statehood Day if year >= 1991: - self[date(year, 7, 6)] = "Valstybės (Lietuvos " \ - "karaliaus Mindaugo " \ - "karūnavimo) diena" + self[date(year, 7, 6)] = ( + "Valstybės (Lietuvos " + "karaliaus Mindaugo " + "karūnavimo) diena" + ) # Assumption Day - self[date(year, 8, 15)] = "Žolinė (Švč. Mergelės " \ - "Marijos ėmimo į dangų diena)" + self[date(year, 8, 15)] = ( + "Žolinė (Švč. Mergelės " "Marijos ėmimo į dangų diena)" + ) # All Saints' Day self[date(year, 11, 1)] = "Visų šventųjų diena (Vėlinės)" diff --git a/holidays/countries/luxembourg.py b/holidays/countries/luxembourg.py index b68c7b747..171961981 100644 --- a/holidays/countries/luxembourg.py +++ b/holidays/countries/luxembourg.py @@ -25,7 +25,7 @@ class Luxembourg(HolidayBase): # https://en.wikipedia.org/wiki/Public_holidays_in_Luxembourg def __init__(self, **kwargs): - self.country = 'LU' + self.country = "LU" HolidayBase.__init__(self, **kwargs) def _populate(self, year): diff --git a/holidays/countries/malawi.py b/holidays/countries/malawi.py index 59cf996e8..1ce7087a1 100644 --- a/holidays/countries/malawi.py +++ b/holidays/countries/malawi.py @@ -22,11 +22,10 @@ class Malawi(HolidayBase): - def __init__(self, **kwargs): # https://www.officeholidays.com/countries/malawi # https://www.timeanddate.com/holidays/malawi/ - self.country = 'MW' + self.country = "MW" HolidayBase.__init__(self, **kwargs) def _populate(self, year): diff --git a/holidays/countries/mexico.py b/holidays/countries/mexico.py index dc5797eb4..739ff347b 100755 --- a/holidays/countries/mexico.py +++ b/holidays/countries/mexico.py @@ -21,9 +21,8 @@ class Mexico(HolidayBase): - def __init__(self, **kwargs): - self.country = 'MX' + self.country = "MX" HolidayBase.__init__(self, **kwargs) def _populate(self, year): @@ -40,8 +39,9 @@ def _populate(self, year): # Constitution Day name = "Día de la Constitución [Constitution Day]" if self.observed and year >= 2007: - self[date(year, FEB, 1) + rd(weekday=MO(+1))] = \ + self[date(year, FEB, 1) + rd(weekday=MO(+1))] = ( name + " (Observed)" + ) if year >= 1917: self[date(year, FEB, 5)] = name @@ -49,8 +49,9 @@ def _populate(self, year): # Benito Juárez's birthday name = "Natalicio de Benito Juárez [Benito Juárez's birthday]" if self.observed and year >= 2007: - self[date(year, MAR, 1) + rd(weekday=MO(+3))] = \ + self[date(year, MAR, 1) + rd(weekday=MO(+3))] = ( name + " (Observed)" + ) if year >= 1917: self[date(year, MAR, 21)] = name @@ -75,8 +76,9 @@ def _populate(self, year): # Revolution Day name = "Día de la Revolución [Revolution Day]" if self.observed and year >= 2007: - self[date(year, NOV, 1) + rd(weekday=MO(+3))] = \ + self[date(year, NOV, 1) + rd(weekday=MO(+3))] = ( name + " (Observed)" + ) if year >= 1917: self[date(year, NOV, 20)] = name diff --git a/holidays/countries/morocco.py b/holidays/countries/morocco.py index 9fcfe24a3..d40d8d39d 100644 --- a/holidays/countries/morocco.py +++ b/holidays/countries/morocco.py @@ -43,7 +43,7 @@ class Morocco(HolidayBase): """ def __init__(self, **kwargs): - self.country = 'MA' + self.country = "MA" HolidayBase.__init__(self, **kwargs) def _populate(self, year): @@ -65,8 +65,10 @@ def is_weekend(self, hol_date, hol_name): # Independence Manifesto Day post 1944 if year > 1944: - self[date(year, JAN, 11)] = "Commémoration de la présentation " \ - "du manifeste de l'indépendance" + self[date(year, JAN, 11)] = ( + "Commémoration de la présentation " + "du manifeste de l'indépendance" + ) # Labor day self[date(year, MAY, 1)] = "Fête du Travail" @@ -83,8 +85,9 @@ def is_weekend(self, hol_date, hol_name): self[date(year, AUG, 14)] = "Journée de Oued Ed-Dahab" # Revolution Day - self[date(year, AUG, 20)] = "Commémoration de la révolution du " \ - "Roi et du peuple" + self[date(year, AUG, 20)] = ( + "Commémoration de la révolution du " "Roi et du peuple" + ) # Youth day if year > 2000: diff --git a/holidays/countries/mozambique.py b/holidays/countries/mozambique.py index 397962f65..f38255630 100644 --- a/holidays/countries/mozambique.py +++ b/holidays/countries/mozambique.py @@ -7,7 +7,7 @@ # specific date is a holiday as fast and flexible as possible. # # Author: ryanss (c) 2014-2017 -# dr-prodigy (c) 2017-2020 +# dr-prodigy (c) 2017-2021 # Website: https://github.com/dr-prodigy/python-holidays # License: MIT (see LICENSE file) @@ -23,9 +23,8 @@ class Mozambique(HolidayBase): - def __init__(self, **kwargs): - self.country = 'MOZ' + self.country = "MOZ" HolidayBase.__init__(self, **kwargs) def _populate(self, year): diff --git a/holidays/countries/netherlands.py b/holidays/countries/netherlands.py index 8e24e749a..317ae7637 100644 --- a/holidays/countries/netherlands.py +++ b/holidays/countries/netherlands.py @@ -22,7 +22,6 @@ class Netherlands(HolidayBase): - def __init__(self, **kwargs): # http://www.iamsterdam.com/en/plan-your-trip/practical-info/public-holidays self.country = "NL" diff --git a/holidays/countries/new_zealand.py b/holidays/countries/new_zealand.py index 33f04b448..942e55339 100644 --- a/holidays/countries/new_zealand.py +++ b/holidays/countries/new_zealand.py @@ -16,18 +16,30 @@ from dateutil.easter import easter from dateutil.relativedelta import relativedelta as rd, MO, FR, WE, TU -from holidays.constants import JAN, FEB, MAR, APR, JUN, SEP, OCT, \ - NOV, DEC +from holidays.constants import JAN, FEB, MAR, APR, JUN, SEP, OCT, NOV, DEC from holidays.constants import TUE, WED, THU, WEEKEND from holidays.holiday_base import HolidayBase class NewZealand(HolidayBase): - PROVINCES = ['NTL', 'AUK', 'TKI', 'HKB', 'WGN', 'MBH', 'NSN', 'CAN', - 'STC', 'WTL', 'OTA', 'STL', 'CIT'] + PROVINCES = [ + "NTL", + "AUK", + "TKI", + "HKB", + "WGN", + "MBH", + "NSN", + "CAN", + "STC", + "WTL", + "OTA", + "STL", + "CIT", + ] def __init__(self, **kwargs): - self.country = 'NZ' + self.country = "NZ" HolidayBase.__init__(self, **kwargs) def _populate(self, year): @@ -120,8 +132,8 @@ def _populate(self, year): self[date(year, DEC, 28)] = name + " (Observed)" # Province Anniversary Day - if self.prov in ('NTL', 'Northland', 'AUK', 'Auckland'): - if 1963 < year <= 1973 and self.prov in ('NTL', 'Northland'): + if self.prov in ("NTL", "Northland", "AUK", "Auckland"): + if 1963 < year <= 1973 and self.prov in ("NTL", "Northland"): name = "Waitangi Day" dt = date(year, FEB, 6) else: @@ -132,16 +144,16 @@ def _populate(self, year): else: self[dt + rd(weekday=MO)] = name - elif self.prov in ('TKI', 'Taranaki', 'New Plymouth'): + elif self.prov in ("TKI", "Taranaki", "New Plymouth"): name = "Taranaki Anniversary Day" self[date(year, MAR, 1) + rd(weekday=MO(+2))] = name - elif self.prov in ('HKB', "Hawke's Bay"): + elif self.prov in ("HKB", "Hawke's Bay"): name = "Hawke's Bay Anniversary Day" labour_day = date(year, OCT, 1) + rd(weekday=MO(+4)) self[labour_day + rd(weekday=FR(-1))] = name - elif self.prov in ('WGN', 'Wellington'): + elif self.prov in ("WGN", "Wellington"): name = "Wellington Anniversary Day" jan22 = date(year, JAN, 22) if jan22.weekday() in (TUE, WED, THU): @@ -149,12 +161,12 @@ def _populate(self, year): else: self[jan22 + rd(weekday=MO)] = name - elif self.prov in ('MBH', 'Marlborough'): + elif self.prov in ("MBH", "Marlborough"): name = "Marlborough Anniversary Day" labour_day = date(year, OCT, 1) + rd(weekday=MO(+4)) self[labour_day + rd(weeks=1)] = name - elif self.prov in ('NSN', 'Nelson'): + elif self.prov in ("NSN", "Nelson"): name = "Nelson Anniversary Day" feb1 = date(year, FEB, 1) if feb1.weekday() in (TUE, WED, THU): @@ -162,18 +174,17 @@ def _populate(self, year): else: self[feb1 + rd(weekday=MO)] = name - elif self.prov in ('CAN', 'Canterbury'): + elif self.prov in ("CAN", "Canterbury"): name = "Canterbury Anniversary Day" - showday = date(year, NOV, 1) + rd(weekday=TU) + \ - rd(weekday=FR(+2)) + showday = date(year, NOV, 1) + rd(weekday=TU) + rd(weekday=FR(+2)) self[showday] = name - elif self.prov in ('STC', 'South Canterbury'): + elif self.prov in ("STC", "South Canterbury"): name = "South Canterbury Anniversary Day" dominion_day = date(year, SEP, 1) + rd(weekday=MO(4)) self[dominion_day] = name - elif self.prov in ('WTL', 'Westland'): + elif self.prov in ("WTL", "Westland"): name = "Westland Anniversary Day" dec1 = date(year, DEC, 1) # Observance varies?!?! @@ -184,7 +195,7 @@ def _populate(self, year): else: self[dec1 + rd(weekday=MO)] = name - elif self.prov in ('OTA', 'Otago'): + elif self.prov in ("OTA", "Otago"): name = "Otago Anniversary Day" mar23 = date(year, MAR, 23) # there is no easily determined single day of local observance?!?! @@ -196,7 +207,7 @@ def _populate(self, year): dt += rd(days=1) self[dt] = name - elif self.prov in ('STL', 'Southland'): + elif self.prov in ("STL", "Southland"): name = "Southland Anniversary Day" jan17 = date(year, JAN, 17) if year > 2011: @@ -207,7 +218,7 @@ def _populate(self, year): else: self[jan17 + rd(weekday=MO)] = name - elif self.prov in ('CIT', 'Chatham Islands'): + elif self.prov in ("CIT", "Chatham Islands"): name = "Chatham Islands Anniversary Day" nov30 = date(year, NOV, 30) if nov30.weekday() in (TUE, WED, THU): diff --git a/holidays/countries/nicaragua.py b/holidays/countries/nicaragua.py index 0999eaeb1..f9315b04b 100644 --- a/holidays/countries/nicaragua.py +++ b/holidays/countries/nicaragua.py @@ -21,19 +21,20 @@ class Nicaragua(HolidayBase): - PROVINCES = ['MN'] + PROVINCES = ["MN"] def __init__(self, **kwargs): - self.country = 'NI' - self.prov = kwargs.pop('prov', kwargs.pop('state', 'MN')) + self.country = "NI" + self.prov = kwargs.pop("prov", kwargs.pop("state", "MN")) HolidayBase.__init__(self, **kwargs) def _populate(self, year): # New Years self[date(year, JAN, 1)] = "Año Nuevo [New Year's Day]" # Maundy Thursday - self[easter(year) + rd(weekday=TH(-1))] =\ - "Jueves Santo [Maundy Thursday]" + self[ + easter(year) + rd(weekday=TH(-1)) + ] = "Jueves Santo [Maundy Thursday]" # Good Friday self[easter(year) + rd(weekday=FR(-1))] = "Viernes Santo [Good Friday]" # Labor Day @@ -42,11 +43,13 @@ def _populate(self, year): if 2020 >= year >= 1979: self[date(year, JUL, 19)] = "Día de la Revolución [Revolution Day]" # Battle of San Jacinto Day - self[date(year, SEP, 14)] =\ - "Batalla de San Jacinto [Battle of San Jacinto]" + self[ + date(year, SEP, 14) + ] = "Batalla de San Jacinto [Battle of San Jacinto]" # Independence Day - self[date(year, SEP, 15)] =\ - "Día de la Independencia [Independence Day]" + self[ + date(year, SEP, 15) + ] = "Día de la Independencia [Independence Day]" # Virgin's Day self[date(year, DEC, 8)] = "Concepción de María [Virgin's Day]" # Christmas @@ -54,7 +57,7 @@ def _populate(self, year): # Provinces festive day if self.prov: - if self.prov == 'MN': + if self.prov == "MN": # Santo Domingo Day Down self[date(year, AUG, 1)] = "Bajada de Santo Domingo" # Santo Domingo Day Up diff --git a/holidays/countries/nigeria.py b/holidays/countries/nigeria.py index de23daede..d61ae6e5f 100644 --- a/holidays/countries/nigeria.py +++ b/holidays/countries/nigeria.py @@ -13,8 +13,7 @@ from datetime import date -from holidays.constants import JAN, MAY, JUN, OCT, \ - DEC +from holidays.constants import JAN, MAY, JUN, OCT, DEC from holidays.holiday_base import HolidayBase diff --git a/holidays/countries/norway.py b/holidays/countries/norway.py index 8bf69090f..d775cd36e 100644 --- a/holidays/countries/norway.py +++ b/holidays/countries/norway.py @@ -52,9 +52,9 @@ def _populate(self, year): # Add all the sundays of the year before adding the "real" holidays if self.include_sundays: first_day_of_year = date(year, JAN, 1) - first_sunday_of_year = \ - first_day_of_year + \ - rd(days=SUN - first_day_of_year.weekday()) + first_sunday_of_year = first_day_of_year + rd( + days=SUN - first_day_of_year.weekday() + ) cur_date = first_sunday_of_year while cur_date < date(year + 1, 1, 1): diff --git a/holidays/countries/paraguay.py b/holidays/countries/paraguay.py index 7ff7c290c..ec0be0d0b 100644 --- a/holidays/countries/paraguay.py +++ b/holidays/countries/paraguay.py @@ -27,7 +27,7 @@ class Paraguay(HolidayBase): # http://www.calendarioparaguay.com/ def __init__(self, **kwargs): - self.country = 'PY' + self.country = "PY" HolidayBase.__init__(self, **kwargs) def _populate(self, year): @@ -38,8 +38,7 @@ def _populate(self, year): self[date(year, JAN, 1)] = "Año Nuevo [New Year's Day]" # Patriots day - name = "Día de los Héroes de la Patria" \ - "[Patriots Day]" + name = "Día de los Héroes de la Patria" "[Patriots Day]" if not self.observed and date(year, MAR, 1).weekday() in WEEKEND: pass @@ -51,7 +50,7 @@ def _populate(self, year): # Holy Week name_thu = "Semana Santa (Jueves Santo) [Holy day (Holy Thursday)]" name_fri = "Semana Santa (Viernes Santo) [Holy day (Holy Friday)]" - name_easter = 'Día de Pascuas [Easter Day]' + name_easter = "Día de Pascuas [Easter Day]" self[easter(year) + rd(weekday=TH(-1))] = name_thu self[easter(year) + rd(weekday=FR(-1))] = name_fri diff --git a/holidays/countries/peru.py b/holidays/countries/peru.py index cf95ded0e..236bf7f9f 100644 --- a/holidays/countries/peru.py +++ b/holidays/countries/peru.py @@ -16,8 +16,7 @@ from dateutil.easter import easter from dateutil.relativedelta import relativedelta as rd, TH, FR, SA, SU -from holidays.constants import JAN, MAY, JUN, JUL, AUG, OCT, \ - NOV, DEC +from holidays.constants import JAN, MAY, JUN, JUL, AUG, OCT, NOV, DEC from holidays.holiday_base import HolidayBase @@ -52,20 +51,22 @@ def _populate(self, year): self[date(year, OCT, 8)] = name # Holy Thursday - self[easter(year) + rd(weekday=TH(-1)) - ] = "Jueves Santo [Maundy Thursday]" + self[ + easter(year) + rd(weekday=TH(-1)) + ] = "Jueves Santo [Maundy Thursday]" # Good Friday - self[easter(year) + rd(weekday=FR(-1)) - ] = "Viernes Santo [Good Friday]" + self[easter(year) + rd(weekday=FR(-1))] = "Viernes Santo [Good Friday]" # Holy Saturday - self[easter(year) + rd(weekday=SA(-1)) - ] = "Sábado de Gloria [Holy Saturday]" + self[ + easter(year) + rd(weekday=SA(-1)) + ] = "Sábado de Gloria [Holy Saturday]" # Easter Sunday - self[easter(year) + rd(weekday=SU(-1)) - ] = "Domingo de Resurrección [Easter Sunday]" + self[ + easter(year) + rd(weekday=SU(-1)) + ] = "Domingo de Resurrección [Easter Sunday]" # Labor Day self[date(year, MAY, 1)] = "Día del Trabajo [Labour Day]" diff --git a/holidays/countries/poland.py b/holidays/countries/poland.py index b077d6357..2ba6cd836 100644 --- a/holidays/countries/poland.py +++ b/holidays/countries/poland.py @@ -25,34 +25,34 @@ class Poland(HolidayBase): # https://pl.wikipedia.org/wiki/Dni_wolne_od_pracy_w_Polsce def __init__(self, **kwargs): - self.country = 'PL' + self.country = "PL" HolidayBase.__init__(self, **kwargs) def _populate(self, year): - self[date(year, JAN, 1)] = 'Nowy Rok' + self[date(year, JAN, 1)] = "Nowy Rok" if year >= 2011: - self[date(year, JAN, 6)] = 'Święto Trzech Króli' + self[date(year, JAN, 6)] = "Święto Trzech Króli" e = easter(year) - self[e] = 'Niedziela Wielkanocna' - self[e + rd(days=1)] = 'Poniedziałek Wielkanocny' + self[e] = "Niedziela Wielkanocna" + self[e + rd(days=1)] = "Poniedziałek Wielkanocny" if year >= 1950: - self[date(year, MAY, 1)] = 'Święto Państwowe' + self[date(year, MAY, 1)] = "Święto Państwowe" if year >= 1919: - self[date(year, MAY, 3)] = 'Święto Narodowe Trzeciego Maja' + self[date(year, MAY, 3)] = "Święto Narodowe Trzeciego Maja" - self[e + rd(days=49)] = 'Zielone Świątki' - self[e + rd(days=60)] = 'Dzień Bożego Ciała' + self[e + rd(days=49)] = "Zielone Świątki" + self[e + rd(days=60)] = "Dzień Bożego Ciała" - self[date(year, AUG, 15)] = 'Wniebowzięcie Najświętszej Marii Panny' + self[date(year, AUG, 15)] = "Wniebowzięcie Najświętszej Marii Panny" - self[date(year, NOV, 1)] = 'Uroczystość Wszystkich świętych' + self[date(year, NOV, 1)] = "Uroczystość Wszystkich świętych" if (1937 <= year <= 1945) or year >= 1989: - self[date(year, NOV, 11)] = 'Narodowe Święto Niepodległości' + self[date(year, NOV, 11)] = "Narodowe Święto Niepodległości" - self[date(year, DEC, 25)] = 'Boże Narodzenie (pierwszy dzień)' - self[date(year, DEC, 26)] = 'Boże Narodzenie (drugi dzień)' + self[date(year, DEC, 25)] = "Boże Narodzenie (pierwszy dzień)" + self[date(year, DEC, 26)] = "Boże Narodzenie (drugi dzień)" class PL(Poland): @@ -65,6 +65,7 @@ class POL(Poland): class Polish(Poland): def __init__(self, **kwargs): - warnings.warn("Polish is deprecated, use Poland instead.", - DeprecationWarning) + warnings.warn( + "Polish is deprecated, use Poland instead.", DeprecationWarning + ) super(Polish, self).__init__(**kwargs) diff --git a/holidays/countries/portugal.py b/holidays/countries/portugal.py index c30b5ec8c..374229487 100644 --- a/holidays/countries/portugal.py +++ b/holidays/countries/portugal.py @@ -16,8 +16,7 @@ from dateutil.easter import easter from dateutil.relativedelta import relativedelta as rd -from holidays.constants import JAN, OCT, \ - NOV, DEC +from holidays.constants import JAN, OCT, NOV, DEC from holidays.holiday_base import HolidayBase @@ -25,7 +24,7 @@ class Portugal(HolidayBase): # https://en.wikipedia.org/wiki/Public_holidays_in_Portugal def __init__(self, **kwargs): - self.country = 'PT' + self.country = "PT" HolidayBase.__init__(self, **kwargs) def _populate(self, year): diff --git a/holidays/countries/romania.py b/holidays/countries/romania.py index 48bbd58e5..1ed607327 100644 --- a/holidays/countries/romania.py +++ b/holidays/countries/romania.py @@ -24,7 +24,7 @@ class Romania(HolidayBase): # https://en.wikipedia.org/wiki/Public_holidays_in_Romania def __init__(self, **kwargs): - self.country = 'RO' + self.country = "RO" HolidayBase.__init__(self, **kwargs) def _populate(self, year): diff --git a/holidays/countries/saudi_arabia.py b/holidays/countries/saudi_arabia.py index c4ec70dcb..565af062f 100644 --- a/holidays/countries/saudi_arabia.py +++ b/holidays/countries/saudi_arabia.py @@ -26,21 +26,21 @@ class SaudiArabia(HolidayBase): """ - There are only 3 official national holidays in Saudi: - https://laboreducation.hrsd.gov.sa/en/gallery/274 - The national day holiday is based on the Georgian calendar while the - other two holidays are based on the Islamic Calendar, and they are - estimates as they announced each year and based on moon sightings; - which are: - - Eid al-Fitr* - - Eid al-Adha* - * only if hijri-converter library is installed, otherwise a warning is - raised that this holiday is missing. hijri-converter requires - Python >= 3.6 + There are only 3 official national holidays in Saudi: + https://laboreducation.hrsd.gov.sa/en/gallery/274 + The national day holiday is based on the Georgian calendar while the + other two holidays are based on the Islamic Calendar, and they are + estimates as they announced each year and based on moon sightings; + which are: + - Eid al-Fitr* + - Eid al-Adha* + * only if hijri-converter library is installed, otherwise a warning is + raised that this holiday is missing. hijri-converter requires + Python >= 3.6 """ def __init__(self, **kwargs): - self.country = 'SA' + self.country = "SA" HolidayBase.__init__(self, **kwargs) def _populate(self, year): diff --git a/holidays/countries/serbia.py b/holidays/countries/serbia.py index d6cdc00f3..3395c41eb 100644 --- a/holidays/countries/serbia.py +++ b/holidays/countries/serbia.py @@ -25,7 +25,7 @@ class Serbia(HolidayBase): # https://en.wikipedia.org/wiki/Public_holidays_in_Serbia def __init__(self, **kwargs): - self.country = 'RS' + self.country = "RS" HolidayBase.__init__(self, **kwargs) def _populate(self, year): @@ -56,13 +56,16 @@ def _populate(self, year): if self.observed and date(year, NOV, 11).weekday() == SUN: self[date(year, NOV, 12)] = name + " (Observed)" # Easter - self[easter(year, method=EASTER_ORTHODOX) - rd(days=2)] = \ - "Велики петак" - self[easter(year, method=EASTER_ORTHODOX) - rd(days=1)] = \ - "Велика субота" + self[ + easter(year, method=EASTER_ORTHODOX) - rd(days=2) + ] = "Велики петак" + self[ + easter(year, method=EASTER_ORTHODOX) - rd(days=1) + ] = "Велика субота" self[easter(year, method=EASTER_ORTHODOX)] = "Васкрс" - self[easter(year, method=EASTER_ORTHODOX) + rd(days=1)] = \ - "Други дан Васкрса" + self[ + easter(year, method=EASTER_ORTHODOX) + rd(days=1) + ] = "Други дан Васкрса" class RS(Serbia): diff --git a/holidays/countries/singapore.py b/holidays/countries/singapore.py index 88d7bd869..da2c40cee 100644 --- a/holidays/countries/singapore.py +++ b/holidays/countries/singapore.py @@ -16,8 +16,19 @@ from dateutil.easter import easter from dateutil.relativedelta import relativedelta as rd, SA, FR, MO -from holidays.constants import JAN, FEB, MAR, MAY, JUN, JUL, AUG, SEP, OCT, \ - NOV, DEC +from holidays.constants import ( + JAN, + FEB, + MAR, + MAY, + JUN, + JUL, + AUG, + SEP, + OCT, + NOV, + DEC, +) from holidays.constants import SUN from holidays.holiday_base import HolidayBase from holidays.utils import get_gre_date @@ -61,14 +72,29 @@ def _populate(self, year): # Hari Raya Puasa # aka Eid al-Fitr # date of observance is announced yearly - dates_obs = {2001: [(DEC, 16)], 2002: [(DEC, 6)], - 2003: [(NOV, 25)], 2004: [(NOV, 14)], 2005: [(NOV, 3)], - 2006: [(OCT, 24)], 2007: [(OCT, 13)], 2008: [(OCT, 1)], - 2009: [(SEP, 20)], 2010: [(SEP, 10)], 2011: [(AUG, 30)], - 2012: [(AUG, 19)], 2013: [(AUG, 8)], 2014: [(JUL, 28)], - 2015: [(JUL, 17)], 2016: [(JUL, 6)], 2017: [(JUN, 25)], - 2018: [(JUN, 15)], 2019: [(JUN, 5)], 2020: [(MAY, 24)], - 2021: [(MAY, 13)]} + dates_obs = { + 2001: [(DEC, 16)], + 2002: [(DEC, 6)], + 2003: [(NOV, 25)], + 2004: [(NOV, 14)], + 2005: [(NOV, 3)], + 2006: [(OCT, 24)], + 2007: [(OCT, 13)], + 2008: [(OCT, 1)], + 2009: [(SEP, 20)], + 2010: [(SEP, 10)], + 2011: [(AUG, 30)], + 2012: [(AUG, 19)], + 2013: [(AUG, 8)], + 2014: [(JUL, 28)], + 2015: [(JUL, 17)], + 2016: [(JUL, 6)], + 2017: [(JUN, 25)], + 2018: [(JUN, 15)], + 2019: [(JUN, 5)], + 2020: [(MAY, 24)], + 2021: [(MAY, 13)], + } if year in dates_obs: for date_obs in dates_obs[year]: hol_date = date(year, *date_obs) @@ -86,20 +112,36 @@ def _populate(self, year): # Second day of Hari Raya Puasa (up to and including 1968) if year <= 1968: hol_date += rd(days=+1) - self[hol_date] = ("Second day of Hari Raya Puasa*" - " (*estimated)") + self[hol_date] = ( + "Second day of Hari Raya Puasa*" " (*estimated)" + ) # Hari Raya Haji # aka Eid al-Adha # date of observance is announced yearly - dates_obs = {2001: [(MAR, 6)], 2002: [(FEB, 23)], - 2003: [(FEB, 12)], 2004: [(FEB, 1)], 2005: [(JAN, 21)], - 2006: [(JAN, 10)], 2007: [(DEC, 20)], 2008: [(DEC, 8)], - 2009: [(NOV, 27)], 2010: [(NOV, 17)], 2011: [(NOV, 6)], - 2012: [(OCT, 26)], 2013: [(OCT, 15)], 2014: [(OCT, 5)], - 2015: [(SEP, 24)], 2016: [(SEP, 12)], 2017: [(SEP, 1)], - 2018: [(AUG, 22)], 2019: [(AUG, 11)], 2020: [(JUL, 31)], - 2021: [(JUL, 20)]} + dates_obs = { + 2001: [(MAR, 6)], + 2002: [(FEB, 23)], + 2003: [(FEB, 12)], + 2004: [(FEB, 1)], + 2005: [(JAN, 21)], + 2006: [(JAN, 10)], + 2007: [(DEC, 20)], + 2008: [(DEC, 8)], + 2009: [(NOV, 27)], + 2010: [(NOV, 17)], + 2011: [(NOV, 6)], + 2012: [(OCT, 26)], + 2013: [(OCT, 15)], + 2014: [(OCT, 5)], + 2015: [(SEP, 24)], + 2016: [(SEP, 12)], + 2017: [(SEP, 1)], + 2018: [(AUG, 22)], + 2019: [(AUG, 11)], + 2020: [(JUL, 31)], + 2021: [(JUL, 20)], + } if year in dates_obs: for date_obs in dates_obs[year]: hol_date = date(year, *date_obs) @@ -126,14 +168,29 @@ def _populate(self, year): # Vesak Day # date of observance is announced yearly # https://en.wikipedia.org/wiki/Vesak#Dates_of_observance - dates_obs = {2001: (MAY, 7), 2002: (MAY, 27), - 2003: (MAY, 15), 2004: (JUN, 2), 2005: (MAY, 23), - 2006: (MAY, 12), 2007: (MAY, 31), 2008: (MAY, 19), - 2009: (MAY, 9), 2010: (MAY, 28), 2011: (MAY, 17), - 2012: (MAY, 5), 2013: (MAY, 24), 2014: (MAY, 13), - 2015: (JUN, 1), 2016: (MAY, 20), 2017: (MAY, 10), - 2018: (MAY, 29), 2019: (MAY, 19), 2020: (MAY, 7), - 2021: (MAY, 26)} + dates_obs = { + 2001: (MAY, 7), + 2002: (MAY, 27), + 2003: (MAY, 15), + 2004: (JUN, 2), + 2005: (MAY, 23), + 2006: (MAY, 12), + 2007: (MAY, 31), + 2008: (MAY, 19), + 2009: (MAY, 9), + 2010: (MAY, 28), + 2011: (MAY, 17), + 2012: (MAY, 5), + 2013: (MAY, 24), + 2014: (MAY, 13), + 2015: (JUN, 1), + 2016: (MAY, 20), + 2017: (MAY, 10), + 2018: (MAY, 29), + 2019: (MAY, 19), + 2020: (MAY, 7), + 2021: (MAY, 26), + } if year in dates_obs: hol_date = date(year, *dates_obs[year]) self[hol_date] = "Vesak Day" @@ -147,14 +204,29 @@ def _populate(self, year): # Deepavali # aka Diwali # date of observance is announced yearly - dates_obs = {2001: (NOV, 14), 2002: (NOV, 3), - 2003: (OCT, 23), 2004: (NOV, 11), 2005: (NOV, 1), - 2006: (OCT, 21), 2007: (NOV, 8), 2008: (OCT, 27), - 2009: (OCT, 17), 2010: (NOV, 5), 2011: (OCT, 26), - 2012: (NOV, 13), 2013: (NOV, 2), 2014: (OCT, 22), - 2015: (NOV, 10), 2016: (OCT, 29), 2017: (OCT, 18), - 2018: (NOV, 6), 2019: (OCT, 27), 2020: (NOV, 14), - 2021: (NOV, 4)} + dates_obs = { + 2001: (NOV, 14), + 2002: (NOV, 3), + 2003: (OCT, 23), + 2004: (NOV, 11), + 2005: (NOV, 1), + 2006: (OCT, 21), + 2007: (NOV, 8), + 2008: (OCT, 27), + 2009: (OCT, 17), + 2010: (NOV, 5), + 2011: (OCT, 26), + 2012: (NOV, 13), + 2013: (NOV, 2), + 2014: (OCT, 22), + 2015: (NOV, 10), + 2016: (OCT, 29), + 2017: (OCT, 18), + 2018: (NOV, 6), + 2019: (OCT, 27), + 2020: (NOV, 14), + 2021: (NOV, 4), + } if year in dates_obs: hol_date = date(year, *dates_obs[year]) self[hol_date] = "Deepavali" @@ -170,8 +242,13 @@ def _populate(self, year): self[date(year, DEC, 26)] = "Boxing Day" # Polling Day - dates_obs = {2001: (NOV, 3), 2006: (MAY, 6), 2011: (MAY, 7), - 2015: (SEP, 11), 2020: (JUL, 10)} + dates_obs = { + 2001: (NOV, 3), + 2006: (MAY, 6), + 2011: (MAY, 7), + 2015: (SEP, 11), + 2020: (JUL, 10), + } if year in dates_obs: self[date(year, *dates_obs[year])] = "Polling Day" @@ -187,11 +264,11 @@ def _populate(self, year): # is declared a public holiday in Singapore." for (hol_date, hol_name) in list(self.items()): if hol_date.weekday() == SUN: - self[hol_date] += ' [Sunday]' + self[hol_date] += " [Sunday]" in_lieu_date = hol_date + rd(days=+1) while in_lieu_date in self: in_lieu_date += rd(days=+1) - self[in_lieu_date] = hol_name + '[In lieu]' + self[in_lieu_date] = hol_name + "[In lieu]" # The below is used to calculate lunar new year (i.e. Chinese new year) # Code borrowed from Hong Kong entry as of 16-Nov-19 @@ -203,46 +280,205 @@ def _populate(self, year): # 29 days. The 12th to 15th digits indicate the month of the next month. # If it is 0x0F, it means that there is no leap month. g_lunar_month_days = [ - 0xF0EA4, 0xF1D4A, 0x52C94, 0xF0C96, 0xF1536, - 0x42AAC, 0xF0AD4, 0xF16B2, 0x22EA4, 0xF0EA4, # 1901-1910 - 0x6364A, 0xF164A, 0xF1496, 0x52956, 0xF055A, - 0xF0AD6, 0x216D2, 0xF1B52, 0x73B24, 0xF1D24, # 1911-1920 - 0xF1A4A, 0x5349A, 0xF14AC, 0xF056C, 0x42B6A, - 0xF0DA8, 0xF1D52, 0x23D24, 0xF1D24, 0x61A4C, # 1921-1930 - 0xF0A56, 0xF14AE, 0x5256C, 0xF16B4, 0xF0DA8, - 0x31D92, 0xF0E92, 0x72D26, 0xF1526, 0xF0A56, # 1931-1940 - 0x614B6, 0xF155A, 0xF0AD4, 0x436AA, 0xF1748, - 0xF1692, 0x23526, 0xF152A, 0x72A5A, 0xF0A6C, # 1941-1950 - 0xF155A, 0x52B54, 0xF0B64, 0xF1B4A, 0x33A94, - 0xF1A94, 0x8152A, 0xF152E, 0xF0AAC, 0x6156A, # 1951-1960 - 0xF15AA, 0xF0DA4, 0x41D4A, 0xF1D4A, 0xF0C94, - 0x3192E, 0xF1536, 0x72AB4, 0xF0AD4, 0xF16D2, # 1961-1970 - 0x52EA4, 0xF16A4, 0xF164A, 0x42C96, 0xF1496, - 0x82956, 0xF055A, 0xF0ADA, 0x616D2, 0xF1B52, # 1971-1980 - 0xF1B24, 0x43A4A, 0xF1A4A, 0xA349A, 0xF14AC, - 0xF056C, 0x60B6A, 0xF0DAA, 0xF1D92, 0x53D24, # 1981-1990 - 0xF1D24, 0xF1A4C, 0x314AC, 0xF14AE, 0x829AC, - 0xF06B4, 0xF0DAA, 0x52D92, 0xF0E92, 0xF0D26, # 1991-2000 - 0x42A56, 0xF0A56, 0xF14B6, 0x22AB4, 0xF0AD4, - 0x736AA, 0xF1748, 0xF1692, 0x53526, 0xF152A, # 2001-2010 - 0xF0A5A, 0x4155A, 0xF156A, 0x92B54, 0xF0BA4, - 0xF1B4A, 0x63A94, 0xF1A94, 0xF192A, 0x42A5C, # 2011-2020 - 0xF0AAC, 0xF156A, 0x22B64, 0xF0DA4, 0x61D52, - 0xF0E4A, 0xF0C96, 0x5192E, 0xF1956, 0xF0AB4, # 2021-2030 - 0x315AC, 0xF16D2, 0xB2EA4, 0xF16A4, 0xF164A, - 0x63496, 0xF1496, 0xF0956, 0x50AB6, 0xF0B5A, # 2031-2040 - 0xF16D4, 0x236A4, 0xF1B24, 0x73A4A, 0xF1A4A, - 0xF14AA, 0x5295A, 0xF096C, 0xF0B6A, 0x31B54, # 2041-2050 - 0xF1D92, 0x83D24, 0xF1D24, 0xF1A4C, 0x614AC, - 0xF14AE, 0xF09AC, 0x40DAA, 0xF0EAA, 0xF0E92, # 2051-2060 - 0x31D26, 0xF0D26, 0x72A56, 0xF0A56, 0xF14B6, - 0x52AB4, 0xF0AD4, 0xF16CA, 0x42E94, 0xF1694, # 2061-2070 - 0x8352A, 0xF152A, 0xF0A5A, 0x6155A, 0xF156A, - 0xF0B54, 0x4174A, 0xF1B4A, 0xF1A94, 0x3392A, # 2071-2080 - 0xF192C, 0x7329C, 0xF0AAC, 0xF156A, 0x52B64, - 0xF0DA4, 0xF1D4A, 0x41C94, 0xF0C96, 0x8192E, # 2081-2090 - 0xF0956, 0xF0AB6, 0x615AC, 0xF16D4, 0xF0EA4, - 0x42E4A, 0xF164A, 0xF1516, 0x22936, # 2090-2099 + 0xF0EA4, + 0xF1D4A, + 0x52C94, + 0xF0C96, + 0xF1536, + 0x42AAC, + 0xF0AD4, + 0xF16B2, + 0x22EA4, + 0xF0EA4, # 1901-1910 + 0x6364A, + 0xF164A, + 0xF1496, + 0x52956, + 0xF055A, + 0xF0AD6, + 0x216D2, + 0xF1B52, + 0x73B24, + 0xF1D24, # 1911-1920 + 0xF1A4A, + 0x5349A, + 0xF14AC, + 0xF056C, + 0x42B6A, + 0xF0DA8, + 0xF1D52, + 0x23D24, + 0xF1D24, + 0x61A4C, # 1921-1930 + 0xF0A56, + 0xF14AE, + 0x5256C, + 0xF16B4, + 0xF0DA8, + 0x31D92, + 0xF0E92, + 0x72D26, + 0xF1526, + 0xF0A56, # 1931-1940 + 0x614B6, + 0xF155A, + 0xF0AD4, + 0x436AA, + 0xF1748, + 0xF1692, + 0x23526, + 0xF152A, + 0x72A5A, + 0xF0A6C, # 1941-1950 + 0xF155A, + 0x52B54, + 0xF0B64, + 0xF1B4A, + 0x33A94, + 0xF1A94, + 0x8152A, + 0xF152E, + 0xF0AAC, + 0x6156A, # 1951-1960 + 0xF15AA, + 0xF0DA4, + 0x41D4A, + 0xF1D4A, + 0xF0C94, + 0x3192E, + 0xF1536, + 0x72AB4, + 0xF0AD4, + 0xF16D2, # 1961-1970 + 0x52EA4, + 0xF16A4, + 0xF164A, + 0x42C96, + 0xF1496, + 0x82956, + 0xF055A, + 0xF0ADA, + 0x616D2, + 0xF1B52, # 1971-1980 + 0xF1B24, + 0x43A4A, + 0xF1A4A, + 0xA349A, + 0xF14AC, + 0xF056C, + 0x60B6A, + 0xF0DAA, + 0xF1D92, + 0x53D24, # 1981-1990 + 0xF1D24, + 0xF1A4C, + 0x314AC, + 0xF14AE, + 0x829AC, + 0xF06B4, + 0xF0DAA, + 0x52D92, + 0xF0E92, + 0xF0D26, # 1991-2000 + 0x42A56, + 0xF0A56, + 0xF14B6, + 0x22AB4, + 0xF0AD4, + 0x736AA, + 0xF1748, + 0xF1692, + 0x53526, + 0xF152A, # 2001-2010 + 0xF0A5A, + 0x4155A, + 0xF156A, + 0x92B54, + 0xF0BA4, + 0xF1B4A, + 0x63A94, + 0xF1A94, + 0xF192A, + 0x42A5C, # 2011-2020 + 0xF0AAC, + 0xF156A, + 0x22B64, + 0xF0DA4, + 0x61D52, + 0xF0E4A, + 0xF0C96, + 0x5192E, + 0xF1956, + 0xF0AB4, # 2021-2030 + 0x315AC, + 0xF16D2, + 0xB2EA4, + 0xF16A4, + 0xF164A, + 0x63496, + 0xF1496, + 0xF0956, + 0x50AB6, + 0xF0B5A, # 2031-2040 + 0xF16D4, + 0x236A4, + 0xF1B24, + 0x73A4A, + 0xF1A4A, + 0xF14AA, + 0x5295A, + 0xF096C, + 0xF0B6A, + 0x31B54, # 2041-2050 + 0xF1D92, + 0x83D24, + 0xF1D24, + 0xF1A4C, + 0x614AC, + 0xF14AE, + 0xF09AC, + 0x40DAA, + 0xF0EAA, + 0xF0E92, # 2051-2060 + 0x31D26, + 0xF0D26, + 0x72A56, + 0xF0A56, + 0xF14B6, + 0x52AB4, + 0xF0AD4, + 0xF16CA, + 0x42E94, + 0xF1694, # 2061-2070 + 0x8352A, + 0xF152A, + 0xF0A5A, + 0x6155A, + 0xF156A, + 0xF0B54, + 0x4174A, + 0xF1B4A, + 0xF1A94, + 0x3392A, # 2071-2080 + 0xF192C, + 0x7329C, + 0xF0AAC, + 0xF156A, + 0x52B64, + 0xF0DA4, + 0xF1D4A, + 0x41C94, + 0xF0C96, + 0x8192E, # 2081-2090 + 0xF0956, + 0xF0AB6, + 0x615AC, + 0xF16D4, + 0xF0EA4, + 0x42E4A, + 0xF164A, + 0xF1516, + 0x22936, # 2090-2099 ] # Define range of years START_YEAR, END_YEAR = 1901, 1900 + len(g_lunar_month_days) @@ -252,12 +488,18 @@ def _populate(self, year): LUNAR_END_DATE, SOLAR_END_DATE = (2099, 12, 30), date(2100, 2, 18) def get_leap_month(self, lunar_year): - return (self.g_lunar_month_days[lunar_year - self.START_YEAR] >> 16) \ - & 0x0F + return ( + self.g_lunar_month_days[lunar_year - self.START_YEAR] >> 16 + ) & 0x0F def lunar_month_days(self, lunar_year, lunar_month): - return 29 + ((self.g_lunar_month_days[lunar_year - self.START_YEAR] >> - lunar_month) & 0x01) + return 29 + ( + ( + self.g_lunar_month_days[lunar_year - self.START_YEAR] + >> lunar_month + ) + & 0x01 + ) def lunar_year_days(self, year): days = 0 @@ -287,7 +529,7 @@ def get_vesak_date(self, year): for m in range(1, 4 + (4 > leap_month)): span_days += self.lunar_month_days(year, m) span_days += 14 - return (self.SOLAR_START_DATE + timedelta(span_days)) + return self.SOLAR_START_DATE + timedelta(span_days) # Estimate Gregorian date of Southern India Diwali def get_s_diwali_date(self, year): @@ -298,7 +540,7 @@ def get_s_diwali_date(self, year): for m in range(1, 10 + (10 > leap_month)): span_days += self.lunar_month_days(year, m) span_days -= 2 - return (self.SOLAR_START_DATE + timedelta(span_days)) + return self.SOLAR_START_DATE + timedelta(span_days) # Estimate Gregorian date(s) of Hara Rasa Puasa def get_hrp_date(self, year): diff --git a/holidays/countries/slovakia.py b/holidays/countries/slovakia.py index 29e156f67..6c73cd327 100644 --- a/holidays/countries/slovakia.py +++ b/holidays/countries/slovakia.py @@ -17,8 +17,7 @@ from dateutil.easter import easter from dateutil.relativedelta import relativedelta as rd -from holidays.constants import JAN, MAY, JUL, AUG, SEP, OCT, \ - NOV, DEC +from holidays.constants import JAN, MAY, JUL, AUG, SEP, OCT, NOV, DEC from holidays.holiday_base import HolidayBase @@ -27,14 +26,16 @@ class Slovakia(HolidayBase): # https://www.slov-lex.sk/pravne-predpisy/SK/ZZ/1993/241/20181011.html def __init__(self, **kwargs): - self.country = 'SK' + self.country = "SK" HolidayBase.__init__(self, **kwargs) def _populate(self, year): self[date(year, JAN, 1)] = "Deň vzniku Slovenskej republiky" - self[date(year, JAN, 6)] = "Zjavenie Pána (Traja králi a" \ - " vianočnýsviatok pravoslávnych" \ - " kresťanov)" + self[date(year, JAN, 6)] = ( + "Zjavenie Pána (Traja králi a" + " vianočnýsviatok pravoslávnych" + " kresťanov)" + ) e = easter(year) self[e - rd(days=2)] = "Veľký piatok" @@ -47,15 +48,17 @@ def _populate(self, year): self[date(year, JUL, 5)] = "Sviatok svätého Cyrila a svätého Metoda" - self[date(year, AUG, 29)] = "Výročie Slovenského národného" \ - " povstania" + self[date(year, AUG, 29)] = ( + "Výročie Slovenského národného" " povstania" + ) self[date(year, SEP, 1)] = "Deň Ústavy Slovenskej republiky" self[date(year, SEP, 15)] = "Sedembolestná Panna Mária" if year == 2018: - self[date(year, OCT, 30)] = "100. výročie prijatia" \ - " Deklarácie slovenského národa" + self[date(year, OCT, 30)] = ( + "100. výročie prijatia" " Deklarácie slovenského národa" + ) self[date(year, NOV, 1)] = "Sviatok Všetkých svätých" if year >= 2001: @@ -78,6 +81,7 @@ class SVK(Slovakia): class Slovak(Slovakia): def __init__(self, **kwargs): - warnings.warn("Slovak is deprecated, use Slovakia instead.", - DeprecationWarning) + warnings.warn( + "Slovak is deprecated, use Slovakia instead.", DeprecationWarning + ) super(Slovak, self).__init__(**kwargs) diff --git a/holidays/countries/slovenia.py b/holidays/countries/slovenia.py index bc12f3d3e..28d7686b0 100644 --- a/holidays/countries/slovenia.py +++ b/holidays/countries/slovenia.py @@ -16,8 +16,7 @@ from dateutil.easter import easter from dateutil.relativedelta import relativedelta as rd -from holidays.constants import JAN, FEB, APR, MAY, JUN, AUG, OCT, \ - NOV, DEC +from holidays.constants import JAN, FEB, APR, MAY, JUN, AUG, OCT, NOV, DEC from holidays.holiday_base import HolidayBase @@ -33,7 +32,7 @@ class Slovenia(HolidayBase): """ def __init__(self, **kwargs): - self.country = 'SI' + self.country = "SI" HolidayBase.__init__(self, **kwargs) def _populate(self, year): diff --git a/holidays/countries/south_africa.py b/holidays/countries/south_africa.py index b52d884ad..93191e3a9 100644 --- a/holidays/countries/south_africa.py +++ b/holidays/countries/south_africa.py @@ -17,8 +17,7 @@ from dateutil.relativedelta import relativedelta as rd from holidays.constants import FRI, SUN -from holidays.constants import JAN, MAR, APR, MAY, JUN, JUL, AUG, SEP, OCT, \ - DEC +from holidays.constants import JAN, MAR, APR, MAY, JUN, JUL, AUG, SEP, OCT, DEC from holidays.holiday_base import HolidayBase diff --git a/holidays/countries/spain.py b/holidays/countries/spain.py index b434ace99..794032b12 100644 --- a/holidays/countries/spain.py +++ b/holidays/countries/spain.py @@ -15,19 +15,49 @@ from dateutil.easter import easter from dateutil.relativedelta import relativedelta as rd, TH, FR, MO -from holidays.constants import JAN, FEB, MAR, APR, MAY, JUN, JUL, AUG, SEP,\ - OCT, NOV, DEC +from holidays.constants import ( + JAN, + FEB, + MAR, + APR, + MAY, + JUN, + JUL, + AUG, + SEP, + OCT, + NOV, + DEC, +) from holidays.constants import SUN from holidays.holiday_base import HolidayBase class Spain(HolidayBase): - PROVINCES = ['AN', 'AR', 'AS', 'CB', 'CM', 'CL', 'CT', 'VC', - 'EX', 'GA', 'IB', 'CN', 'MD', 'MC', 'ML', 'NC', 'PV', 'RI'] + PROVINCES = [ + "AN", + "AR", + "AS", + "CB", + "CM", + "CL", + "CT", + "VC", + "EX", + "GA", + "IB", + "CN", + "MD", + "MC", + "ML", + "NC", + "PV", + "RI", + ] def __init__(self, **kwargs): - self.country = 'ES' - self.prov = kwargs.pop('prov', kwargs.pop('state', '')) + self.country = "ES" + self.prov = kwargs.pop("prov", kwargs.pop("state", "")) HolidayBase.__init__(self, **kwargs) def _is_observed(self, date_holiday, name_holiday): @@ -40,86 +70,123 @@ def _populate(self, year): self._is_observed(date(year, JAN, 1), "Año nuevo") self._is_observed(date(year, JAN, 6), "Epifanía del Señor") - if year < 2015 and self.prov and self.prov in \ - ['AR', 'CL', 'CM', 'EX', 'GA', 'MD', 'ML', 'MC', 'NC', - 'PV', 'VC']: + if ( + year < 2015 + and self.prov + and self.prov + in [ + "AR", + "CL", + "CM", + "EX", + "GA", + "MD", + "ML", + "MC", + "NC", + "PV", + "VC", + ] + ): self._is_observed(date(year, MAR, 19), "San José") - elif year == 2015 and self.prov and self.prov in \ - ['CM', 'MD', 'ML', 'MC', 'NC', 'PV', 'VC']: + elif ( + year == 2015 + and self.prov + and self.prov in ["CM", "MD", "ML", "MC", "NC", "PV", "VC"] + ): self._is_observed(date(year, MAR, 19), "San José") - elif year == 2016 and self.prov and self.prov in \ - ['ML', 'MC', 'PV', 'VC']: + elif ( + year == 2016 + and self.prov + and self.prov in ["ML", "MC", "PV", "VC"] + ): self._is_observed(date(year, MAR, 19), "San José") - elif year == 2017 and self.prov and self.prov in ['PV']: + elif year == 2017 and self.prov and self.prov in ["PV"]: self._is_observed(date(year, MAR, 19), "San José") - elif 2018 <= year <= 2019 and self.prov and self.prov in \ - ['GA', 'MC', 'NC', 'PV', 'VC']: + elif ( + 2018 <= year <= 2019 + and self.prov + and self.prov in ["GA", "MC", "NC", "PV", "VC"] + ): self._is_observed(date(year, MAR, 19), "San José") - elif 2020 <= year <= 2025 and self.prov and self.prov in \ - ['CM', 'GA', 'MC', 'NC', 'PV', 'VC']: + elif ( + 2020 <= year <= 2025 + and self.prov + and self.prov in ["CM", "GA", "MC", "NC", "PV", "VC"] + ): self._is_observed(date(year, MAR, 19), "San José") - if self.prov and self.prov not in ['CT', 'VC']: + if self.prov and self.prov not in ["CT", "VC"]: self[easter(year) + rd(weeks=-1, weekday=TH)] = "Jueves Santo" self[easter(year) + rd(weeks=-1, weekday=FR)] = "Viernes Santo" - if self.prov and self.prov in \ - ['CT', 'PV', 'NC', 'VC', 'IB', 'CM']: + if self.prov and self.prov in ["CT", "PV", "NC", "VC", "IB", "CM"]: self[easter(year) + rd(weekday=MO)] = "Lunes de Pascua" self._is_observed(date(year, MAY, 1), "Día del Trabajador") - if self.prov and self.prov in ['CT', 'GA', 'VC']: + if self.prov and self.prov in ["CT", "GA", "VC"]: self._is_observed(date(year, JUN, 24), "San Juan") self._is_observed(date(year, AUG, 15), "Asunción de la Virgen") self._is_observed(date(year, OCT, 12), "Día de la Hispanidad") self._is_observed(date(year, NOV, 1), "Todos los Santos") - self._is_observed(date(year, DEC, 6), "Día de la Constitución " - "Española") + self._is_observed( + date(year, DEC, 6), "Día de la Constitución " "Española" + ) self._is_observed(date(year, DEC, 8), "La Inmaculada Concepción") self._is_observed(date(year, DEC, 25), "Navidad") - if self.prov and self.prov in ['CT', 'IB']: + if self.prov and self.prov in ["CT", "IB"]: self._is_observed(date(year, DEC, 26), "San Esteban") # Provinces festive day if self.prov: - if self.prov == 'AN': + if self.prov == "AN": self._is_observed(date(year, FEB, 28), "Día de Andalucia") - elif self.prov == 'AR': + elif self.prov == "AR": self._is_observed(date(year, APR, 23), "Día de San Jorge") - elif self.prov == 'AS': + elif self.prov == "AS": self._is_observed(date(year, SEP, 8), "Día de Asturias") - elif self.prov == 'CB': - self._is_observed(date(year, JUL, 28), "Día de las Instituci" - "ones de Cantabria") - elif self.prov == 'CM': - self._is_observed(date(year, MAY, 31), "Día de Castilla " - "La Mancha") - elif self.prov == 'CL': - self._is_observed(date(year, APR, 23), "Día de Castilla y " - "Leon") - elif self.prov == 'CT': - self._is_observed(date(year, SEP, 11), "Día Nacional de " - "Catalunya") - elif self.prov == 'VC': - self._is_observed(date(year, OCT, 9), "Día de la Comunidad " - "Valenciana") - elif self.prov == 'EX': + elif self.prov == "CB": + self._is_observed( + date(year, JUL, 28), + "Día de las Instituci" "ones de Cantabria", + ) + elif self.prov == "CM": + self._is_observed( + date(year, MAY, 31), "Día de Castilla " "La Mancha" + ) + elif self.prov == "CL": + self._is_observed( + date(year, APR, 23), "Día de Castilla y " "Leon" + ) + elif self.prov == "CT": + self._is_observed( + date(year, SEP, 11), "Día Nacional de " "Catalunya" + ) + elif self.prov == "VC": + self._is_observed( + date(year, OCT, 9), "Día de la Comunidad " "Valenciana" + ) + elif self.prov == "EX": self._is_observed(date(year, SEP, 8), "Día de Extremadura") - elif self.prov == 'GA': - self._is_observed(date(year, JUL, 25), "Día Nacional de " - "Galicia") - elif self.prov == 'IB': - self._is_observed(date(year, MAR, 1), "Día de las Islas " - "Baleares") - elif self.prov == 'CN': + elif self.prov == "GA": + self._is_observed( + date(year, JUL, 25), "Día Nacional de " "Galicia" + ) + elif self.prov == "IB": + self._is_observed( + date(year, MAR, 1), "Día de las Islas " "Baleares" + ) + elif self.prov == "CN": self._is_observed(date(year, MAY, 30), "Día de Canarias") - elif self.prov == 'MD': - self._is_observed(date(year, MAY, 2), "Día de Comunidad de " - "Madrid") - elif self.prov == 'MC': - self._is_observed(date(year, JUN, 9), "Día de la Región de " - "Murcia") - elif self.prov == 'NC': + elif self.prov == "MD": + self._is_observed( + date(year, MAY, 2), "Día de Comunidad de " "Madrid" + ) + elif self.prov == "MC": + self._is_observed( + date(year, JUN, 9), "Día de la Región de " "Murcia" + ) + elif self.prov == "NC": self._is_observed(date(year, SEP, 27), "Día de Navarra") - elif self.prov == 'PV': + elif self.prov == "PV": self._is_observed(date(year, OCT, 25), "Día del Páis Vasco") - elif self.prov == 'RI': + elif self.prov == "RI": self._is_observed(date(year, JUN, 9), "Día de La Rioja") diff --git a/holidays/countries/sweden.py b/holidays/countries/sweden.py index b9b455dee..9b9b51f15 100644 --- a/holidays/countries/sweden.py +++ b/holidays/countries/sweden.py @@ -16,8 +16,7 @@ from dateutil.easter import easter from dateutil.relativedelta import relativedelta as rd, FR, SA -from holidays.constants import JAN, MAR, MAY, JUN, OCT, \ - DEC +from holidays.constants import JAN, MAR, MAY, JUN, OCT, DEC from holidays.constants import MON, THU, FRI, SAT, SUN from holidays.holiday_base import HolidayBase @@ -50,9 +49,9 @@ def _populate(self, year): # Add all the sundays of the year before adding the "real" holidays if self.include_sundays: first_day_of_year = date(year, JAN, 1) - first_sunday_of_year = \ - first_day_of_year + \ - rd(days=SUN - first_day_of_year.weekday()) + first_sunday_of_year = first_day_of_year + rd( + days=SUN - first_day_of_year.weekday() + ) cur_date = first_sunday_of_year while cur_date < date(year + 1, 1, 1): diff --git a/holidays/countries/switzerland.py b/holidays/countries/switzerland.py index 44f7354fe..ee207a4cb 100644 --- a/holidays/countries/switzerland.py +++ b/holidays/countries/switzerland.py @@ -21,105 +21,197 @@ class Switzerland(HolidayBase): - PROVINCES = ['AG', 'AR', 'AI', 'BL', 'BS', 'BE', 'FR', 'GE', 'GL', - 'GR', 'JU', 'LU', 'NE', 'NW', 'OW', 'SG', 'SH', 'SZ', - 'SO', 'TG', 'TI', 'UR', 'VD', 'VS', 'ZG', 'ZH'] + PROVINCES = [ + "AG", + "AR", + "AI", + "BL", + "BS", + "BE", + "FR", + "GE", + "GL", + "GR", + "JU", + "LU", + "NE", + "NW", + "OW", + "SG", + "SH", + "SZ", + "SO", + "TG", + "TI", + "UR", + "VD", + "VS", + "ZG", + "ZH", + ] def __init__(self, **kwargs): - self.country = 'CH' + self.country = "CH" HolidayBase.__init__(self, **kwargs) def _populate(self, year): # public holidays - self[date(year, JAN, 1)] = 'Neujahrestag' - - if self.prov in ('AG', 'BE', 'FR', 'GL', 'GR', 'JU', 'LU', - 'NE', 'OW', 'SH', 'SO', 'TG', 'VD', 'ZG', 'ZH'): - self[date(year, JAN, 2)] = 'Berchtoldstag' - - if self.prov in ('SZ', 'TI', 'UR'): - self[date(year, JAN, 6)] = 'Heilige Drei Könige' - - if self.prov == 'NE': - self[date(year, MAR, 1)] = 'Jahrestag der Ausrufung der Republik' - - if self.prov in ('NW', 'SZ', 'TI', 'UR', 'VS'): - self[date(year, MAR, 19)] = 'Josefstag' + self[date(year, JAN, 1)] = "Neujahrestag" + + if self.prov in ( + "AG", + "BE", + "FR", + "GL", + "GR", + "JU", + "LU", + "NE", + "OW", + "SH", + "SO", + "TG", + "VD", + "ZG", + "ZH", + ): + self[date(year, JAN, 2)] = "Berchtoldstag" + + if self.prov in ("SZ", "TI", "UR"): + self[date(year, JAN, 6)] = "Heilige Drei Könige" + + if self.prov == "NE": + self[date(year, MAR, 1)] = "Jahrestag der Ausrufung der Republik" + + if self.prov in ("NW", "SZ", "TI", "UR", "VS"): + self[date(year, MAR, 19)] = "Josefstag" # Näfelser Fahrt (first Thursday in April but not in Holy Week) - if self.prov == 'GL' and year >= 1835: - if ((date(year, APR, 1) + rd(weekday=FR)) != - (easter(year) - rd(days=2))): - self[date(year, APR, 1) + rd(weekday=TH)] = 'Näfelser Fahrt' + if self.prov == "GL" and year >= 1835: + if (date(year, APR, 1) + rd(weekday=FR)) != ( + easter(year) - rd(days=2) + ): + self[date(year, APR, 1) + rd(weekday=TH)] = "Näfelser Fahrt" else: - self[date(year, APR, 8) + rd(weekday=TH)] = 'Näfelser Fahrt' + self[date(year, APR, 8) + rd(weekday=TH)] = "Näfelser Fahrt" # it's a Holiday on a Sunday - self[easter(year)] = 'Ostern' + self[easter(year)] = "Ostern" # VS don't have easter - if self.prov != 'VS': - self[easter(year) - rd(days=2)] = 'Karfreitag' - self[easter(year) + rd(weekday=MO)] = 'Ostermontag' + if self.prov != "VS": + self[easter(year) - rd(days=2)] = "Karfreitag" + self[easter(year) + rd(weekday=MO)] = "Ostermontag" - if self.prov in ('BL', 'BS', 'JU', 'NE', 'SH', 'SO', 'TG', 'TI', - 'ZH'): - self[date(year, MAY, 1)] = 'Tag der Arbeit' + if self.prov in ("BL", "BS", "JU", "NE", "SH", "SO", "TG", "TI", "ZH"): + self[date(year, MAY, 1)] = "Tag der Arbeit" - self[easter(year) + rd(days=39)] = 'Auffahrt' + self[easter(year) + rd(days=39)] = "Auffahrt" # it's a Holiday on a Sunday - self[easter(year) + rd(days=49)] = 'Pfingsten' - - self[easter(year) + rd(days=50)] = 'Pfingstmontag' - - if self.prov in ('AI', 'JU', 'LU', 'NW', 'OW', 'SZ', 'TI', 'UR', - 'VS', 'ZG'): - self[easter(year) + rd(days=60)] = 'Fronleichnam' - - if self.prov == 'JU': - self[date(year, JUN, 23)] = 'Fest der Unabhängigkeit' - - if self.prov == 'TI': - self[date(year, JUN, 29)] = 'Peter und Paul' + self[easter(year) + rd(days=49)] = "Pfingsten" + + self[easter(year) + rd(days=50)] = "Pfingstmontag" + + if self.prov in ( + "AI", + "JU", + "LU", + "NW", + "OW", + "SZ", + "TI", + "UR", + "VS", + "ZG", + ): + self[easter(year) + rd(days=60)] = "Fronleichnam" + + if self.prov == "JU": + self[date(year, JUN, 23)] = "Fest der Unabhängigkeit" + + if self.prov == "TI": + self[date(year, JUN, 29)] = "Peter und Paul" if year >= 1291: - self[date(year, AUG, 1)] = 'Nationalfeiertag' - - if self.prov in ('AI', 'JU', 'LU', 'NW', 'OW', 'SZ', 'TI', 'UR', - 'VS', 'ZG'): - self[date(year, AUG, 15)] = 'Mariä Himmelfahrt' - - if self.prov == 'VD': + self[date(year, AUG, 1)] = "Nationalfeiertag" + + if self.prov in ( + "AI", + "JU", + "LU", + "NW", + "OW", + "SZ", + "TI", + "UR", + "VS", + "ZG", + ): + self[date(year, AUG, 15)] = "Mariä Himmelfahrt" + + if self.prov == "VD": # Monday after the third Sunday of September dt = date(year, SEP, 1) + rd(weekday=SU(+3)) + rd(weekday=MO) - self[dt] = 'Lundi du Jeûne' + self[dt] = "Lundi du Jeûne" - if self.prov == 'GE': + if self.prov == "GE": # Thursday after the first Sunday of September dt = date(year, SEP, 1) + rd(weekday=SU) + rd(weekday=TH) - self[dt] = 'Jeûne genevois' - - if self.prov == 'OW': - self[date(year, SEP, 25)] = 'Bruder Klaus' - - if self.prov in ('AI', 'GL', 'JU', 'LU', 'NW', 'OW', 'SG', 'SZ', - 'TI', 'UR', 'VS', 'ZG'): - self[date(year, NOV, 1)] = 'Allerheiligen' - - if self.prov in ('AI', 'LU', 'NW', 'OW', 'SZ', 'TI', 'UR', 'VS', - 'ZG'): - self[date(year, DEC, 8)] = 'Mariä Empfängnis' - - self[date(year, DEC, 25)] = 'Weihnachten' - - if self.prov in ('AG', 'AR', 'AI', 'BL', 'BS', 'BE', 'FR', 'GL', - 'GR', 'LU', 'NE', 'NW', 'OW', 'SG', 'SH', 'SZ', - 'SO', 'TG', 'TI', 'UR', 'ZG', 'ZH'): - self[date(year, DEC, 26)] = 'Stephanstag' - - if self.prov == 'GE': - self[date(year, DEC, 31)] = 'Wiederherstellung der Republik' + self[dt] = "Jeûne genevois" + + if self.prov == "OW": + self[date(year, SEP, 25)] = "Bruder Klaus" + + if self.prov in ( + "AI", + "GL", + "JU", + "LU", + "NW", + "OW", + "SG", + "SZ", + "TI", + "UR", + "VS", + "ZG", + ): + self[date(year, NOV, 1)] = "Allerheiligen" + + if self.prov in ("AI", "LU", "NW", "OW", "SZ", "TI", "UR", "VS", "ZG"): + self[date(year, DEC, 8)] = "Mariä Empfängnis" + + self[date(year, DEC, 25)] = "Weihnachten" + + if self.prov in ( + "AG", + "AR", + "AI", + "BL", + "BS", + "BE", + "FR", + "GL", + "GR", + "LU", + "NE", + "NW", + "OW", + "SG", + "SH", + "SZ", + "SO", + "TG", + "TI", + "UR", + "ZG", + "ZH", + ): + self[date(year, DEC, 26)] = "Stephanstag" + + if self.prov == "GE": + self[date(year, DEC, 31)] = "Wiederherstellung der Republik" class CH(Switzerland): diff --git a/holidays/countries/turkey.py b/holidays/countries/turkey.py index fb4616a8f..302113415 100644 --- a/holidays/countries/turkey.py +++ b/holidays/countries/turkey.py @@ -23,7 +23,7 @@ class Turkey(HolidayBase): # https://en.wikipedia.org/wiki/Public_holidays_in_Turkey def __init__(self, **kwargs): - self.country = 'TR' + self.country = "TR" HolidayBase.__init__(self, **kwargs) def _populate(self, year): @@ -38,8 +38,9 @@ def _populate(self, year): self[date(year, MAY, 1)] = "Labour Day" # 19th of May - self[date(year, MAY, 19)] = "Commemoration of Ataturk, Youth and "\ - "Sports Day" + self[date(year, MAY, 19)] = ( + "Commemoration of Ataturk, Youth and " "Sports Day" + ) # 15th of Jul # Became a national holiday after 15 Jul 2016 coup d'etat attempt. diff --git a/holidays/countries/ukraine.py b/holidays/countries/ukraine.py index 2d93265c3..713418a81 100644 --- a/holidays/countries/ukraine.py +++ b/holidays/countries/ukraine.py @@ -16,8 +16,7 @@ from dateutil.easter import easter, EASTER_ORTHODOX from dateutil.relativedelta import relativedelta as rd -from holidays.constants import JAN, MAR, MAY, JUN, JUL, AUG, SEP, OCT, \ - NOV, DEC +from holidays.constants import JAN, MAR, MAY, JUN, JUL, AUG, SEP, OCT, NOV, DEC from holidays.holiday_base import HolidayBase @@ -42,8 +41,7 @@ def _populate(self, year): # Christmas Day (Orthodox) if year >= 1991: - self[date(year, JAN, 7)] = "Різдво Христове" \ - " (православне)" + self[date(year, JAN, 7)] = "Різдво Христове" " (православне)" # Women's Day if year > 1965: @@ -51,8 +49,7 @@ def _populate(self, year): # Easter if year >= 1991: - self[easter(year, method=EASTER_ORTHODOX)] = "Пасха" \ - " (Великдень)" + self[easter(year, method=EASTER_ORTHODOX)] = "Пасха" " (Великдень)" # Holy trinity if year >= 1991: @@ -102,8 +99,7 @@ def _populate(self, year): # October Revolution if 1917 < year < 2000: if year <= 1991: - name = "Річниця Великої Жовтневої" \ - " соціалістичної революції" + name = "Річниця Великої Жовтневої" " соціалістичної революції" else: name = "Річниця жовтневого перевороту" self[date(year, NOV, 7)] = name @@ -111,8 +107,7 @@ def _populate(self, year): # Christmas Day (Catholic) if year >= 2017: - self[date(year, DEC, 25)] = "Різдво Христове" \ - " (католицьке)" + self[date(year, DEC, 25)] = "Різдво Христове" " (католицьке)" # USSR holidays # Bloody_Sunday_(1905) if 1917 <= year < 1951: diff --git a/holidays/countries/united_arab_emirates.py b/holidays/countries/united_arab_emirates.py index a4f8f7da8..94be2a49e 100644 --- a/holidays/countries/united_arab_emirates.py +++ b/holidays/countries/united_arab_emirates.py @@ -48,7 +48,7 @@ class UnitedArabEmirates(HolidayBase): # Python >= 3.6 def __init__(self, **kwargs): - self.country = 'AE' + self.country = "AE" HolidayBase.__init__(self, **kwargs) def _populate(self, year): @@ -57,7 +57,7 @@ def _populate(self, year): self[date(year, JAN, 1)] = "New Year's Day" # Commemoration Day, since 2015. - if (year >= 2015 and year < 2019): + if year >= 2015 and year < 2019: self[date(year, NOV, 30)] = "Commemoration Day" elif year >= 2019: self[date(year, DEC, 1)] = "Commemoration Day" @@ -72,27 +72,37 @@ def _populate(self, year): # Date is announced each year. Usually stretches along 3 or 4 days, # in some instances prepending/appending a day or two # before/after the official holiday. - dates_obs = {2017: [(JUN, 25)], 2018: [(JUN, 14)], 2019: [(JUN, 3)], - 2020: [(MAY, 24)]} + dates_obs = { + 2017: [(JUN, 25)], + 2018: [(JUN, 14)], + 2019: [(JUN, 3)], + 2020: [(MAY, 24)], + } fitr = "Eid al-Fitr" if year in dates_obs: for date_obs in dates_obs[year]: hol_date = date(year, *date_obs) self[hol_date] = fitr - self[hol_date + rd(days=1)] = '{} Holiday'.format(fitr) - self[hol_date + rd(days=2)] = '{} Holiday'.format(fitr) + self[hol_date + rd(days=1)] = "{} Holiday".format(fitr) + self[hol_date + rd(days=2)] = "{} Holiday".format(fitr) else: for date_obs in get_gre_date(year, 10, 1): hol_date = date_obs - self[hol_date] = '{}* (*estimated)'.format(fitr) - self[hol_date + rd(days=1)] =\ - '{} Holiday* (*estimated)'.format(fitr) - self[hol_date + rd(days=2)] =\ - '{} Holiday* (*estimated)'.format(fitr) + self[hol_date] = "{}* (*estimated)".format(fitr) + self[ + hol_date + rd(days=1) + ] = "{} Holiday* (*estimated)".format(fitr) + self[ + hol_date + rd(days=2) + ] = "{} Holiday* (*estimated)".format(fitr) # Arafat Day & Eid al-Adha - dates_obs = {2017: [(AUG, 31)], 2018: [(AUG, 20)], 2019: [(AUG, 10)], - 2020: [(JUL, 30)]} + dates_obs = { + 2017: [(AUG, 31)], + 2018: [(AUG, 20)], + 2019: [(AUG, 10)], + 2020: [(JUL, 30)], + } hajj = "Arafat (Hajj) Day" adha = "Eid al-Adha" if year in dates_obs: @@ -100,21 +110,27 @@ def _populate(self, year): hol_date = date(year, *date_obs) self[hol_date] = hajj self[hol_date + rd(days=1)] = adha - self[hol_date + rd(days=2)] = '{} Holiday'.format(adha) - self[hol_date + rd(days=3)] = '{} Holiday'.format(adha) + self[hol_date + rd(days=2)] = "{} Holiday".format(adha) + self[hol_date + rd(days=3)] = "{} Holiday".format(adha) else: for date_obs in get_gre_date(year, 12, 9): hol_date = date_obs - self[hol_date] = '{}* (*estimated)'.format(hajj) - self[hol_date + rd(days=1)] = '{}* (*estimated)'.format(adha) - self[hol_date + rd(days=2)] =\ - '{}* Holiday* (*estimated)'.format(adha) - self[hol_date + rd(days=3)] =\ - '{} Holiday* (*estimated)'.format(adha) + self[hol_date] = "{}* (*estimated)".format(hajj) + self[hol_date + rd(days=1)] = "{}* (*estimated)".format(adha) + self[ + hol_date + rd(days=2) + ] = "{}* Holiday* (*estimated)".format(adha) + self[ + hol_date + rd(days=3) + ] = "{} Holiday* (*estimated)".format(adha) # Islamic New Year - (hijari_year, 1, 1) - dates_obs = {2017: [(SEP, 22)], 2018: [(SEP, 11)], 2019: [(AUG, 31)], - 2020: [(AUG, 23)]} + dates_obs = { + 2017: [(SEP, 22)], + 2018: [(SEP, 11)], + 2019: [(AUG, 31)], + 2020: [(AUG, 23)], + } new_hijri_year = "Al Hijra - Islamic New Year" if year in dates_obs: for date_obs in dates_obs[year]: @@ -123,7 +139,7 @@ def _populate(self, year): else: for date_obs in get_gre_date(year, 1, 1): hol_date = date_obs - self[hol_date] = '{}* (*estimated)'.format(new_hijri_year) + self[hol_date] = "{}* (*estimated)".format(new_hijri_year) # Leilat al-Miraj - The Prophet's ascension (hijari_year, 7, 27) if year <= 2018: # starting from 2019 the UAE government removed this @@ -136,12 +152,15 @@ def _populate(self, year): else: for date_obs in get_gre_date(year, 7, 27): hol_date = date_obs - self[hol_date] = '{}* (*estimated)'.format(ascension) + self[hol_date] = "{}* (*estimated)".format(ascension) # Prophet Muhammad's Birthday - (hijari_year, 3, 12) if year <= 2019: # starting from 2020 the UAE government removed this - dates_obs = {2017: [(NOV, 30)], 2018: [(NOV, 19)], - 2019: [(NOV, 9)]} + dates_obs = { + 2017: [(NOV, 30)], + 2018: [(NOV, 19)], + 2019: [(NOV, 9)], + } mawlud = "Mawlud al-Nabi - Prophet Mohammad's Birthday" if year in dates_obs: for date_obs in dates_obs[year]: @@ -150,7 +169,7 @@ def _populate(self, year): else: for date_obs in get_gre_date(year, 3, 12): hol_date = date_obs - self[hol_date] = '{}* (*estimated)'.format(mawlud) + self[hol_date] = "{}* (*estimated)".format(mawlud) class AE(UnitedArabEmirates): diff --git a/holidays/countries/united_kingdom.py b/holidays/countries/united_kingdom.py index 035f2657d..d4d7903b1 100644 --- a/holidays/countries/united_kingdom.py +++ b/holidays/countries/united_kingdom.py @@ -16,8 +16,7 @@ from dateutil.easter import easter from dateutil.relativedelta import relativedelta as rd, MO, FR -from holidays.constants import JAN, MAR, APR, MAY, JUN, JUL, AUG, OCT, \ - NOV, DEC +from holidays.constants import JAN, MAR, APR, MAY, JUN, JUL, AUG, OCT, NOV, DEC from holidays.constants import MON, TUE, WED, THU, FRI, SAT, SUN, WEEKEND from holidays.holiday_base import HolidayBase @@ -29,7 +28,7 @@ class UnitedKingdom(HolidayBase): # Look at _country_specific() method for country specific behavior. def __init__(self, **kwargs): - self.country = 'UK' + self.country = "UK" HolidayBase.__init__(self, **kwargs) def _populate(self, year): @@ -39,62 +38,58 @@ def _populate(self, year): name = "New Year's Day" self[date(year, JAN, 1)] = name if self.observed and date(year, JAN, 1).weekday() == SUN: - self[date(year, JAN, 1) + rd(days=+1)] = name + \ - " (Observed)" - elif self.observed \ - and date(year, JAN, 1).weekday() == SAT: - self[date(year, JAN, 1) + rd(days=+2)] = name + \ - " (Observed)" + self[date(year, JAN, 1) + rd(days=+1)] = name + " (Observed)" + elif self.observed and date(year, JAN, 1).weekday() == SAT: + self[date(year, JAN, 1) + rd(days=+2)] = name + " (Observed)" # New Year Holiday - if self.country in ('UK', 'Scotland'): + if self.country in ("UK", "Scotland"): name = "New Year Holiday" - if self.country == 'UK': + if self.country == "UK": name += " [Scotland]" self[date(year, JAN, 2)] = name if self.observed and date(year, JAN, 2).weekday() in WEEKEND: - self[date(year, JAN, 2) + rd(days=+2)] = name + \ - " (Observed)" + self[date(year, JAN, 2) + rd(days=+2)] = name + " (Observed)" elif self.observed and date(year, JAN, 2).weekday() == MON: - self[date(year, JAN, 2) + rd(days=+1)] = name + \ - " (Observed)" + self[date(year, JAN, 2) + rd(days=+1)] = name + " (Observed)" # St. Patrick's Day - if self.country in ('UK', 'Northern Ireland'): + if self.country in ("UK", "Northern Ireland"): name = "St. Patrick's Day" - if self.country == 'UK': + if self.country == "UK": name += " [Northern Ireland]" self[date(year, MAR, 17)] = name if self.observed and date(year, MAR, 17).weekday() in WEEKEND: - self[date(year, MAR, 17) + rd(weekday=MO)] = name + \ - " (Observed)" + self[date(year, MAR, 17) + rd(weekday=MO)] = ( + name + " (Observed)" + ) # TT bank holiday (first Friday in June) - if self.country == 'Isle of Man': + if self.country == "Isle of Man": self[date(year, JUN, 1) + rd(weekday=FR)] = "TT Bank Holiday" # Tynwald Day - if self.country == 'Isle of Man': + if self.country == "Isle of Man": self[date(year, JUL, 5)] = "Tynwald Day" # Battle of the Boyne - if self.country in ('UK', 'Northern Ireland'): + if self.country in ("UK", "Northern Ireland"): name = "Battle of the Boyne" - if self.country == 'UK': + if self.country == "UK": name += " [Northern Ireland]" self[date(year, JUL, 12)] = name # Summer bank holiday (first Monday in August) - if self.country in ('UK', 'Scotland'): + if self.country in ("UK", "Scotland"): name = "Summer Bank Holiday" - if self.country == 'UK': + if self.country == "UK": name += " [Scotland]" self[date(year, AUG, 1) + rd(weekday=MO)] = name # St. Andrew's Day - if self.country in ('UK', 'Scotland'): + if self.country in ("UK", "Scotland"): name = "St. Andrew's Day" - if self.country == 'UK': + if self.country == "UK": name += " [Scotland]" self[date(year, NOV, 30)] = name @@ -116,9 +111,9 @@ def _country_specific(self, year): self[easter(year) + rd(weekday=FR(-1))] = "Good Friday" # Easter Monday - if self.country != 'Scotland': + if self.country != "Scotland": name = "Easter Monday" - if self.country == 'UK': + if self.country == "UK": name += " [England, Wales, Northern Ireland]" self[easter(year) + rd(weekday=MO)] = name @@ -156,9 +151,9 @@ def _country_specific(self, year): self[date(year, MAY, 31) + rd(weekday=MO(-1))] = name # Late Summer bank holiday (last Monday in August) - if self.country not in ('Scotland') and year >= 1971: + if self.country not in ("Scotland") and year >= 1971: name = "Late Summer Bank Holiday" - if self.country == 'UK': + if self.country == "UK": name += " [England, Wales, Northern Ireland]" self[date(year, AUG, 31) + rd(weekday=MO(-1))] = name @@ -200,35 +195,30 @@ class GBR(UnitedKingdom): class England(UnitedKingdom): - def __init__(self, **kwargs): - self.country = 'England' + self.country = "England" HolidayBase.__init__(self, **kwargs) class Wales(UnitedKingdom): - def __init__(self, **kwargs): - self.country = 'Wales' + self.country = "Wales" HolidayBase.__init__(self, **kwargs) class Scotland(UnitedKingdom): - def __init__(self, **kwargs): - self.country = 'Scotland' + self.country = "Scotland" HolidayBase.__init__(self, **kwargs) class IsleOfMan(UnitedKingdom): - def __init__(self, **kwargs): - self.country = 'Isle of Man' + self.country = "Isle of Man" HolidayBase.__init__(self, **kwargs) class NorthernIreland(UnitedKingdom): - def __init__(self, **kwargs): - self.country = 'Northern Ireland' + self.country = "Northern Ireland" HolidayBase.__init__(self, **kwargs) diff --git a/holidays/countries/united_states.py b/holidays/countries/united_states.py index 0d0786232..fa3a23da2 100644 --- a/holidays/countries/united_states.py +++ b/holidays/countries/united_states.py @@ -16,9 +16,20 @@ from dateutil.easter import easter from dateutil.relativedelta import relativedelta as rd, MO, FR, TH, TU -from holidays.constants import JAN, FEB, MAR, APR, MAY, JUN, JUL, AUG, SEP, \ - OCT, \ - NOV, DEC +from holidays.constants import ( + JAN, + FEB, + MAR, + APR, + MAY, + JUN, + JUL, + AUG, + SEP, + OCT, + NOV, + DEC, +) from holidays.constants import MON, WED, FRI, SAT, SUN, WEEKEND from holidays.holiday_base import HolidayBase @@ -26,15 +37,70 @@ class UnitedStates(HolidayBase): # https://en.wikipedia.org/wiki/Public_holidays_in_the_United_States - STATES = ['AL', 'AK', 'AS', 'AZ', 'AR', 'CA', 'CO', 'CT', 'DE', 'DC', 'FL', - 'GA', 'GU', 'HI', 'ID', 'IL', 'IN', 'IA', 'KS', 'KY', 'LA', 'ME', - 'MD', 'MH', 'MA', 'MI', 'FM', 'MN', 'MS', 'MO', 'MT', 'NE', 'NV', - 'NH', 'NJ', 'NM', 'NY', 'NC', 'ND', 'MP', 'OH', 'OK', 'OR', 'PW', - 'PA', 'PR', 'RI', 'SC', 'SD', 'TN', 'TX', 'UT', 'VT', 'VA', 'VI', - 'WA', 'WV', 'WI', 'WY'] + STATES = [ + "AL", + "AK", + "AS", + "AZ", + "AR", + "CA", + "CO", + "CT", + "DE", + "DC", + "FL", + "GA", + "GU", + "HI", + "ID", + "IL", + "IN", + "IA", + "KS", + "KY", + "LA", + "ME", + "MD", + "MH", + "MA", + "MI", + "FM", + "MN", + "MS", + "MO", + "MT", + "NE", + "NV", + "NH", + "NJ", + "NM", + "NY", + "NC", + "ND", + "MP", + "OH", + "OK", + "OR", + "PW", + "PA", + "PR", + "RI", + "SC", + "SD", + "TN", + "TX", + "UT", + "VT", + "VA", + "VI", + "WA", + "WV", + "WI", + "WY", + ] def __init__(self, **kwargs): - self.country = 'US' + self.country = "US" HolidayBase.__init__(self, **kwargs) def _populate(self, year): @@ -43,16 +109,13 @@ def _populate(self, year): name = "New Year's Day" self[date(year, JAN, 1)] = name if self.observed and date(year, JAN, 1).weekday() == SUN: - self[date(year, JAN, 1) + rd(days=+1)] = name + \ - " (Observed)" - elif self.observed \ - and date(year, JAN, 1).weekday() == SAT: + self[date(year, JAN, 1) + rd(days=+1)] = name + " (Observed)" + elif self.observed and date(year, JAN, 1).weekday() == SAT: # Add Dec 31st from the previous year without triggering # the entire year to be added expand = self.expand self.expand = False - self[date(year, JAN, 1) + rd(days=-1)] = name + \ - " (Observed)" + self[date(year, JAN, 1) + rd(days=-1)] = name + " (Observed)" self.expand = expand # The next year's observed New Year's Day can be in this year # when it falls on a Friday (Jan 1st is a Saturday) @@ -60,26 +123,25 @@ def _populate(self, year): self[date(year, DEC, 31)] = name + " (Observed)" # Epiphany - if self.state == 'PR': + if self.state == "PR": self[date(year, JAN, 6)] = "Epiphany" # Three King's Day - if self.state == 'VI': + if self.state == "VI": self[date(year, JAN, 6)] = "Three King's Day" # Lee Jackson Day name = "Lee Jackson Day" - if self.state == 'VA' and year >= 2000: - dt = date(year, JAN, 1) + rd(weekday=MO(+3)) + rd( - weekday=FR(-1)) + if self.state == "VA" and year >= 2000: + dt = date(year, JAN, 1) + rd(weekday=MO(+3)) + rd(weekday=FR(-1)) self[dt] = name - elif self.state == 'VA' and year >= 1983: + elif self.state == "VA" and year >= 1983: self[date(year, JAN, 1) + rd(weekday=MO(+3))] = name - elif self.state == 'VA' and year >= 1889: + elif self.state == "VA" and year >= 1889: self[date(year, JAN, 19)] = name # Inauguration Day - if self.state in ('DC', 'LA', 'MD', 'VA') and year >= 1789: + if self.state in ("DC", "LA", "MD", "VA") and year >= 1789: name = "Inauguration Day" if (year - 1789) % 4 == 0 and year >= 1937: self[date(year, JAN, 20)] = name @@ -93,96 +155,101 @@ def _populate(self, year): # Martin Luther King Jr. Day if year >= 1986: name = "Martin Luther King Jr. Day" - if self.state == 'AL': + if self.state == "AL": name = "Robert E. Lee/Martin Luther King Birthday" - elif (self.state == 'MS') or ((self.state == 'AR') and - (year <= 2017)): - name = ("Dr. Martin Luther King Jr. " - "and Robert E. Lee's Birthdays") - elif self.state in ('AZ', 'NH'): + elif (self.state == "MS") or ( + (self.state == "AR") and (year <= 2017) + ): + name = ( + "Dr. Martin Luther King Jr. " + "and Robert E. Lee's Birthdays" + ) + elif self.state in ("AZ", "NH"): name = "Dr. Martin Luther King Jr./Civil Rights Day" - elif self.state == 'GA' and year < 2012: + elif self.state == "GA" and year < 2012: name = "Robert E. Lee's Birthday" - elif self.state == 'ID' and year >= 2006: + elif self.state == "ID" and year >= 2006: name = "Martin Luther King Jr. - Idaho Human Rights Day" self[date(year, JAN, 1) + rd(weekday=MO(+3))] = name # Lincoln's Birthday name = "Lincoln's Birthday" - if (self.state in ('CT', 'IL', 'IA', 'NJ', 'NY') and year >= 1971) \ - or (self.state == 'CA' and 1971 <= year <= 2009): + if (self.state in ("CT", "IL", "IA", "NJ", "NY") and year >= 1971) or ( + self.state == "CA" and 1971 <= year <= 2009 + ): self[date(year, FEB, 12)] = name - if self.observed \ - and date(year, FEB, 12).weekday() == SAT: + if self.observed and date(year, FEB, 12).weekday() == SAT: self[date(year, FEB, 11)] = name + " (Observed)" - elif self.observed \ - and date(year, FEB, 12).weekday() == SUN: + elif self.observed and date(year, FEB, 12).weekday() == SUN: self[date(year, FEB, 13)] = name + " (Observed)" # Susan B. Anthony Day - if (self.state == 'CA' and year >= 2014) \ - or (self.state == 'FL' and year >= 2011) \ - or (self.state == 'NY' and year >= 2004) \ - or (self.state == 'WI' and year >= 1976): + if ( + (self.state == "CA" and year >= 2014) + or (self.state == "FL" and year >= 2011) + or (self.state == "NY" and year >= 2004) + or (self.state == "WI" and year >= 1976) + ): self[date(year, FEB, 15)] = "Susan B. Anthony Day" # Washington's Birthday name = "Washington's Birthday" - if self.state == 'AL': + if self.state == "AL": name = "George Washington/Thomas Jefferson Birthday" - elif self.state == 'AR': + elif self.state == "AR": name = "George Washington's Birthday and Daisy Gatson Bates Day" - elif self.state in ('PR', 'VI'): + elif self.state in ("PR", "VI"): name = "Presidents' Day" - if self.state not in ('DE', 'FL', 'GA', 'NM', 'PR'): + if self.state not in ("DE", "FL", "GA", "NM", "PR"): if year > 1970: self[date(year, FEB, 1) + rd(weekday=MO(+3))] = name elif year >= 1879: self[date(year, FEB, 22)] = name - elif self.state == 'GA': + elif self.state == "GA": if date(year, DEC, 24).weekday() != WED: self[date(year, DEC, 24)] = name else: self[date(year, DEC, 26)] = name - elif self.state in ('PR', 'VI'): + elif self.state in ("PR", "VI"): self[date(year, FEB, 1) + rd(weekday=MO(+3))] = name # Mardi Gras - if self.state == 'LA' and year >= 1857: + if self.state == "LA" and year >= 1857: self[easter(year) + rd(days=-47)] = "Mardi Gras" # Guam Discovery Day - if self.state == 'GU' and year >= 1970: + if self.state == "GU" and year >= 1970: self[date(year, MAR, 1) + rd(weekday=MO)] = "Guam Discovery Day" # Casimir Pulaski Day - if self.state == 'IL' and year >= 1978: + if self.state == "IL" and year >= 1978: self[date(year, MAR, 1) + rd(weekday=MO)] = "Casimir Pulaski Day" # Texas Independence Day - if self.state == 'TX' and year >= 1874: + if self.state == "TX" and year >= 1874: self[date(year, MAR, 2)] = "Texas Independence Day" # Town Meeting Day - if self.state == 'VT' and year >= 1800: + if self.state == "VT" and year >= 1800: self[date(year, MAR, 1) + rd(weekday=TU)] = "Town Meeting Day" # Evacuation Day - if self.state == 'MA' and year >= 1901: + if self.state == "MA" and year >= 1901: name = "Evacuation Day" self[date(year, MAR, 17)] = name if date(year, MAR, 17).weekday() in WEEKEND: - self[date(year, MAR, 17) + rd(weekday=MO)] = name + \ - " (Observed)" + self[date(year, MAR, 17) + rd(weekday=MO)] = ( + name + " (Observed)" + ) # Emancipation Day - if self.state == 'PR': + if self.state == "PR": self[date(year, MAR, 22)] = "Emancipation Day" if self.observed and date(year, MAR, 22).weekday() == SUN: self[date(year, MAR, 23)] = "Emancipation Day (Observed)" # Prince Jonah Kuhio Kalanianaole Day - if self.state == 'HI' and year >= 1949: + if self.state == "HI" and year >= 1949: name = "Prince Jonah Kuhio Kalanianaole Day" self[date(year, MAR, 26)] = name if self.observed and date(year, MAR, 26).weekday() == SAT: @@ -192,26 +259,26 @@ def _populate(self, year): # Steward's Day name = "Steward's Day" - if self.state == 'AK' and year >= 1955: + if self.state == "AK" and year >= 1955: self[date(year, APR, 1) + rd(days=-1, weekday=MO(-1))] = name - elif self.state == 'AK' and year >= 1918: + elif self.state == "AK" and year >= 1918: self[date(year, MAR, 30)] = name # César Chávez Day name = "César Chávez Day" - if self.state == 'CA' and year >= 1995: + if self.state == "CA" and year >= 1995: self[date(year, MAR, 31)] = name if self.observed and date(year, MAR, 31).weekday() == SUN: self[date(year, APR, 1)] = name + " (Observed)" - elif self.state == 'TX' and year >= 2000: + elif self.state == "TX" and year >= 2000: self[date(year, MAR, 31)] = name # Transfer Day - if self.state == 'VI': + if self.state == "VI": self[date(year, MAR, 31)] = "Transfer Day" # Emancipation Day - if self.state == 'DC' and year >= 2005: + if self.state == "DC" and year >= 2005: name = "Emancipation Day" self[date(year, APR, 16)] = name if self.observed and date(year, APR, 16).weekday() == SAT: @@ -220,54 +287,67 @@ def _populate(self, year): self[date(year, APR, 17)] = name + " (Observed)" # Patriots' Day - if self.state in ('ME', 'MA') and year >= 1969: + if self.state in ("ME", "MA") and year >= 1969: self[date(year, APR, 1) + rd(weekday=MO(+3))] = "Patriots' Day" - elif self.state in ('ME', 'MA') and year >= 1894: + elif self.state in ("ME", "MA") and year >= 1894: self[date(year, APR, 19)] = "Patriots' Day" # Holy Thursday - if self.state == 'VI': + if self.state == "VI": self[easter(year) + rd(weekday=TH(-1))] = "Holy Thursday" # Good Friday - if self.state in ('CT', 'DE', 'GU', 'IN', 'KY', 'LA', - 'NJ', 'NC', 'PR', 'TN', 'TX', 'VI'): + if self.state in ( + "CT", + "DE", + "GU", + "IN", + "KY", + "LA", + "NJ", + "NC", + "PR", + "TN", + "TX", + "VI", + ): self[easter(year) + rd(weekday=FR(-1))] = "Good Friday" # Easter Monday - if self.state == 'VI': + if self.state == "VI": self[easter(year) + rd(weekday=MO)] = "Easter Monday" # Confederate Memorial Day name = "Confederate Memorial Day" - if self.state in ('AL', 'GA', 'MS', 'SC') and year >= 1866: - if self.state == 'GA' and year >= 2016: + if self.state in ("AL", "GA", "MS", "SC") and year >= 1866: + if self.state == "GA" and year >= 2016: name = "State Holiday" - if self.state == 'GA' and year == 2020: + if self.state == "GA" and year == 2020: self[date(year, APR, 10)] = name else: self[date(year, APR, 1) + rd(weekday=MO(+4))] = name - elif self.state == 'TX' and year >= 1931: + elif self.state == "TX" and year >= 1931: self[date(year, JAN, 19)] = name # San Jacinto Day - if self.state == 'TX' and year >= 1875: + if self.state == "TX" and year >= 1875: self[date(year, APR, 21)] = "San Jacinto Day" # Arbor Day - if self.state == 'NE' and year >= 1989: + if self.state == "NE" and year >= 1989: self[date(year, APR, 30) + rd(weekday=FR(-1))] = "Arbor Day" - elif self.state == 'NE' and year >= 1875: + elif self.state == "NE" and year >= 1875: self[date(year, APR, 22)] = "Arbor Day" # Primary Election Day - if self.state == 'IN' and \ - ((year >= 2006 and year % 2 == 0) or year >= 2015): + if self.state == "IN" and ( + (year >= 2006 and year % 2 == 0) or year >= 2015 + ): dt = date(year, MAY, 1) + rd(weekday=MO) self[dt + rd(days=+1)] = "Primary Election Day" # Truman Day - if self.state == 'MO' and year >= 1949: + if self.state == "MO" and year >= 1949: name = "Truman Day" self[date(year, MAY, 8)] = name if self.observed and date(year, MAY, 8).weekday() == SAT: @@ -283,11 +363,11 @@ def _populate(self, year): # Jefferson Davis Birthday name = "Jefferson Davis Birthday" - if self.state == 'AL' and year >= 1890: + if self.state == "AL" and year >= 1890: self[date(year, JUN, 1) + rd(weekday=MO)] = name # Kamehameha Day - if self.state == 'HI' and year >= 1872: + if self.state == "HI" and year >= 1872: self[date(year, JUN, 11)] = "Kamehameha Day" if self.observed and year >= 2011: if date(year, JUN, 11).weekday() == SAT: @@ -296,12 +376,12 @@ def _populate(self, year): self[date(year, JUN, 12)] = "Kamehameha Day (Observed)" # Emancipation Day In Texas - if self.state == 'TX' and year >= 1980: + if self.state == "TX" and year >= 1980: self[date(year, JUN, 19)] = "Emancipation Day In Texas" # West Virginia Day name = "West Virginia Day" - if self.state == 'WV' and year >= 1927: + if self.state == "WV" and year >= 1927: self[date(year, JUN, 20)] = name if self.observed and date(year, JUN, 20).weekday() == SAT: self[date(year, JUN, 19)] = name + " (Observed)" @@ -309,7 +389,7 @@ def _populate(self, year): self[date(year, JUN, 21)] = name + " (Observed)" # Emancipation Day in US Virgin Islands - if self.state == 'VI': + if self.state == "VI": self[date(year, JUL, 3)] = "Emancipation Day" # Independence Day @@ -322,11 +402,11 @@ def _populate(self, year): self[date(year, JUL, 4) + rd(days=+1)] = name + " (Observed)" # Liberation Day (Guam) - if self.state == 'GU' and year >= 1945: + if self.state == "GU" and year >= 1945: self[date(year, JUL, 21)] = "Liberation Day (Guam)" # Pioneer Day - if self.state == 'UT' and year >= 1849: + if self.state == "UT" and year >= 1849: name = "Pioneer Day" self[date(year, JUL, 24)] = name if self.observed and date(year, JUL, 24).weekday() == SAT: @@ -335,21 +415,21 @@ def _populate(self, year): self[date(year, JUL, 24) + rd(days=+1)] = name + " (Observed)" # Constitution Day - if self.state == 'PR': + if self.state == "PR": self[date(year, JUL, 25)] = "Constitution Day" if self.observed and date(year, JUL, 25).weekday() == SUN: self[date(year, JUL, 26)] = "Constitution Day (Observed)" # Victory Day - if self.state == 'RI' and year >= 1948: + if self.state == "RI" and year >= 1948: self[date(year, AUG, 1) + rd(weekday=MO(+2))] = "Victory Day" # Statehood Day (Hawaii) - if self.state == 'HI' and year >= 1959: + if self.state == "HI" and year >= 1959: self[date(year, AUG, 1) + rd(weekday=FR(+3))] = "Statehood Day" # Bennington Battle Day - if self.state == 'VT' and year >= 1778: + if self.state == "VT" and year >= 1778: name = "Bennington Battle Day" self[date(year, AUG, 16)] = name if self.observed and date(year, AUG, 16).weekday() == SAT: @@ -358,7 +438,7 @@ def _populate(self, year): self[date(year, AUG, 17)] = name + " (Observed)" # Lyndon Baines Johnson Day - if self.state == 'TX' and year >= 1973: + if self.state == "TX" and year >= 1973: self[date(year, AUG, 27)] = "Lyndon Baines Johnson Day" # Labor Day @@ -366,10 +446,10 @@ def _populate(self, year): self[date(year, SEP, 1) + rd(weekday=MO)] = "Labor Day" # Columbus Day - if self.state not in ('AK', 'AR', 'DE', 'FL', 'HI', 'NV'): - if self.state == 'SD': + if self.state not in ("AK", "AR", "DE", "FL", "HI", "NV"): + if self.state == "SD": name = "Native American Day" - elif self.state == 'VI': + elif self.state == "VI": name = "Columbus Day and Puerto Rico Friendship Day" else: name = "Columbus Day" @@ -379,20 +459,16 @@ def _populate(self, year): self[date(year, OCT, 12)] = name # Alaska Day - if self.state == 'AK' and year >= 1867: + if self.state == "AK" and year >= 1867: name = "Alaska Day" self[date(year, OCT, 18)] = name - if self.observed \ - and date(year, OCT, 18).weekday() == SAT: - self[date(year, OCT, 18) + rd(days=-1)] = name + \ - " (Observed)" - elif self.observed \ - and date(year, OCT, 18).weekday() == SUN: - self[date(year, OCT, 18) + rd(days=+1)] = name + \ - " (Observed)" + if self.observed and date(year, OCT, 18).weekday() == SAT: + self[date(year, OCT, 18) + rd(days=-1)] = name + " (Observed)" + elif self.observed and date(year, OCT, 18).weekday() == SUN: + self[date(year, OCT, 18) + rd(days=+1)] = name + " (Observed)" # Nevada Day - if self.state == 'NV' and year >= 1933: + if self.state == "NV" and year >= 1933: dt = date(year, OCT, 31) if year >= 2000: dt += rd(weekday=FR(-1)) @@ -403,19 +479,21 @@ def _populate(self, year): self[dt + rd(days=+1)] = "Nevada Day (Observed)" # Liberty Day - if self.state == 'VI': + if self.state == "VI": self[date(year, NOV, 1)] = "Liberty Day" # Election Day - if (self.state in ('DE', 'HI', 'IL', 'IN', 'LA', - 'MT', 'NH', 'NJ', 'NY', 'WV') and - year >= 2008 and year % 2 == 0) \ - or (self.state in ('IN', 'NY') and year >= 2015): + if ( + self.state + in ("DE", "HI", "IL", "IN", "LA", "MT", "NH", "NJ", "NY", "WV") + and year >= 2008 + and year % 2 == 0 + ) or (self.state in ("IN", "NY") and year >= 2015): dt = date(year, NOV, 1) + rd(weekday=MO) self[dt + rd(days=+1)] = "Election Day" # All Souls' Day - if self.state == 'GU': + if self.state == "GU": self[date(year, NOV, 2)] = "All Souls' Day" # Veterans Day @@ -427,17 +505,13 @@ def _populate(self, year): self[date(year, OCT, 1) + rd(weekday=MO(+4))] = name elif year >= 1938: self[date(year, NOV, 11)] = name - if self.observed \ - and date(year, NOV, 11).weekday() == SAT: - self[date(year, NOV, 11) + rd(days=-1)] = name + \ - " (Observed)" - elif self.observed \ - and date(year, NOV, 11).weekday() == SUN: - self[date(year, NOV, 11) + rd(days=+1)] = name + \ - " (Observed)" + if self.observed and date(year, NOV, 11).weekday() == SAT: + self[date(year, NOV, 11) + rd(days=-1)] = name + " (Observed)" + elif self.observed and date(year, NOV, 11).weekday() == SUN: + self[date(year, NOV, 11) + rd(days=+1)] = name + " (Observed)" # Discovery Day - if self.state == 'PR': + if self.state == "PR": self[date(year, NOV, 19)] = "Discovery Day" if self.observed and date(year, NOV, 19).weekday() == SUN: self[date(year, NOV, 20)] = "Discovery Day (Observed)" @@ -452,28 +526,32 @@ def _populate(self, year): # American Indian Heritage Day # Family Day # New Mexico Presidents' Day - if (self.state in ('CA', 'DE', 'FL', 'NH', 'NC', 'OK', 'TX', 'WV') and - year >= 1975) \ - or (self.state == 'IN' and year >= 2010) \ - or (self.state == 'MD' and year >= 2008) \ - or self.state in ('NV', 'NM'): - if self.state in ('CA', 'DE', 'NH', 'NC', 'OK', 'WV'): + if ( + ( + self.state in ("CA", "DE", "FL", "NH", "NC", "OK", "TX", "WV") + and year >= 1975 + ) + or (self.state == "IN" and year >= 2010) + or (self.state == "MD" and year >= 2008) + or self.state in ("NV", "NM") + ): + if self.state in ("CA", "DE", "NH", "NC", "OK", "WV"): name = "Day After Thanksgiving" - elif self.state in ('FL', 'TX'): + elif self.state in ("FL", "TX"): name = "Friday After Thanksgiving" - elif self.state == 'IN': + elif self.state == "IN": name = "Lincoln's Birthday" - elif self.state == 'MD' and year >= 2008: + elif self.state == "MD" and year >= 2008: name = "American Indian Heritage Day" - elif self.state == 'NV': + elif self.state == "NV": name = "Family Day" - elif self.state == 'NM': + elif self.state == "NM": name = "Presidents' Day" dt = date(year, NOV, 1) + rd(weekday=TH(+4)) self[dt + rd(days=+1)] = name # Robert E. Lee's Birthday - if self.state == 'GA' and year >= 1986: + if self.state == "GA" and year >= 1986: if year >= 2016: name = "State Holiday" else: @@ -481,14 +559,16 @@ def _populate(self, year): self[date(year, NOV, 29) + rd(weekday=FR(-1))] = name # Lady of Camarin Day - if self.state == 'GU': + if self.state == "GU": self[date(year, DEC, 8)] = "Lady of Camarin Day" # Christmas Eve - if self.state == 'AS' or \ - (self.state in ('KS', 'MI', 'NC') and year >= 2013) or \ - (self.state == 'TX' and year >= 1981) or \ - (self.state == 'WI' and year >= 2012): + if ( + self.state == "AS" + or (self.state in ("KS", "MI", "NC") and year >= 2013) + or (self.state == "TX" and year >= 1981) + or (self.state == "WI" and year >= 2012) + ): name = "Christmas Eve" self[date(year, DEC, 24)] = name name = name + " (Observed)" @@ -496,25 +576,20 @@ def _populate(self, year): if self.observed and date(year, DEC, 24).weekday() == FRI: self[date(year, DEC, 24) + rd(days=-1)] = name # If on Saturday or Sunday, observed on Friday - elif self.observed \ - and date(year, DEC, 24).weekday() in WEEKEND: + elif self.observed and date(year, DEC, 24).weekday() in WEEKEND: self[date(year, DEC, 24) + rd(weekday=FR(-1))] = name # Christmas Day if year > 1870: name = "Christmas Day" self[date(year, DEC, 25)] = "Christmas Day" - if self.observed \ - and date(year, DEC, 25).weekday() == SAT: - self[date(year, DEC, 25) + rd(days=-1)] = name + \ - " (Observed)" - elif self.observed \ - and date(year, DEC, 25).weekday() == SUN: - self[date(year, DEC, 25) + rd(days=+1)] = name + \ - " (Observed)" + if self.observed and date(year, DEC, 25).weekday() == SAT: + self[date(year, DEC, 25) + rd(days=-1)] = name + " (Observed)" + elif self.observed and date(year, DEC, 25).weekday() == SUN: + self[date(year, DEC, 25) + rd(days=+1)] = name + " (Observed)" # Day After Christmas - if self.state == 'NC' and year >= 2013: + if self.state == "NC" and year >= 2013: name = "Day After Christmas" self[date(year, DEC, 26)] = name name = name + " (Observed)" @@ -522,21 +597,20 @@ def _populate(self, year): if self.observed and date(year, DEC, 26).weekday() in WEEKEND: self[date(year, DEC, 26) + rd(weekday=MO)] = name # If on Monday, observed on Tuesday - elif self.observed \ - and date(year, DEC, 26).weekday() == MON: + elif self.observed and date(year, DEC, 26).weekday() == MON: self[date(year, DEC, 26) + rd(days=+1)] = name - elif self.state == 'TX' and year >= 1981: + elif self.state == "TX" and year >= 1981: self[date(year, DEC, 26)] = "Day After Christmas" - elif self.state == 'VI': + elif self.state == "VI": self[date(year, DEC, 26)] = "Christmas Second Day" # New Year's Eve - if (self.state in ('KY', 'MI') and year >= 2013) or \ - (self.state == 'WI' and year >= 2012): + if (self.state in ("KY", "MI") and year >= 2013) or ( + self.state == "WI" and year >= 2012 + ): name = "New Year's Eve" self[date(year, DEC, 31)] = name - if self.observed \ - and date(year, DEC, 31).weekday() == SAT: + if self.observed and date(year, DEC, 31).weekday() == SAT: self[date(year, DEC, 30)] = name + " (Observed)" diff --git a/holidays/countries/vietnam.py b/holidays/countries/vietnam.py index edfb0b5c6..dc931a8a1 100644 --- a/holidays/countries/vietnam.py +++ b/holidays/countries/vietnam.py @@ -49,13 +49,14 @@ def _populate(self, year): self[first_date + rd(days=+1)] = name + " observed" # Lunar New Year - name = ["Vietnamese New Year", # index: 0 - "The second day of Tet Holiday", # index: 1 - "The third day of Tet Holiday", # index: 2 - "The forth day of Tet Holiday", # index: 3 - "The fifth day of Tet Holiday", # index: 4 - "Vietnamese New Year's Eve", # index: -1 - ] + name = [ + "Vietnamese New Year", # index: 0 + "The second day of Tet Holiday", # index: 1 + "The third day of Tet Holiday", # index: 2 + "The forth day of Tet Holiday", # index: 3 + "The fifth day of Tet Holiday", # index: 4 + "Vietnamese New Year's Eve", # index: -1 + ] dt = self.get_solar_date(year, 1, 1) new_year_date = date(dt.year, dt.month, dt.day) if self.observed: @@ -91,8 +92,11 @@ def _populate(self, year): # convert lunar calendar date to solar def get_solar_date(self, year, month, day): self.korean_cal.setLunarDate(year, month, day, False) - return date(self.korean_cal.solarYear, self.korean_cal.solarMonth, - self.korean_cal.solarDay) + return date( + self.korean_cal.solarYear, + self.korean_cal.solarMonth, + self.korean_cal.solarDay, + ) class VN(Vietnam): diff --git a/holidays/holiday_base.py b/holidays/holiday_base.py index 83a792686..1ca61fccb 100644 --- a/holidays/holiday_base.py +++ b/holidays/holiday_base.py @@ -20,21 +20,24 @@ class HolidayBase(dict): PROVINCES = [] - def __init__(self, years=[], expand=True, observed=True, - prov=None, state=None): + def __init__( + self, years=[], expand=True, observed=True, prov=None, state=None + ): self.observed = observed self.expand = expand if isinstance(years, int): - years = [years, ] + years = [ + years, + ] self.years = set(years) - if not getattr(self, 'prov', False): + if not getattr(self, "prov", False): self.prov = prov self.state = state for year in list(self.years): self._populate(year) def __setattr__(self, key, value): - if key == 'observed' and len(self) > 0: + if key == "observed" and len(self) > 0: dict.__setattr__(self, key, value) if value is True: # Add (Observed) dates @@ -94,7 +97,7 @@ def __getitem__(self, key): ) if step == 0: - raise ValueError('Step value must not be zero.') + raise ValueError("Step value must not be zero.") date_diff = stop - start if date_diff.days < 0 <= step or date_diff.days >= 0 > step: @@ -104,10 +107,7 @@ def __getitem__(self, key): for delta_days in range(0, date_diff.days, step): day = start + timedelta(days=delta_days) try: - dict.__getitem__( - self, - day - ) + dict.__getitem__(self, day) days_in_range.append(day) except KeyError: pass @@ -116,8 +116,7 @@ def __getitem__(self, key): def __setitem__(self, key, value): if key in self: - if self.get(key).find(value) < 0 \ - and value.find(self.get(key)) < 0: + if self.get(key).find(value) < 0 and value.find(self.get(key)) < 0: value = "%s, %s" % (value, self.get(key)) else: value = self.get(key) @@ -180,8 +179,9 @@ def __add__(self, other): elif not isinstance(other, HolidayBase): raise TypeError() HolidaySum = createHolidaySum(self, other) - country = (getattr(self, 'country', None) or - getattr(other, 'country', None)) + country = getattr(self, "country", None) or getattr( + other, "country", None + ) if self.country and other.country and self.country != other.country: c1 = self.country if not isinstance(c1, list): @@ -190,15 +190,18 @@ def __add__(self, other): if not isinstance(c2, list): c2 = [c2] country = c1 + c2 - prov = getattr(self, 'prov', None) or getattr(other, 'prov', None) + prov = getattr(self, "prov", None) or getattr(other, "prov", None) if self.prov and other.prov and self.prov != other.prov: p1 = self.prov if isinstance(self.prov, list) else [self.prov] p2 = other.prov if isinstance(other.prov, list) else [other.prov] prov = p1 + p2 - return HolidaySum(years=(self.years | other.years), - expand=(self.expand or other.expand), - observed=(self.observed or other.observed), - country=country, prov=prov) + return HolidaySum( + years=(self.years | other.years), + expand=(self.expand or other.expand), + observed=(self.observed or other.observed), + country=country, + prov=prov, + ) def __radd__(self, other): return self.__add__(other) @@ -209,16 +212,15 @@ def _populate(self, year): def createHolidaySum(h1, h2): class HolidaySum(HolidayBase): - def __init__(self, country, **kwargs): self.country = country self.holidays = [] - if getattr(h1, 'holidays', False): + if getattr(h1, "holidays", False): for h in h1.holidays: self.holidays.append(h) else: self.holidays.append(h1) - if getattr(h2, 'holidays', False): + if getattr(h2, "holidays", False): for h in h2.holidays: self.holidays.append(h) else: diff --git a/holidays/utils.py b/holidays/utils.py index 88d1135ea..46a03c168 100755 --- a/holidays/utils.py +++ b/holidays/utils.py @@ -19,18 +19,29 @@ def list_supported_countries(): """List all supported countries incl. their abbreviation.""" - return [name for name, obj in - inspect.getmembers(holidays.countries, inspect.isclass)] + return [ + name + for name, obj in inspect.getmembers( + holidays.countries, inspect.isclass + ) + ] -def CountryHoliday(country, years=[], prov=None, state=None, expand=True, - observed=True): +def CountryHoliday( + country, years=[], prov=None, state=None, expand=True, observed=True +): try: - country_classes = inspect.getmembers(holidays.countries, - inspect.isclass) + country_classes = inspect.getmembers( + holidays.countries, inspect.isclass + ) country = next(obj for name, obj in country_classes if name == country) - country_holiday = country(years=years, prov=prov, state=state, - expand=expand, observed=observed) + country_holiday = country( + years=years, + prov=prov, + state=state, + expand=expand, + observed=observed, + ) except StopIteration: raise KeyError("Country %s not available" % country) return country_holiday @@ -45,8 +56,9 @@ def get_gre_date(year, Hmonth, Hday): requirement). """ Hyear = convert.Gregorian(year, 1, 1).to_hijri().datetuple()[0] - gres = [convert.Hijri(y, Hmonth, Hday).to_gregorian() - for y in range(Hyear - 1, Hyear + 2)] - gre_dates = [date(*gre.datetuple()) - for gre in gres if gre.year == year] + gres = [ + convert.Hijri(y, Hmonth, Hday).to_gregorian() + for y in range(Hyear - 1, Hyear + 2) + ] + gre_dates = [date(*gre.datetuple()) for gre in gres if gre.year == year] return gre_dates diff --git a/pyproject.toml b/pyproject.toml new file mode 100644 index 000000000..cb58c6997 --- /dev/null +++ b/pyproject.toml @@ -0,0 +1,49 @@ +[tool.black] +line-length = 79 +target-version = ['py36', 'py37', 'py38'] +exclude = ''' +/( + \.eggs + | \.git + | \.hg + | \.mypy_cache + | \.tox + | \.venv + | _build + | buck-out + | build + | dist +)/ +''' + +[tool.coverage.run] +branch = true +include = [ + 'tests.py', +] +omit = [ + 'setup.py', + 'holidays/__init__.py', + 'test/*', + 'tests.py', +# comment the above line if you want to see if all tests did run + ] + +[tool.coverage.report] +# Regexes for lines to exclude from consideration +exclude_lines = [ + # Have to re-enable the standard pragma + 'pragma: no cover', + + # Don't complain about missing debug-only code: + 'def __repr__', + 'if self\.debug', + + # Don't complain if tests don't hit defensive assertion code: + 'raise AssertionError', + 'raise NotImplementedError', + + # Don't complain if non-runnable code isn't run: + 'if 0:', + 'if __name__ == .__main__.:', +] diff --git a/requirements_dev.txt b/requirements_dev.txt new file mode 100644 index 000000000..50aa78a8d --- /dev/null +++ b/requirements_dev.txt @@ -0,0 +1,18 @@ +# package runtime requirements +python-dateutil +six +convertdate>=2.3.0 +korean_lunar_calendar +hijri_converter + +# test requirements +pytest +pytest-cov +coverage[toml] +pre-commit +flake8 + +#deployment +pip>=19.2.3 +bump2version +wheel>=0.33.6 diff --git a/setup.cfg b/setup.cfg new file mode 100644 index 000000000..a7b836196 --- /dev/null +++ b/setup.cfg @@ -0,0 +1,21 @@ +[bumpversion] +current_version = 0.10.5.3 +commit = True +tag = True + +[bumpversion:file:setup.py] +search = version='{current_version}', +replace = version='{new_version}', + +[bumpversion:file:holidays/__init__.py] +search = __version__ = '{current_version}' +replace = __version__ = '{new_version}' + +[flake8] +extend-ignore = E203,F401,W503,W504 +exclude = __init__.py,*.pyc,tests.py +paths = ./holidays/ ./tests/ + +[rstcheck] +# This is needed since the comments in 'More Examples' make it invalid python code +ignore_language = python diff --git a/setup.py b/setup.py index 7a66c22cc..7d0b56b8b 100644 --- a/setup.py +++ b/setup.py @@ -1,3 +1,4 @@ +# -*- coding: utf-8 -*- # python-holidays # --------------- # A fast, efficient Python library for generating country, province and state @@ -11,49 +12,56 @@ import codecs import re + try: from setuptools import setup except ImportError: from distutils.core import setup -with codecs.open('holidays/__init__.py', 'r', 'utf-8') as fd: - version = re.search(r'^__version__\s*=\s*[\'"]([^\'"]*)[\'"]', - fd.read(), re.MULTILINE).group(1) +with codecs.open("holidays/__init__.py", "r", "utf-8") as fd: + version = re.search( + r'^__version__\s*=\s*[\'"]([^\'"]*)[\'"]', fd.read(), re.MULTILINE + ).group(1) if not version: - raise RuntimeError('Cannot find version information') + raise RuntimeError("Cannot find version information") setup( - name='holidays', + name="holidays", version=version, - author='ryanss', - author_email='ryanssdev@icloud.com', - maintainer='dr-prodigy', - maintainer_email='maurizio.montel@gmail.com', - url='https://github.com/dr-prodigy/python-holidays', - packages=['holidays', 'holidays/countries'], - license='MIT', - description='Generate and work with holidays in Python', - long_description=codecs.open('README.rst', encoding='utf-8').read(), - install_requires=['python-dateutil', 'six', 'convertdate>=2.3.0', - 'korean_lunar_calendar', 'hijri_converter'], - platforms='any', + author="ryanss", + author_email="ryanssdev@icloud.com", + maintainer="dr-prodigy", + maintainer_email="maurizio.montel@gmail.com", + url="https://github.com/dr-prodigy/python-holidays", + packages=["holidays", "holidays/countries"], + license="MIT", + description="Generate and work with holidays in Python", + long_description=codecs.open("README.rst", encoding="utf-8").read(), + install_requires=[ + "python-dateutil", + "six", + "convertdate>=2.3.0", + "korean_lunar_calendar", + "hijri_converter", + ], + platforms="any", classifiers=[ - 'Development Status :: 4 - Beta', - 'Intended Audience :: Developers', - 'License :: OSI Approved :: MIT License', - 'Operating System :: OS Independent', - 'Programming Language :: Python', - 'Programming Language :: Python :: 3', - 'Programming Language :: Python :: 3.6', - 'Programming Language :: Python :: 3.7', - 'Programming Language :: Python :: 3.8', - 'Programming Language :: Python :: 3.9', - 'Programming Language :: Python :: Implementation :: CPython', - 'Programming Language :: Python :: Implementation :: PyPy', - 'Topic :: Office/Business :: Scheduling', - 'Topic :: Software Development :: Libraries :: Python Modules', - 'Topic :: Software Development :: Localization', + "Development Status :: 4 - Beta", + "Intended Audience :: Developers", + "License :: OSI Approved :: MIT License", + "Operating System :: OS Independent", + "Programming Language :: Python", + "Programming Language :: Python :: 3", + "Programming Language :: Python :: 3.6", + "Programming Language :: Python :: 3.7", + "Programming Language :: Python :: 3.8", + "Programming Language :: Python :: 3.9", + "Programming Language :: Python :: Implementation :: CPython", + "Programming Language :: Python :: Implementation :: PyPy", + "Topic :: Office/Business :: Scheduling", + "Topic :: Software Development :: Libraries :: Python Modules", + "Topic :: Software Development :: Localization", ], ) diff --git a/test/__init__.py b/test/__init__.py new file mode 100644 index 000000000..b03717273 --- /dev/null +++ b/test/__init__.py @@ -0,0 +1,13 @@ +# -*- coding: utf-8 -*- + +# python-holidays +# --------------- +# A fast, efficient Python library for generating country, province and state +# specific sets of holidays on the fly. It aims to make determining whether a +# specific date is a holiday as fast and flexible as possible. +# +# Author: ryanss (c) 2014-2017 +# dr-prodigy (c) 2017-2021 +# Website: https://github.com/dr-prodigy/python-holidays +# License: MIT (see LICENSE file) +from test.countries import * diff --git a/test/countries/__init__.py b/test/countries/__init__.py new file mode 100644 index 000000000..23cc25320 --- /dev/null +++ b/test/countries/__init__.py @@ -0,0 +1,82 @@ +# -*- coding: utf-8 -*- + +# python-holidays +# --------------- +# A fast, efficient Python library for generating country, province and state +# specific sets of holidays on the fly. It aims to make determining whether a +# specific date is a holiday as fast and flexible as possible. +# +# Author: ryanss (c) 2014-2017 +# dr-prodigy (c) 2017-2021 +# Website: https://github.com/dr-prodigy/python-holidays +# License: MIT (see LICENSE file) +from .test_angola import * +from .test_argentina import * +from .test_aruba import * +from .test_australia import * +from .test_austria import * +from .test_bangladesh import * +from .test_belarus import * +from .test_belgium import * +from .test_brazil import * +from .test_bulgaria import * +from .test_burundi import * +from .test_canada import * +from .test_chile import * +from .test_colombia import * +from .test_croatia import * +from .test_czechia import * +from .test_denmark import * +from .test_djibouti import * +from .test_dominican_republic import * +from .test_egypt import * +from .test_estonia import * +from .test_european_central_bank import * +from .test_finland import * +from .test_france import * +from .test_germany import * +from .test_greece import * +from .test_honduras import * +from .test_hongkong import * +from .test_hungary import * +from .test_iceland import * +from .test_india import * +from .test_ireland import * +from .test_israel import * +from .test_italy import * +from .test_japan import * +from .test_kenya import * +from .test_korea import * +from .test_latvia import * +from .test_lithuania import * +from .test_luxembourg import * +from .test_malawi import * +from .test_mexico import * +from .test_morocco import * +from .test_mozambique import * +from .test_netherlands import * +from .test_new_zealand import * +from .test_nicaragua import * +from .test_nigeria import * +from .test_norway import * +from .test_paraguay import * +from .test_peru import * +from .test_poland import * +from .test_portugal import * +from .test_romania import * +from .test_russia import * +from .test_saudi_arabia import * +from .test_serbia import * +from .test_singapore import * +from .test_slovakia import * +from .test_slovenia import * +from .test_south_africa import * +from .test_spain import * +from .test_sweden import * +from .test_switzerland import * +from .test_turkey import * +from .test_ukraine import * +from .test_united_arab_emirates import * +from .test_united_kingdom import * +from .test_united_states import * +from .test_vietnam import * diff --git a/test/countries/test_angola.py b/test/countries/test_angola.py new file mode 100644 index 000000000..b59cb9602 --- /dev/null +++ b/test/countries/test_angola.py @@ -0,0 +1,48 @@ +# -*- coding: utf-8 -*- + +# python-holidays +# --------------- +# A fast, efficient Python library for generating country, province and state +# specific sets of holidays on the fly. It aims to make determining whether a +# specific date is a holiday as fast and flexible as possible. +# +# Author: ryanss (c) 2014-2017 +# dr-prodigy (c) 2017-2021 +# Website: https://github.com/dr-prodigy/python-holidays +# License: MIT (see LICENSE file) + +import unittest + +from datetime import date + +import holidays + + +class TestAngola(unittest.TestCase): + def setUp(self): + self.holidays = holidays.AO() + + def test_new_years(self): + self.assertIn("1975-01-01", self.holidays) + self.assertIn("2017-01-01", self.holidays) + self.assertIn("2999-01-01", self.holidays) + self.assertIn("2017-01-02", self.holidays) # sunday + + def test_easter(self): + self.assertIn(date(2017, 4, 14), self.holidays) + self.assertIn(date(2020, 4, 10), self.holidays) + self.assertIn(date(1994, 4, 1), self.holidays) + + def test_static(self): + self.assertIn("2004-03-08", self.holidays) + self.assertIn("2020-03-23", self.holidays) + + def test_long_weekend(self): + self.assertIn("2020-02-03", self.holidays) + self.assertIn("2019-04-05", self.holidays) + self.assertIn("2050-03-07", self.holidays) + + def test_not_holiday(self): + self.assertNotIn("2016-12-28", self.holidays) + self.assertNotIn("2015-03-02", self.holidays) + self.assertNotIn("2018-03-23", self.holidays) diff --git a/test/countries/test_argentina.py b/test/countries/test_argentina.py new file mode 100644 index 000000000..183879d95 --- /dev/null +++ b/test/countries/test_argentina.py @@ -0,0 +1,171 @@ +# -*- coding: utf-8 -*- + +# python-holidays +# --------------- +# A fast, efficient Python library for generating country, province and state +# specific sets of holidays on the fly. It aims to make determining whether a +# specific date is a holiday as fast and flexible as possible. +# +# Author: ryanss (c) 2014-2017 +# dr-prodigy (c) 2017-2021 +# Website: https://github.com/dr-prodigy/python-holidays +# License: MIT (see LICENSE file) + +import unittest + +from datetime import date +from dateutil.relativedelta import relativedelta + +import holidays + + +class TestAR(unittest.TestCase): + def setUp(self): + self.holidays = holidays.AR(observed=True) + + def test_new_years(self): + self.holidays.observed = False + self.assertNotIn(date(2010, 12, 31), self.holidays) + self.assertNotIn(date(2017, 1, 2), self.holidays) + self.holidays.observed = True + self.assertIn(date(2017, 1, 1), self.holidays) + for year in range(1900, 2100): + dt = date(year, 1, 1) + self.assertIn(dt, self.holidays) + self.assertNotIn(dt + relativedelta(days=-1), self.holidays) + self.assertNotIn(dt + relativedelta(days=+1), self.holidays) + + def test_carnival_day(self): + for dt in [ + date(2018, 2, 12), + date(2018, 2, 13), + date(2017, 2, 27), + date(2017, 2, 28), + date(2016, 2, 8), + date(2016, 2, 9), + ]: + self.assertIn(dt, self.holidays) + + def test_memory_national_day(self): + self.holidays.observed = False + self.assertNotIn(date(1907, 3, 24), self.holidays) + self.assertNotIn(date(2002, 3, 24), self.holidays) + self.holidays.observed = True + for dt in [date(2018, 3, 24), date(2017, 3, 24), date(2016, 3, 24)]: + self.assertIn(dt, self.holidays) + + def test_holy_week_day(self): + for dt in [ + date(2018, 3, 29), + date(2018, 3, 30), + date(2017, 4, 13), + date(2017, 4, 14), + date(2016, 3, 24), + date(2016, 3, 25), + ]: + self.assertIn(dt, self.holidays) + + def test_malvinas_war_day(self): + for year in range(1900, 2100): + dt = date(year, 4, 2) + self.assertIn(dt, self.holidays) + + def test_labor_day(self): + self.holidays.observed = False + self.assertNotIn(date(2010, 4, 30), self.holidays) + self.assertNotIn(date(2011, 5, 2), self.holidays) + self.holidays.observed = True + self.assertIn(date(1922, 5, 1), self.holidays) + for year in range(1900, 2100): + dt = date(year, 5, 1) + self.assertIn(dt, self.holidays) + self.assertNotIn(dt + relativedelta(days=-1), self.holidays) + self.assertNotIn(dt + relativedelta(days=+1), self.holidays) + + def test_may_revolution_day(self): + self.holidays.observed = False + self.assertNotIn(date(1930, 5, 25), self.holidays) + self.assertNotIn(date(2014, 5, 25), self.holidays) + self.holidays.observed = True + for year in range(1900, 2100): + dt = date(year, 5, 1) + self.assertIn(dt, self.holidays) + self.assertNotIn(dt + relativedelta(days=-1), self.holidays) + self.assertNotIn(dt + relativedelta(days=+1), self.holidays) + + def test_guemes_day(self): + for year in range(1900, 2100): + dt = date(year, 6, 17) + self.assertIn(dt, self.holidays) + self.assertNotIn(dt + relativedelta(days=-1), self.holidays) + self.assertNotIn(dt + relativedelta(days=+1), self.holidays) + + def test_belgrano_day(self): + for year in range(1900, 2100): + dt = date(year, 6, 20) + self.assertIn(dt, self.holidays) + self.assertNotIn(dt + relativedelta(days=-1), self.holidays) + self.assertNotIn(dt + relativedelta(days=+1), self.holidays) + + def test_independence_day(self): + self.holidays.observed = False + self.assertNotIn(date(2017, 7, 9), self.holidays) + self.assertNotIn(date(2011, 7, 9), self.holidays) + self.holidays.observed = True + self.assertIn(date(2017, 7, 9), self.holidays) + self.assertIn(date(2011, 7, 9), self.holidays) + for year in range(1900, 2100): + dt = date(year, 7, 9) + self.assertIn(dt, self.holidays) + self.assertNotIn(dt + relativedelta(days=-1), self.holidays) + self.assertNotIn(dt + relativedelta(days=+1), self.holidays) + + def test_san_martin_day(self): + self.holidays.observed = False + self.assertNotIn(date(1930, 8, 10), self.holidays) + self.assertNotIn(date(2008, 8, 10), self.holidays) + self.holidays.observed = True + for year in range(1900, 2100): + dt = date(year, 8, 17) + self.assertIn(dt, self.holidays) + self.assertNotIn(dt + relativedelta(days=-1), self.holidays) + self.assertNotIn(dt + relativedelta(days=+1), self.holidays) + + def test_cultural_day(self): + self.holidays.observed = False + self.assertNotIn(date(2014, 10, 12), self.holidays) + self.assertNotIn(date(1913, 10, 12), self.holidays) + self.holidays.observed = True + for year in range(1900, 2100): + dt = date(year, 10, 12) + self.assertIn(dt, self.holidays) + self.assertNotIn(dt + relativedelta(days=-1), self.holidays) + self.assertNotIn(dt + relativedelta(days=+1), self.holidays) + + def test_national_sovereignty_day(self): + for year in range(1900, 2100): + dt = date(year, 11, 20) + if year < 2010: + self.assertNotIn(dt, self.holidays) + else: + self.assertIn(dt, self.holidays) + self.assertNotIn(dt + relativedelta(days=-1), self.holidays) + self.assertNotIn(dt + relativedelta(days=+1), self.holidays) + + def test_inmaculate_conception_day(self): + self.holidays.observed = False + self.assertNotIn(date(1940, 12, 8), self.holidays) + self.assertNotIn(date(2013, 12, 8), self.holidays) + self.holidays.observed = True + for year in range(1900, 2100): + dt = date(year, 12, 8) + self.assertIn(dt, self.holidays) + self.assertNotIn(dt + relativedelta(days=-1), self.holidays) + self.assertNotIn(dt + relativedelta(days=+1), self.holidays) + + def test_christmas(self): + for year in range(1900, 2100): + dt = date(year, 12, 25) + self.assertIn(dt, self.holidays) + self.assertNotIn(dt + relativedelta(days=-1), self.holidays) + self.assertNotIn(dt + relativedelta(days=+1), self.holidays) diff --git a/test/countries/test_aruba.py b/test/countries/test_aruba.py new file mode 100644 index 000000000..74bceef68 --- /dev/null +++ b/test/countries/test_aruba.py @@ -0,0 +1,103 @@ +# -*- coding: utf-8 -*- + +# python-holidays +# --------------- +# A fast, efficient Python library for generating country, province and state +# specific sets of holidays on the fly. It aims to make determining whether a +# specific date is a holiday as fast and flexible as possible. +# +# Author: ryanss (c) 2014-2017 +# dr-prodigy (c) 2017-2021 +# Website: https://github.com/dr-prodigy/python-holidays +# License: MIT (see LICENSE file) + +import unittest + +from datetime import date + +import holidays + + +class TestAruba(unittest.TestCase): + def setUp(self): + self.holidays = holidays.AW() + + def test_2017(self): + self.assertIn(date(2017, 1, 1), self.holidays) + self.assertIn(date(2017, 1, 25), self.holidays) + self.assertIn(date(2017, 3, 18), self.holidays) + self.assertIn(date(2017, 2, 27), self.holidays) + self.assertIn(date(2017, 4, 14), self.holidays) + self.assertIn(date(2017, 4, 17), self.holidays) + self.assertIn(date(2017, 4, 27), self.holidays) + self.assertIn(date(2017, 5, 1), self.holidays) + self.assertIn(date(2017, 5, 25), self.holidays) + self.assertIn(date(2017, 12, 25), self.holidays) + self.assertIn(date(2017, 12, 26), self.holidays) + + def test_new_years(self): + self.assertIn(date(2017, 1, 1), self.holidays) + + def test_betico_day(self): + self.assertIn(date(2017, 1, 25), self.holidays) + + def test_carnaval_monday(self): + self.assertIn(date(2017, 2, 27), self.holidays) + + def test_anthem_and_flag_day(self): + self.assertIn(date(2017, 3, 18), self.holidays) + + def test_good_friday(self): + self.assertIn(date(2017, 4, 14), self.holidays) + + def test_easter_monday(self): + self.assertIn(date(2017, 4, 17), self.holidays) + + def test_labour_day(self): + self.assertIn(date(2017, 5, 1), self.holidays) + + def test_queens_day_between_1891_and_1948(self): + # Between 1891 and 1948 Queens Day was celebrated on 8-31 + self.holidays = holidays.AW(years=[1901]) + self.assertIn(date(1901, 8, 31), self.holidays) + + def test_queens_day_between_1891_and_1948_substituted_later(self): + # Between 1891 and 1948 Queens Day was celebrated on 9-1 + # (one day later) when Queens Day falls on a Sunday + self.holidays = holidays.AW(years=[1947]) + self.assertIn(date(1947, 9, 1), self.holidays) + + def test_queens_day_between_1949_and_2013(self): + self.holidays = holidays.AW(years=[1965]) + self.assertIn(date(1965, 4, 30), self.holidays) + + def test_queens_day_between_1949_and_1980_substituted_later(self): + self.holidays = holidays.AW(years=[1967]) + self.assertIn(date(1967, 5, 1), self.holidays) + + def test_queens_day_between_1980_and_2013_substituted_earlier(self): + self.holidays = holidays.AW(years=[2006]) + self.assertIn(date(2006, 4, 29), self.holidays) + + def test_kings_day_after_2014(self): + self.holidays = holidays.AW(years=[2013]) + self.assertNotIn(date(2013, 4, 27), self.holidays) + + self.holidays = holidays.AW(years=[2017]) + self.assertIn(date(2017, 4, 27), self.holidays) + + def test_kings_day_after_2014_substituted_earlier(self): + self.holidays = holidays.AW(years=[2188]) + self.assertIn(date(2188, 4, 26), self.holidays) + + def test_ascension_day(self): + self.holidays = holidays.AW(years=2017) + self.assertIn(date(2017, 5, 25), self.holidays) + + def test_christmas(self): + self.holidays = holidays.AW(years=2017) + self.assertIn(date(2017, 12, 25), self.holidays) + + def test_second_christmas(self): + self.holidays = holidays.AW(years=2017) + self.assertIn(date(2017, 12, 26), self.holidays) diff --git a/test/countries/test_australia.py b/test/countries/test_australia.py new file mode 100644 index 000000000..87bab93d4 --- /dev/null +++ b/test/countries/test_australia.py @@ -0,0 +1,413 @@ +# -*- coding: utf-8 -*- + +# python-holidays +# --------------- +# A fast, efficient Python library for generating country, province and state +# specific sets of holidays on the fly. It aims to make determining whether a +# specific date is a holiday as fast and flexible as possible. +# +# Author: ryanss (c) 2014-2017 +# dr-prodigy (c) 2017-2021 +# Website: https://github.com/dr-prodigy/python-holidays +# License: MIT (see LICENSE file) + +import unittest + +from datetime import date +from dateutil.relativedelta import relativedelta + +import holidays + + +class TestAU(unittest.TestCase): + def setUp(self): + self.holidays = holidays.AU(observed=True) + self.state_hols = { + state: holidays.AU(observed=True, prov=state) + for state in holidays.AU.PROVINCES + } + + def test_new_years(self): + for year in range(1900, 2100): + dt = date(year, 1, 1) + self.assertIn(dt, self.holidays) + for year, day in enumerate( + [3, 2, 1, 1, 1, 1, 2, 1, 1, 1, 1], 2011 # 2011-15 # 2016-21 + ): + dt = date(year, 1, day) + for state, hols in self.state_hols.items(): + self.assertIn(dt, hols, (state, dt)) + self.assertEqual(hols[dt][:10], "New Year's", state) + + def test_australia_day(self): + for year, day in enumerate( + [26, 26, 28, 27, 26, 26, 26, 26, 28, 27, 26], + 2011, # 2011-15 # 2016-21 + ): + jan26 = date(year, 1, 26) + dt = date(year, 1, day) + self.assertIn(jan26, self.holidays, dt) + self.assertEqual(self.holidays[jan26], "Australia Day") + self.assertIn(dt, self.holidays, dt) + self.assertEqual(self.holidays[dt][:10], "Australia ") + for state in holidays.AU.PROVINCES: + self.assertIn(jan26, self.state_hols[state], (state, dt)) + self.assertEqual( + self.state_hols[state][jan26], "Australia Day" + ) + self.assertIn(dt, self.state_hols[state], (state, dt)) + self.assertEqual(self.state_hols[state][dt][:10], "Australia ") + self.assertNotIn(date(2016, 1, 27), self.holidays) + self.assertNotIn(date(1887, 1, 26), self.holidays) + self.assertNotIn(date(1934, 1, 26), self.state_hols["SA"]) + for dt in [date(1889, 1, 26), date(1936, 1, 26), date(1945, 1, 26)]: + self.assertIn(dt, self.state_hols["NSW"], dt) + self.assertEqual(self.state_hols["NSW"][dt], "Anniversary Day") + + def test_good_friday(self): + 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.assertIn(dt, self.holidays) + self.assertEqual(self.holidays[dt], "Good Friday") + + def test_easter_saturday(self): + for dt in [ + date(1900, 4, 14), + date(1901, 4, 6), + date(1902, 3, 29), + date(1999, 4, 3), + date(2000, 4, 22), + date(2010, 4, 3), + date(2018, 3, 31), + date(2019, 4, 20), + date(2020, 4, 11), + ]: + for state in ["ACT", "NSW", "NT", "QLD", "SA", "VIC"]: + self.assertIn(dt, self.state_hols[state], (state, dt)) + self.assertEqual(self.state_hols[state][dt], "Easter Saturday") + for state in ["TAS", "WA"]: + self.assertNotIn(dt, self.state_hols[state], (state, dt)) + + def test_easter_sunday(self): + for dt in [ + date(1900, 4, 15), + date(1901, 4, 7), + date(1902, 3, 30), + date(1999, 4, 4), + date(2010, 4, 4), + date(2018, 4, 1), + date(2019, 4, 21), + date(2020, 4, 12), + ]: + for state in ["NSW", "ACT", "QLD", "VIC"]: + self.assertIn(dt, self.state_hols[state], (state, dt)) + self.assertEqual(self.state_hols[state][dt], "Easter Sunday") + for state in ["NT", "SA", "TAS", "WA"]: + self.assertNotIn(dt, self.state_hols[state], (state, dt)) + + def test_easter_monday(self): + for dt in [ + date(1900, 4, 16), + date(1901, 4, 8), + date(1902, 3, 31), + date(1999, 4, 5), + date(2010, 4, 5), + date(2018, 4, 2), + date(2019, 4, 22), + date(2020, 4, 13), + ]: + self.assertIn(dt, self.holidays) + self.assertEqual(self.holidays[dt], "Easter Monday") + self.assertNotIn(dt + relativedelta(days=+1), self.holidays) + + def test_bank_holiday(self): + for dt in [ + date(1912, 8, 5), + date(1913, 8, 4), + date(1999, 8, 2), + date(2018, 8, 6), + date(2020, 8, 3), + ]: + self.assertIn(dt, self.state_hols["NSW"], dt) + self.assertEqual(self.state_hols["NSW"][dt], "Bank Holiday") + + def test_labour_day(self): + for year, day in enumerate( + [ + 7, + 5, + 4, + 3, + 2, + 7, + 6, + ], + 2011, + ): + dt = date(year, 3, day) + self.assertIn(dt, self.state_hols["WA"], dt) + self.assertEqual(self.state_hols["WA"][dt], "Labour Day") + for year, day in enumerate([10, 9, 14], 2014): + dt = date(year, 3, day) + self.assertNotIn(dt, self.holidays, dt) + self.assertIn(dt, self.state_hols["VIC"], dt) + self.assertEqual(self.state_hols["VIC"][dt], "Labour Day") + + def test_anzac_day(self): + for year in range(1900, 1921): + dt = date(year, 4, 25) + self.assertNotIn(dt, self.holidays) + for year in range(1921, 2100): + dt = date(year, 4, 25) + self.assertIn(dt, self.holidays) + for dt in [date(2015, 4, 27), date(2020, 4, 27)]: + self.assertNotIn(dt, self.holidays, dt) + for state in ["NT", "WA"]: + self.assertIn(dt, self.state_hols[state], (state, dt)) + self.assertEqual(self.state_hols[state][dt][:5], "Anzac") + for state in ["ACT", "QLD", "SA", "NSW", "TAS", "VIC"]: + self.assertNotIn(dt, self.state_hols[state], (state, dt)) + dt = date(2021, 4, 26) + for state in ["ACT", "NT", "QLD", "SA", "WA"]: + self.assertIn(dt, self.state_hols[state], (state, dt)) + self.assertEqual(self.state_hols[state][dt][:5], "Anzac") + for state in ["NSW", "TAS", "VIC"]: + self.assertNotIn(dt, self.state_hols[state], (state, dt)) + + def test_western_australia_day(self): + for year, day in enumerate([4, 3, 2], 2012): + dt = date(year, 6, day) + self.assertIn(dt, self.state_hols["WA"], dt) + self.assertEqual(self.state_hols["WA"][dt], "Foundation Day") + for year, day in enumerate([1, 6, 5], 2015): + dt = date(year, 6, day) + self.assertIn(dt, self.state_hols["WA"], dt) + self.assertEqual( + self.state_hols["WA"][dt], "Western Australia Day" + ) + + def test_adelaide_cup(self): + for dt in [date(2015, 3, 9), date(2016, 3, 14), date(2017, 3, 13)]: + self.assertIn(dt, self.state_hols["SA"], dt) + self.assertEqual(self.state_hols["SA"][dt], "Adelaide Cup") + + def test_queens_birthday(self): + # Western Australia + for dt in [ + date(2012, 10, 1), + date(2013, 9, 30), + date(2014, 9, 29), + date(2015, 9, 28), + date(2016, 9, 26), + date(2017, 9, 25), + ]: + self.assertIn(dt, self.state_hols["WA"], dt) + self.assertEqual(self.state_hols["WA"][dt], "Queen's Birthday") + # Other states except Queensland + other_states = [ + date(2010, 6, 14), + date(2011, 6, 13), + date(2012, 6, 11), + date(2013, 6, 10), + date(2014, 6, 9), + date(2015, 6, 8), + date(2016, 6, 13), + date(2017, 6, 12), + date(2018, 6, 11), + ] + for dt in other_states: + self.assertIn(dt, self.state_hols["NSW"], dt) + self.assertIn(dt, self.state_hols["VIC"], dt) + self.assertIn(dt, self.state_hols["ACT"], dt) + # Queensland + qld_dates = other_states[:-3] + qld_dates.remove(date(2012, 6, 11)) + qld_dates.extend( + [ + date(2012, 10, 1), + date(2016, 10, 3), + date(2017, 10, 2), + date(2018, 10, 1), + ] + ) + for dt in qld_dates: + self.assertIn(dt, self.state_hols["QLD"], dt) + self.assertEqual(self.state_hols["QLD"][dt], "Queen's Birthday") + self.assertIn(date(2012, 6, 11), self.state_hols["QLD"]) + + def test_picnic_day(self): + for dt in [date(2015, 8, 3), date(2016, 8, 1)]: + self.assertIn(dt, self.state_hols["NT"], dt) + self.assertEqual(self.state_hols["NT"][dt], "Picnic Day") + + def test_family_and_community_day(self): + for dt in [ + date(2007, 11, 6), + date(2008, 11, 4), + date(2009, 11, 3), + date(2010, 9, 26), + date(2011, 10, 10), + date(2012, 10, 8), + date(2013, 9, 30), + date(2014, 9, 29), + date(2015, 9, 28), + date(2016, 9, 26), + date(2017, 9, 25), + ]: + self.assertIn(dt, self.state_hols["ACT"], dt) + self.assertEqual( + self.state_hols["ACT"][dt], "Family & Community Day" + ) + + def test_reconciliation_day(self): + for dt in [date(2018, 5, 28), date(2019, 5, 27), date(2020, 6, 1)]: + self.assertIn(dt, self.state_hols["ACT"], dt) + self.assertEqual(self.state_hols["ACT"][dt], "Reconciliation Day") + + def test_grand_final_day(self): + dt = date(2019, 9, 27) + dt_2020 = date(2020, 10, 23) + dt_2020_old = date(2020, 9, 25) + self.assertIn(dt, self.state_hols["VIC"], dt) + self.assertEqual(self.state_hols["VIC"][dt], "Grand Final Day") + self.assertIn(dt_2020, self.state_hols["VIC"], dt_2020) + self.assertEqual(self.state_hols["VIC"][dt_2020], "Grand Final Day") + self.assertNotIn(dt_2020_old, self.state_hols["VIC"], dt_2020_old) + + def test_melbourne_cup(self): + for dt in [date(2014, 11, 4), date(2015, 11, 3), date(2016, 11, 1)]: + self.assertIn(dt, self.state_hols["VIC"], dt) + self.assertEqual(self.state_hols["VIC"][dt], "Melbourne Cup") + + def test_royal_queensland_show(self): + for year, day in enumerate([15, 14, 14, 11, 10, 16], 2018): + dt = date(year, 8, day) + self.assertIn(dt, self.state_hols["QLD"], dt) + self.assertEqual( + self.state_hols["QLD"][dt], "The Royal Queensland Show" + ) + + def test_christmas_day(self): + self.holidays.observed = False + for year in range(1900, 2100): + dt = date(year, 12, 25) + self.assertIn(dt, self.holidays) + self.assertNotIn(dt + relativedelta(days=-1), self.holidays) + self.assertNotIn(date(2010, 12, 24), self.holidays) + self.assertNotEqual( + self.holidays[date(2011, 12, 26)], "Christmas Day (Observed)" + ) + self.holidays.observed = True + self.assertEqual( + self.holidays[date(2011, 12, 27)], "Christmas Day (Observed)" + ) + for year, day in enumerate( + [ + 25, + 25, + 25, + 27, + 27, # 2001-05 + 25, + 25, + 25, + 25, + 27, # 2006-10 + 27, + 25, + 25, + 25, + 25, # 2011-15 + 27, + 25, + 25, + 25, + 25, + 25, + ], # 2016-21 + 2001, + ): + dt = date(year, 12, day) + self.assertIn(dt, self.holidays, dt) + self.assertEqual(self.holidays[dt][:9], "Christmas") + + def test_boxing_day(self): + self.holidays.observed = False + for year in range(1900, 2100): + dt = date(year, 12, 26) + self.assertIn(dt, self.holidays) + self.assertNotIn(dt + relativedelta(days=+1), self.holidays) + self.assertNotIn(date(2009, 12, 28), self.holidays) + self.assertNotIn(date(2010, 12, 27), self.holidays) + self.holidays.observed = True + self.assertIn(date(2009, 12, 28), self.holidays) + self.assertIn(date(2010, 12, 27), self.holidays) + for year, day in enumerate( + [ + 26, + 26, + 26, + 28, + 26, # 2001-05 + 26, + 26, + 26, + 28, + 28, # 2006-10 + 26, + 26, + 26, + 26, + 28, # 2011-15 + 26, + 26, + 26, + 26, + 28, + 28, + ], # 2016-21 + 2001, + ): + dt = date(year, 12, day) + self.assertIn(dt, self.holidays, dt) + self.assertEqual(self.holidays[dt][:6], "Boxing") + + def test_all_holidays(self): + au = sum( + holidays.AU(years=[1957, 2012, 2015], prov=p) + for p in holidays.AU.PROVINCES + ) + holidays_found = sum((au.get_list(key) for key in au), []) + all_holidays = [ + "New Year's Day", + "Australia Day", + "Adelaide Cup", + "Canberra Day", + "Good Friday", + "Easter Saturday", + "Easter Sunday", + "Easter Monday", + "Anzac Day", + "Queen's Birthday", + "Western Australia Day", + "Family & Community Day", + "Labour Day", + "Eight Hours Day", + "May Day", + "Picnic Day", + "Melbourne Cup", + "Christmas Day", + "Proclamation Day", + "Boxing Day", + ] + for holiday in all_holidays: + self.assertIn(holiday, holidays_found, holiday) diff --git a/test/countries/test_austria.py b/test/countries/test_austria.py new file mode 100644 index 000000000..2380f799e --- /dev/null +++ b/test/countries/test_austria.py @@ -0,0 +1,87 @@ +# -*- coding: utf-8 -*- + +# python-holidays +# --------------- +# A fast, efficient Python library for generating country, province and state +# specific sets of holidays on the fly. It aims to make determining whether a +# specific date is a holiday as fast and flexible as possible. +# +# Author: ryanss (c) 2014-2017 +# dr-prodigy (c) 2017-2021 +# Website: https://github.com/dr-prodigy/python-holidays +# License: MIT (see LICENSE file) + +import unittest + +from datetime import date +from dateutil.relativedelta import relativedelta + +import holidays + + +class TestAT(unittest.TestCase): + def setUp(self): + self.holidays = holidays.AT() + + def test_new_years(self): + for year in range(1900, 2100): + dt = date(year, 1, 1) + self.assertIn(dt, self.holidays) + self.assertNotIn(dt + relativedelta(days=-1), self.holidays) + self.assertNotIn(dt + relativedelta(days=+1), self.holidays) + + def test_christmas(self): + for year in range(1900, 2100): + dt = date(year, 12, 25) + self.assertIn(dt, self.holidays) + self.assertIn(dt + relativedelta(days=+1), self.holidays) + self.assertNotIn(dt + relativedelta(days=-1), self.holidays) + self.assertNotIn(dt + relativedelta(days=+2), self.holidays) + + def test_easter_monday(self): + for dt in [ + date(1900, 4, 16), + date(1901, 4, 8), + date(1902, 3, 31), + date(1999, 4, 5), + date(2000, 4, 24), + date(2010, 4, 5), + date(2018, 4, 2), + date(2019, 4, 22), + date(2020, 4, 13), + ]: + self.assertIn(dt, self.holidays) + self.assertNotIn(dt + relativedelta(days=-1), self.holidays) + self.assertNotIn(dt + relativedelta(days=+1), self.holidays) + + def test_national_day(self): + for year in range(1919, 1934): + dt = date(year, 11, 12) + self.assertIn(dt, self.holidays) + self.assertNotIn(dt + relativedelta(days=-1), self.holidays) + self.assertNotIn(dt + relativedelta(days=+1), self.holidays) + for year in range(1967, 2100): + dt = date(year, 10, 26) + self.assertIn(dt, self.holidays) + self.assertNotIn(dt + relativedelta(days=-1), self.holidays) + self.assertNotIn(dt + relativedelta(days=+1), self.holidays) + + def test_all_holidays_present(self): + at_2015 = holidays.AT(years=[2015]) + all_holidays = [ + "Neujahr", + "Heilige Drei Könige", + "Ostermontag", + "Staatsfeiertag", + "Christi Himmelfahrt", + "Pfingstmontag", + "Fronleichnam", + "Mariä Himmelfahrt", + "Nationalfeiertag", + "Allerheiligen", + "Mariä Empfängnis", + "Christtag", + "Stefanitag", + ] + for holiday in all_holidays: + self.assertIn(holiday, at_2015.values()) diff --git a/test/countries/test_bangladesh.py b/test/countries/test_bangladesh.py new file mode 100644 index 000000000..0102e7233 --- /dev/null +++ b/test/countries/test_bangladesh.py @@ -0,0 +1,32 @@ +# -*- coding: utf-8 -*- + +# python-holidays +# --------------- +# A fast, efficient Python library for generating country, province and state +# specific sets of holidays on the fly. It aims to make determining whether a +# specific date is a holiday as fast and flexible as possible. +# +# Author: ryanss (c) 2014-2017 +# dr-prodigy (c) 2017-2021 +# Website: https://github.com/dr-prodigy/python-holidays +# License: MIT (see LICENSE file) + +import unittest + +from datetime import date + +import holidays + + +class TestBangladesh(unittest.TestCase): + def setUp(self): + self.holidays = holidays.BD() + + def test_2020(self): + self.assertIn(date(2020, 2, 21), self.holidays) + self.assertIn(date(2020, 3, 17), self.holidays) + self.assertIn(date(2020, 3, 26), self.holidays) + self.assertIn(date(2020, 4, 14), self.holidays) + self.assertIn(date(2020, 5, 1), self.holidays) + self.assertIn(date(2020, 8, 15), self.holidays) + self.assertIn(date(2020, 12, 16), self.holidays) diff --git a/test/countries/test_belarus.py b/test/countries/test_belarus.py new file mode 100644 index 000000000..8f4e46b5e --- /dev/null +++ b/test/countries/test_belarus.py @@ -0,0 +1,69 @@ +# -*- coding: utf-8 -*- + +# python-holidays +# --------------- +# A fast, efficient Python library for generating country, province and state +# specific sets of holidays on the fly. It aims to make determining whether a +# specific date is a holiday as fast and flexible as possible. +# +# Author: ryanss (c) 2014-2017 +# dr-prodigy (c) 2017-2021 +# Website: https://github.com/dr-prodigy/python-holidays +# License: MIT (see LICENSE file) + +import unittest + +from datetime import date + +import holidays + + +class TestBelarus(unittest.TestCase): + def setUp(self): + self.holidays = holidays.BY() + + def test_2018(self): + # http://calendar.by/procal.php?year=2018 + # https://www.officeholidays.com/countries/belarus/index.php + self.assertIn(date(2018, 1, 1), self.holidays) + self.assertIn(date(2018, 1, 7), self.holidays) + self.assertIn(date(2018, 3, 8), self.holidays) + self.assertIn(date(2018, 4, 17), self.holidays) + self.assertIn(date(2018, 5, 1), self.holidays) + self.assertIn(date(2018, 5, 9), self.holidays) + self.assertIn(date(2018, 7, 3), self.holidays) + self.assertIn(date(2018, 11, 7), self.holidays) + self.assertIn(date(2018, 12, 25), self.holidays) + + def test_new_year(self): + self.assertIn(date(2019, 1, 1), self.holidays) + self.assertNotIn(date(2019, 1, 2), self.holidays) + self.assertIn(date(2020, 1, 1), self.holidays) + self.assertIn(date(2020, 1, 2), self.holidays) + self.assertIn(date(2021, 1, 1), self.holidays) + self.assertIn(date(2021, 1, 2), self.holidays) + + def test_radunitsa(self): + # http://calendar.by/content.php?id=20 + self.assertIn(date(2012, 4, 24), self.holidays) + self.assertIn(date(2013, 5, 14), self.holidays) + self.assertIn(date(2014, 4, 29), self.holidays) + self.assertIn(date(2015, 4, 21), self.holidays) + self.assertIn(date(2016, 5, 10), self.holidays) + self.assertIn(date(2017, 4, 25), self.holidays) + self.assertIn(date(2018, 4, 17), self.holidays) + self.assertIn(date(2019, 5, 7), self.holidays) + self.assertIn(date(2020, 4, 28), self.holidays) + self.assertIn(date(2021, 5, 11), self.holidays) + self.assertIn(date(2022, 5, 3), self.holidays) + self.assertIn(date(2023, 4, 25), self.holidays) + self.assertIn(date(2024, 5, 14), self.holidays) + self.assertIn(date(2025, 4, 29), self.holidays) + self.assertIn(date(2026, 4, 21), self.holidays) + self.assertIn(date(2027, 5, 11), self.holidays) + self.assertIn(date(2028, 4, 25), self.holidays) + self.assertIn(date(2029, 4, 17), self.holidays) + self.assertIn(date(2030, 5, 7), self.holidays) + + def test_before_1998(self): + self.assertNotIn(date(1997, 7, 3), self.holidays) diff --git a/test/countries/test_belgium.py b/test/countries/test_belgium.py new file mode 100644 index 000000000..872ef2085 --- /dev/null +++ b/test/countries/test_belgium.py @@ -0,0 +1,38 @@ +# -*- coding: utf-8 -*- + +# python-holidays +# --------------- +# A fast, efficient Python library for generating country, province and state +# specific sets of holidays on the fly. It aims to make determining whether a +# specific date is a holiday as fast and flexible as possible. +# +# Author: ryanss (c) 2014-2017 +# dr-prodigy (c) 2017-2021 +# Website: https://github.com/dr-prodigy/python-holidays +# License: MIT (see LICENSE file) + +import unittest + +from datetime import date + +import holidays + + +class TestBelgium(unittest.TestCase): + def setUp(self): + self.holidays = holidays.BE() + + def test_2017(self): + # https://www.belgium.be/nl/over_belgie/land/belgie_in_een_notendop/feestdagen + self.assertIn(date(2017, 1, 1), self.holidays) + self.assertIn(date(2017, 4, 16), self.holidays) + self.assertIn(date(2017, 4, 17), self.holidays) + self.assertIn(date(2017, 5, 1), self.holidays) + self.assertIn(date(2017, 5, 25), self.holidays) + self.assertIn(date(2017, 6, 4), self.holidays) + self.assertIn(date(2017, 6, 5), self.holidays) + self.assertIn(date(2017, 7, 21), self.holidays) + self.assertIn(date(2017, 8, 15), self.holidays) + self.assertIn(date(2017, 11, 1), self.holidays) + self.assertIn(date(2017, 11, 11), self.holidays) + self.assertIn(date(2017, 12, 25), self.holidays) diff --git a/test/countries/test_brazil.py b/test/countries/test_brazil.py new file mode 100644 index 000000000..6d2f73836 --- /dev/null +++ b/test/countries/test_brazil.py @@ -0,0 +1,296 @@ +# -*- coding: utf-8 -*- + +# python-holidays +# --------------- +# A fast, efficient Python library for generating country, province and state +# specific sets of holidays on the fly. It aims to make determining whether a +# specific date is a holiday as fast and flexible as possible. +# +# Author: ryanss (c) 2014-2017 +# dr-prodigy (c) 2017-2021 +# Website: https://github.com/dr-prodigy/python-holidays +# License: MIT (see LICENSE file) + +import unittest + +from datetime import date + +import holidays + + +class TestBrazil(unittest.TestCase): + def test_BR_holidays(self): + self.holidays = holidays.BR(years=2018) + self.assertIn("2018-01-01", self.holidays) + self.assertEqual(self.holidays[date(2018, 1, 1)], "Ano novo") + self.assertIn("2018-02-14", self.holidays) + self.assertEqual( + self.holidays[date(2018, 2, 14)], + "Quarta-feira de cinzas (Início da Quaresma)", + ) + self.assertIn("2018-02-13", self.holidays) + self.assertEqual(self.holidays[date(2018, 2, 13)], "Carnaval") + self.assertIn("2018-03-30", self.holidays) + self.assertEqual(self.holidays[date(2018, 3, 30)], "Sexta-feira Santa") + self.assertIn("2018-02-13", self.holidays) + self.assertEqual(self.holidays[date(2018, 2, 13)], "Carnaval") + self.assertIn("2018-04-01", self.holidays) + self.assertEqual(self.holidays[date(2018, 4, 1)], "Páscoa") + self.assertIn("2018-04-21", self.holidays) + self.assertEqual(self.holidays[date(2018, 4, 21)], "Tiradentes") + self.assertIn("2018-05-01", self.holidays) + self.assertEqual( + self.holidays[date(2018, 5, 1)], "Dia Mundial do Trabalho" + ) + self.assertIn("2018-05-31", self.holidays) + self.assertEqual(self.holidays[date(2018, 5, 31)], "Corpus Christi") + self.assertIn("2018-09-07", self.holidays) + self.assertEqual( + self.holidays[date(2018, 9, 7)], "Independência do Brasil" + ) + self.assertIn("2018-10-12", self.holidays) + self.assertEqual( + self.holidays[date(2018, 10, 12)], "Nossa Senhora Aparecida" + ) + self.assertIn("2018-11-02", self.holidays) + self.assertEqual(self.holidays[date(2018, 11, 2)], "Finados") + self.assertIn("2018-11-15", self.holidays) + self.assertEqual( + self.holidays[date(2018, 11, 15)], "Proclamação da República" + ) + self.assertIn("2018-12-25", self.holidays) + self.assertEqual(self.holidays[date(2018, 12, 25)], "Natal") + + def test_AC_holidays(self): + ac_holidays = holidays.BR(state="AC") + self.assertIn("2018-01-23", ac_holidays) + self.assertEqual(ac_holidays[date(2018, 1, 23)], "Dia do evangélico") + self.assertIn("2018-06-15", ac_holidays) + self.assertEqual(ac_holidays[date(2018, 6, 15)], "Aniversário do Acre") + self.assertIn("2018-09-05", ac_holidays) + self.assertEqual(ac_holidays[date(2018, 9, 5)], "Dia da Amazônia") + self.assertIn("2018-11-17", ac_holidays) + self.assertEqual( + ac_holidays[date(2018, 11, 17)], + "Assinatura do Tratado de Petrópolis", + ) + + def test_AL_holidays(self): + al_holidays = holidays.BR(state="AL") + self.assertIn("2018-06-24", al_holidays) + self.assertEqual(al_holidays[date(2018, 6, 24)], "São João") + self.assertIn("2018-06-29", al_holidays) + self.assertEqual(al_holidays[date(2018, 6, 29)], "São Pedro") + self.assertIn("2018-09-16", al_holidays) + self.assertEqual( + al_holidays[date(2018, 9, 16)], "Emancipação política de Alagoas" + ) + self.assertIn("2018-11-20", al_holidays) + self.assertEqual(al_holidays[date(2018, 11, 20)], "Consciência Negra") + + def test_AP_holidays(self): + ap_holidays = holidays.BR(state="AP") + self.assertIn("2018-03-19", ap_holidays) + self.assertEqual(ap_holidays[date(2018, 3, 19)], "Dia de São José") + self.assertIn("2018-07-25", ap_holidays) + self.assertEqual(ap_holidays[date(2018, 7, 25)], "São Tiago") + self.assertIn("2018-10-05", ap_holidays) + self.assertEqual(ap_holidays[date(2018, 10, 5)], "Criação do estado") + self.assertIn("2018-11-20", ap_holidays) + self.assertEqual(ap_holidays[date(2018, 11, 20)], "Consciência Negra") + + def test_AM_holidays(self): + am_holidays = holidays.BR(state="AM") + self.assertIn("2018-09-05", am_holidays) + self.assertEqual( + am_holidays[date(2018, 9, 5)], + "Elevação do Amazonas à categoria de província", + ) + self.assertIn("2018-11-20", am_holidays) + self.assertEqual(am_holidays[date(2018, 11, 20)], "Consciência Negra") + self.assertIn("2018-12-08", am_holidays) + self.assertEqual( + am_holidays[date(2018, 12, 8)], "Dia de Nossa Senhora da Conceição" + ) + + def test_BA_holidays(self): + ba_holidays = holidays.BR(state="BA") + self.assertIn("2018-07-02", ba_holidays) + self.assertEqual( + ba_holidays[date(2018, 7, 2)], "Independência da Bahia" + ) + + def test_CE_holidays(self): + ce_holidays = holidays.BR(state="CE") + self.assertIn("2018-03-19", ce_holidays) + self.assertEqual(ce_holidays[date(2018, 3, 19)], "São José") + self.assertIn("2018-03-25", ce_holidays) + self.assertEqual(ce_holidays[date(2018, 3, 25)], "Data Magna do Ceará") + + def test_DF_holidays(self): + df_holidays = holidays.BR(state="DF") + self.assertIn("2018-04-21", df_holidays) + self.assertEqual( + df_holidays[date(2018, 4, 21)], "Fundação de Brasília, Tiradentes" + ) + self.assertIn("2018-11-30", df_holidays) + self.assertEqual(df_holidays[date(2018, 11, 30)], "Dia do Evangélico") + + def test_ES_holidays(self): + es_holidays = holidays.BR(state="ES") + self.assertIn("2018-10-28", es_holidays) + self.assertEqual( + es_holidays[date(2018, 10, 28)], "Dia do Servidor Público" + ) + + def test_GO_holidays(self): + go_holidays = holidays.BR(state="GO") + self.assertIn("2018-10-28", go_holidays) + self.assertEqual( + go_holidays[date(2018, 10, 28)], "Dia do Servidor Público" + ) + + def test_MA_holidays(self): + ma_holidays = holidays.BR(state="MA") + self.assertIn("2018-07-28", ma_holidays) + self.assertEqual( + ma_holidays[date(2018, 7, 28)], + "Adesão do Maranhão à independência do Brasil", + ) + self.assertIn("2018-12-08", ma_holidays) + self.assertEqual( + ma_holidays[date(2018, 12, 8)], "Dia de Nossa Senhora da Conceição" + ) + + def test_MT_holidays(self): + mt_holidays = holidays.BR(state="MT") + self.assertIn("2018-11-20", mt_holidays) + self.assertEqual(mt_holidays[date(2018, 11, 20)], "Consciência Negra") + + def test_MS_holidays(self): + ms_holidays = holidays.BR(state="MS") + self.assertIn("2018-10-11", ms_holidays) + self.assertEqual(ms_holidays[date(2018, 10, 11)], "Criação do estado") + + def test_MG_holidays(self): + mg_holidays = holidays.BR(state="MG") + self.assertIn("2018-04-21", mg_holidays) + self.assertEqual( + mg_holidays[date(2018, 4, 21)], "Data Magna de MG, Tiradentes" + ) + + def test_PA_holidays(self): + pa_holidays = holidays.BR(state="PA") + self.assertIn("2018-08-15", pa_holidays) + self.assertEqual( + pa_holidays[date(2018, 8, 15)], + "Adesão do Grão-Pará à independência do Brasil", + ) + + def test_PB_holidays(self): + pb_holidays = holidays.BR(state="PB") + self.assertIn("2018-08-05", pb_holidays) + self.assertEqual(pb_holidays[date(2018, 8, 5)], "Fundação do Estado") + + def test_PE_holidays(self): + pe_holidays = holidays.BR(state="PE") + self.assertIn("2018-03-06", pe_holidays) + self.assertEqual( + pe_holidays[date(2018, 3, 6)], + "Revolução Pernambucana (Data Magna)", + ) + self.assertIn("2018-06-24", pe_holidays) + self.assertEqual(pe_holidays[date(2018, 6, 24)], "São João") + + def test_PI_holidays(self): + pi_holidays = holidays.BR(state="PI") + self.assertIn("2018-03-13", pi_holidays) + self.assertEqual( + pi_holidays[date(2018, 3, 13)], "Dia da Batalha do Jenipapo" + ) + self.assertIn("2018-10-19", pi_holidays) + self.assertEqual(pi_holidays[date(2018, 10, 19)], "Dia do Piauí") + + def test_PR_holidays(self): + pr_holidays = holidays.BR(state="PR") + self.assertIn("2018-12-19", pr_holidays) + self.assertEqual( + pr_holidays[date(2018, 12, 19)], "Emancipação do Paraná" + ) + + def test_RJ_holidays(self): + rj_holidays = holidays.BR(state="RJ") + self.assertIn("2018-04-23", rj_holidays) + self.assertEqual(rj_holidays[date(2018, 4, 23)], "Dia de São Jorge") + self.assertIn("2018-10-28", rj_holidays) + self.assertEqual( + rj_holidays[date(2018, 10, 28)], "Dia do Funcionário Público" + ) + self.assertIn("2018-11-20", rj_holidays) + self.assertEqual(rj_holidays[date(2018, 11, 20)], "Zumbi dos Palmares") + + def test_RN_holidays(self): + rn_holidays = holidays.BR(state="RN") + self.assertIn("2018-06-29", rn_holidays) + self.assertEqual(rn_holidays[date(2018, 6, 29)], "Dia de São Pedro") + self.assertIn("2018-10-03", rn_holidays) + self.assertEqual( + rn_holidays[date(2018, 10, 3)], "Mártires de Cunhaú e Uruaçuu" + ) + + def test_RS_holidays(self): + rs_holidays = holidays.BR(state="RS") + self.assertIn("2018-09-20", rs_holidays) + self.assertEqual( + rs_holidays[date(2018, 9, 20)], "Revolução Farroupilha" + ) + + def test_RO_holidays(self): + ro_holidays = holidays.BR(state="RO") + self.assertIn("2018-01-04", ro_holidays) + self.assertEqual(ro_holidays[date(2018, 1, 4)], "Criação do estado") + self.assertIn("2018-06-18", ro_holidays) + self.assertEqual(ro_holidays[date(2018, 6, 18)], "Dia do Evangélico") + + def test_RR_holidays(self): + rr_holidays = holidays.BR(state="RR") + self.assertIn("2018-10-05", rr_holidays) + self.assertEqual(rr_holidays[date(2018, 10, 5)], "Criação de Roraima") + + def test_SC_holidays(self): + sc_holidays = holidays.BR(state="SC") + self.assertIn("2018-08-11", sc_holidays) + self.assertEqual( + sc_holidays[date(2018, 8, 11)], + "Criação da capitania, separando-se de SP", + ) + + def test_SP_holidays(self): + sp_holidays = holidays.BR(state="SP") + self.assertIn("2018-07-09", sp_holidays) + self.assertEqual( + sp_holidays[date(2018, 7, 9)], + "Revolução Constitucionalista de 1932", + ) + + def test_SE_holidays(self): + se_holidays = holidays.BR(state="SE") + self.assertIn("2018-07-08", se_holidays) + self.assertEqual( + se_holidays[date(2018, 7, 8)], "Autonomia política de Sergipe" + ) + + def test_TO_holidays(self): + to_holidays = holidays.BR(state="TO") + self.assertIn("2018-01-01", to_holidays) + self.assertEqual( + to_holidays[date(2018, 1, 1)], "Instalação de Tocantins, Ano novo" + ) + self.assertIn("2018-09-08", to_holidays) + self.assertEqual( + to_holidays[date(2018, 9, 8)], "Nossa Senhora da Natividade" + ) + self.assertIn("2018-10-05", to_holidays) + self.assertEqual( + to_holidays[date(2018, 10, 5)], "Criação de Tocantins" + ) diff --git a/test/countries/test_bulgaria.py b/test/countries/test_bulgaria.py new file mode 100644 index 000000000..1196ccaf0 --- /dev/null +++ b/test/countries/test_bulgaria.py @@ -0,0 +1,96 @@ +# -*- coding: utf-8 -*- + +# python-holidays +# --------------- +# A fast, efficient Python library for generating country, province and state +# specific sets of holidays on the fly. It aims to make determining whether a +# specific date is a holiday as fast and flexible as possible. +# +# Author: ryanss (c) 2014-2017 +# dr-prodigy (c) 2017-2021 +# Website: https://github.com/dr-prodigy/python-holidays +# License: MIT (see LICENSE file) + +import unittest + +from datetime import date, timedelta + +import holidays + + +class TestBulgaria(unittest.TestCase): + def setUp(self): + self.holidays = holidays.Bulgaria() + + def test_before_1990(self): + self.assertEqual(len(holidays.Bulgaria(years=[1989])), 0) + + def test_new_years_day(self): + for year in range(1990, 2020): + self.assertIn(date(year, 1, 1), self.holidays) + + def test_liberation_day(self): + for year in range(1990, 2020): + self.assertIn(date(year, 3, 3), self.holidays) + + def test_labour_day(self): + for year in range(1990, 2020): + self.assertIn(date(year, 5, 1), self.holidays) + + def test_saint_georges_day(self): + for year in range(1990, 2020): + self.assertIn(date(year, 5, 6), self.holidays) + + def test_twenty_fourth_of_may(self): + for year in range(1990, 2020): + self.assertIn(date(year, 5, 24), self.holidays) + + def test_unification_day(self): + for year in range(1990, 2020): + self.assertIn(date(year, 9, 6), self.holidays) + + def test_independence_day(self): + for year in range(1990, 2020): + self.assertIn(date(year, 9, 22), self.holidays) + + def test_national_awakening_day(self): + for year in range(1990, 2020): + self.assertIn(date(year, 11, 1), self.holidays) + + def test_christmas(self): + for year in range(1990, 2020): + self.assertIn(date(year, 12, 24), self.holidays) + self.assertIn(date(year, 12, 25), self.holidays) + self.assertIn(date(year, 12, 26), self.holidays) + + def test_easter(self): + for year, month, day in [ + (2000, 4, 30), + (2001, 4, 15), + (2002, 5, 5), + (2003, 4, 27), + (2004, 4, 11), + (2005, 5, 1), + (2006, 4, 23), + (2007, 4, 8), + (2008, 4, 27), + (2009, 4, 19), + (2010, 4, 4), + (2011, 4, 24), + (2012, 4, 15), + (2013, 5, 5), + (2014, 4, 20), + (2015, 4, 12), + (2016, 5, 1), + (2017, 4, 16), + (2018, 4, 8), + (2019, 4, 28), + (2020, 4, 19), + (2021, 5, 2), + (2022, 4, 24), + ]: + easter = date(year, month, day) + easter_saturday = easter - timedelta(days=1) + easter_friday = easter - timedelta(days=2) + for holiday in [easter_friday, easter_saturday, easter]: + self.assertIn(holiday, self.holidays) diff --git a/test/countries/test_burundi.py b/test/countries/test_burundi.py new file mode 100644 index 000000000..7706b6c84 --- /dev/null +++ b/test/countries/test_burundi.py @@ -0,0 +1,98 @@ +# -*- coding: utf-8 -*- + +# python-holidays +# --------------- +# A fast, efficient Python library for generating country, province and state +# specific sets of holidays on the fly. It aims to make determining whether a +# specific date is a holiday as fast and flexible as possible. +# +# Author: ryanss (c) 2014-2017 +# dr-prodigy (c) 2017-2021 +# Website: https://github.com/dr-prodigy/python-holidays +# License: MIT (see LICENSE file) + +import sys +import unittest + +from datetime import date + +import holidays + + +class TestBurundi(unittest.TestCase): + def setUp(self): + self.holidays = holidays.BI() + + def test_new_year_day(self): + for year in range(1979, 2050): + self.assertIn("New Year's Day", self.holidays[date(year, 1, 1)]) + + def test_unity_day(self): + self.assertIn("Unity Day", self.holidays[date(2017, 2, 5)]) + self.assertIn("Unity Day (Observed)", self.holidays[date(2017, 2, 6)]) + + def test_labour_day(self): + self.assertIn("Labour Day", self.holidays[date(2017, 5, 1)]) + self.assertIn("Labour Day (Observed)", self.holidays[date(2022, 5, 2)]) + + def test_rwagasore_day(self): + self.assertIn( + "Prince Louis Rwagasore Day", self.holidays[date(2017, 10, 13)] + ) + self.assertIn( + "Prince Louis Rwagasore Day (Observed)", + self.holidays[date(2024, 10, 14)], + ) + + def test_ntaryamira_day(self): + self.assertIn( + "President Ntaryamira Day", self.holidays[date(2017, 4, 6)] + ) + + def test_ndadaye_day(self): + self.assertIn( + "President Ndadaye's Day", self.holidays[date(2017, 10, 21)] + ) + self.assertIn( + "President Ndadaye's Day (Observed)", + self.holidays[date(2018, 10, 22)], + ) + + def test_independence_day(self): + for year in range(1962, 2050): + self.assertIn(date(year, 7, 1), self.holidays) + + for year in range(1930, 1962): + if year != 1958: + # in 1958 it's Eid Al Adha (as estimated by convertdate) + self.assertNotIn(date(year, 7, 1), self.holidays) + + self.assertIn( + "Independence Day (Observed)", self.holidays[date(2018, 7, 2)] + ) + + def test_ascension_day(self): + self.assertIn("Ascension Day", self.holidays[date(2020, 5, 21)]) + + def test_assumption_Day(self): + self.assertIn("Assumption Day", self.holidays[date(2020, 8, 15)]) + + def test_all_saints_Day(self): + self.assertIn("All Saints' Day", self.holidays[date(2020, 11, 1)]) + self.assertIn( + "All Saints' Day (Observed)", self.holidays[date(2020, 11, 2)] + ) + + def test_christmas_Day(self): + self.assertIn("Christmas Day", self.holidays[date(2020, 12, 25)]) + + def test_eid_al_adha(self): + if sys.version_info >= (3, 6): + import importlib.util + + if importlib.util.find_spec("hijri_converter"): + self.holidays = holidays.Burundi(years=[2019, 1999]) + + # eid Al Adha + self.assertIn(date(2020, 7, 31), self.holidays) + self.assertIn(date(2020, 7, 31), self.holidays) diff --git a/test/countries/test_canada.py b/test/countries/test_canada.py new file mode 100644 index 000000000..617851225 --- /dev/null +++ b/test/countries/test_canada.py @@ -0,0 +1,356 @@ +# -*- coding: utf-8 -*- + +# python-holidays +# --------------- +# A fast, efficient Python library for generating country, province and state +# specific sets of holidays on the fly. It aims to make determining whether a +# specific date is a holiday as fast and flexible as possible. +# +# Author: ryanss (c) 2014-2017 +# dr-prodigy (c) 2017-2021 +# Website: https://github.com/dr-prodigy/python-holidays +# License: MIT (see LICENSE file) + +import unittest + +from datetime import date +from dateutil.relativedelta import relativedelta + +import holidays + + +class TestCA(unittest.TestCase): + def setUp(self): + self.holidays = holidays.CA(observed=False) + + def test_new_years(self): + self.assertNotIn(date(2010, 12, 31), self.holidays) + self.assertNotIn(date(2017, 1, 2), self.holidays) + self.holidays.observed = True + self.assertIn(date(2010, 12, 31), self.holidays) + self.assertIn(date(2017, 1, 2), self.holidays) + self.holidays.observed = False + for year in range(1900, 2100): + dt = date(year, 1, 1) + self.assertIn(dt, self.holidays) + self.assertNotIn(dt + relativedelta(days=-1), self.holidays) + self.assertNotIn(dt + relativedelta(days=+1), self.holidays) + + def test_islander_day(self): + pei_holidays = holidays.CA(prov="PE") + for dt in [ + date(2009, 2, 9), + date(2010, 2, 15), + date(2011, 2, 21), + date(2012, 2, 20), + date(2013, 2, 18), + date(2014, 2, 17), + date(2015, 2, 16), + date(2016, 2, 15), + date(2020, 2, 17), + ]: + if dt.year >= 2010: + self.assertNotEqual(self.holidays[dt], "Islander Day") + elif dt.year == 2009: + self.assertNotIn(dt, self.holidays) + self.assertIn(dt, pei_holidays) + self.assertNotIn(dt + relativedelta(days=-1), pei_holidays) + self.assertNotIn(dt + relativedelta(days=+1), pei_holidays) + + def test_family_day(self): + ab_holidays = holidays.CA(prov="AB") + bc_holidays = holidays.CA(prov="BC") + mb_holidays = holidays.CA(prov="MB") + sk_holidays = holidays.CA(prov="SK") + nb_holidays = holidays.CA(prov="NB") + for dt in [ + date(1990, 2, 19), + date(1999, 2, 15), + date(2000, 2, 21), + date(2006, 2, 20), + ]: + self.assertNotIn(dt, self.holidays) + self.assertIn(dt, ab_holidays) + self.assertNotIn(dt, bc_holidays) + self.assertNotIn(dt, mb_holidays) + self.assertNotIn(dt, sk_holidays) + dt = date(2007, 2, 19) + self.assertNotIn(dt, self.holidays) + self.assertIn(dt, ab_holidays) + self.assertNotIn(dt, bc_holidays) + self.assertNotIn(dt, mb_holidays) + self.assertIn(dt, sk_holidays) + for dt in [ + date(2008, 2, 18), + date(2012, 2, 20), + date(2014, 2, 17), + date(2018, 2, 19), + ]: + self.assertIn(dt, self.holidays) + self.assertIn(dt, ab_holidays) + self.assertNotIn(dt, bc_holidays) + self.assertIn(dt, mb_holidays) + self.assertIn(dt, sk_holidays) + for dt in [date(2018, 2, 19)]: + self.assertIn(dt, nb_holidays) + for dt in [date(2019, 2, 18), date(2020, 2, 17)]: + self.assertIn(dt, self.holidays) + self.assertIn(dt, ab_holidays) + self.assertIn(dt, bc_holidays) + self.assertIn(dt, mb_holidays) + self.assertIn(dt, sk_holidays) + for dt in [date(2013, 2, 11), date(2016, 2, 8)]: + self.assertNotIn(dt, self.holidays) + self.assertNotIn(dt, ab_holidays) + self.assertIn(dt, bc_holidays) + self.assertNotIn(dt, mb_holidays) + self.assertNotIn(dt, sk_holidays) + self.assertEqual(mb_holidays[date(2014, 2, 17)], "Louis Riel Day") + + def test_st_patricks_day(self): + nl_holidays = holidays.CA(prov="NL", observed=False) + for dt in [ + date(1900, 3, 19), + date(1999, 3, 15), + date(2000, 3, 20), + date(2012, 3, 19), + date(2013, 3, 18), + date(2014, 3, 17), + date(2015, 3, 16), + date(2016, 3, 14), + date(2020, 3, 16), + ]: + self.assertNotIn(dt, self.holidays) + self.assertIn(dt, nl_holidays) + self.assertNotIn(dt + relativedelta(days=-1), nl_holidays) + self.assertNotIn(dt + relativedelta(days=+1), nl_holidays) + + def test_good_friday(self): + qc_holidays = holidays.CA(prov="QC") + 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.assertIn(dt, self.holidays) + self.assertNotIn(dt + relativedelta(days=-1), self.holidays) + self.assertNotIn(dt + relativedelta(days=+1), self.holidays) + self.assertNotIn(dt, qc_holidays) + + def test_easter_monday(self): + qc_holidays = holidays.CA(prov="QC") + for dt in [ + date(1900, 4, 16), + date(1901, 4, 8), + date(1902, 3, 31), + date(1999, 4, 5), + date(2000, 4, 24), + date(2010, 4, 5), + date(2018, 4, 2), + date(2019, 4, 22), + date(2020, 4, 13), + ]: + self.assertNotIn(dt, self.holidays) + self.assertIn(dt, qc_holidays) + self.assertNotIn(dt + relativedelta(days=-1), qc_holidays) + self.assertNotIn(dt + relativedelta(days=+1), qc_holidays) + + def test_st_georges_day(self): + nl_holidays = holidays.CA(prov="NL") + for dt in [ + date(1990, 4, 23), + date(1999, 4, 26), + date(2000, 4, 24), + date(2010, 4, 19), + date(2016, 4, 25), + date(2020, 4, 20), + ]: + self.assertNotIn(dt, self.holidays) + self.assertIn(dt, nl_holidays) + self.assertNotIn(dt + relativedelta(days=-1), nl_holidays) + self.assertNotIn(dt + relativedelta(days=+1), nl_holidays) + + def test_victoria_day(self): + for dt in [ + date(1953, 5, 18), + date(1999, 5, 24), + date(2000, 5, 22), + date(2010, 5, 24), + date(2015, 5, 18), + date(2020, 5, 18), + ]: + self.assertIn(dt, self.holidays) + self.assertNotIn(dt + relativedelta(days=-1), self.holidays) + self.assertNotIn(dt + relativedelta(days=+1), self.holidays) + + def test_national_aboriginal_day(self): + nt_holidays = holidays.CA(prov="NT") + self.assertNotIn(date(1995, 6, 21), nt_holidays) + for year in range(1996, 2100): + dt = date(year, 6, 21) + self.assertNotIn(dt, self.holidays) + self.assertIn(dt, nt_holidays) + self.assertNotIn(dt + relativedelta(days=-1), nt_holidays) + self.assertNotIn(dt + relativedelta(days=+1), nt_holidays) + + def test_st_jean_baptiste_day(self): + qc_holidays = holidays.CA(prov="QC", observed=False) + self.assertNotIn(date(1924, 6, 24), qc_holidays) + for year in range(1925, 2100): + dt = date(year, 6, 24) + self.assertNotIn(dt, self.holidays) + self.assertIn(dt, qc_holidays) + self.assertNotIn(dt + relativedelta(days=-1), qc_holidays) + self.assertNotIn(dt + relativedelta(days=+1), qc_holidays) + self.assertNotIn(date(2001, 6, 25), qc_holidays) + qc_holidays.observed = True + self.assertIn(date(2001, 6, 25), qc_holidays) + + def test_discovery_day(self): + nl_holidays = holidays.CA(prov="NL") + yt_holidays = holidays.CA(prov="YT") + for dt in [ + date(1997, 6, 23), + date(1999, 6, 21), + date(2000, 6, 26), + date(2010, 6, 21), + date(2016, 6, 27), + date(2020, 6, 22), + ]: + self.assertNotIn(dt, self.holidays) + self.assertIn(dt, nl_holidays) + self.assertNotIn(dt, yt_holidays) + for dt in [ + date(1912, 8, 19), + date(1999, 8, 16), + date(2000, 8, 21), + date(2006, 8, 21), + date(2016, 8, 15), + date(2020, 8, 17), + ]: + self.assertNotIn(dt, self.holidays) + self.assertNotIn(dt, nl_holidays) + self.assertIn(dt, yt_holidays) + + def test_canada_day(self): + for year in range(1900, 2100): + dt = date(year, 7, 1) + self.assertIn(dt, self.holidays) + self.assertNotIn(dt + relativedelta(days=-1), self.holidays) + self.assertNotIn(dt + relativedelta(days=+1), self.holidays) + self.assertNotIn(date(2006, 7, 3), self.holidays) + self.assertNotIn(date(2007, 7, 2), self.holidays) + self.holidays.observed = True + self.assertIn(date(2006, 7, 3), self.holidays) + self.assertIn(date(2007, 7, 2), self.holidays) + + def test_nunavut_day(self): + nu_holidays = holidays.CA(prov="NU", observed=False) + self.assertNotIn(date(1999, 7, 9), nu_holidays) + self.assertNotIn(date(2000, 7, 9), nu_holidays) + self.assertIn(date(2000, 4, 1), nu_holidays) + for year in range(2001, 2100): + dt = date(year, 7, 9) + self.assertNotIn(dt, self.holidays) + self.assertIn(dt, nu_holidays) + self.assertNotIn(dt + relativedelta(days=-1), nu_holidays) + self.assertNotIn(dt + relativedelta(days=+1), nu_holidays) + self.assertNotIn(date(2017, 7, 10), nu_holidays) + nu_holidays.observed = True + self.assertIn(date(2017, 7, 10), nu_holidays) + + def test_civic_holiday(self): + bc_holidays = holidays.CA(prov="BC") + for dt in [date(1900, 8, 6), date(1955, 8, 1), date(1973, 8, 6)]: + self.assertIn(dt, self.holidays) + self.assertNotIn(dt, bc_holidays) + for dt in [ + date(1974, 8, 5), + date(1999, 8, 2), + date(2000, 8, 7), + date(2010, 8, 2), + date(2015, 8, 3), + date(2020, 8, 3), + ]: + self.assertIn(dt, self.holidays) + self.assertIn(dt, bc_holidays) + + def test_labour_day(self): + self.assertNotIn(date(1893, 9, 4), self.holidays) + for dt in [ + date(1894, 9, 3), + date(1900, 9, 3), + date(1999, 9, 6), + date(2000, 9, 4), + date(2014, 9, 1), + date(2015, 9, 7), + ]: + self.assertIn(dt, self.holidays) + self.assertNotIn(dt + relativedelta(days=-1), self.holidays) + self.assertNotIn(dt + relativedelta(days=+1), self.holidays) + + def test_thanksgiving(self): + ns_holidays = holidays.CA(prov="NB") + for dt in [ + date(1931, 10, 12), + date(1990, 10, 8), + date(1999, 10, 11), + date(2000, 10, 9), + date(2013, 10, 14), + date(2020, 10, 12), + ]: + self.assertIn(dt, self.holidays) + self.assertNotIn(dt + relativedelta(days=-1), self.holidays) + self.assertNotIn(dt + relativedelta(days=+1), self.holidays) + self.assertNotIn(dt, ns_holidays) + + def test_remembrance_day(self): + ab_holidays = holidays.CA(prov="AB", observed=False) + nl_holidays = holidays.CA(prov="NL", observed=False) + self.assertNotIn(date(1930, 11, 11), ab_holidays) + self.assertNotIn(date(1930, 11, 11), nl_holidays) + for year in range(1931, 2100): + dt = date(year, 11, 11) + self.assertNotIn(dt, self.holidays) + self.assertIn(dt, ab_holidays) + self.assertIn(dt, nl_holidays) + self.assertNotIn(dt + relativedelta(days=-1), nl_holidays) + self.assertNotIn(dt + relativedelta(days=+1), nl_holidays) + self.assertNotIn(date(2007, 11, 12), ab_holidays) + self.assertNotIn(date(2007, 11, 12), nl_holidays) + ab_holidays.observed = True + nl_holidays.observed = True + self.assertNotIn(date(2007, 11, 12), ab_holidays) + self.assertIn(date(2007, 11, 12), nl_holidays) + + def test_christmas_day(self): + for year in range(1900, 2100): + dt = date(year, 12, 25) + self.assertIn(dt, self.holidays) + self.assertNotIn(dt + relativedelta(days=-1), self.holidays) + self.assertNotIn(date(2010, 12, 24), self.holidays) + self.assertNotEqual( + self.holidays[date(2011, 12, 26)], "Christmas Day (Observed)" + ) + self.holidays.observed = True + self.assertIn(date(2010, 12, 24), self.holidays) + self.assertEqual( + self.holidays[date(2011, 12, 26)], "Christmas Day (Observed)" + ) + + def test_boxing_day(self): + for year in range(1900, 2100): + dt = date(year, 12, 26) + self.assertIn(dt, self.holidays) + self.assertNotIn(dt + relativedelta(days=+1), self.holidays) + self.assertNotIn(date(2009, 12, 28), self.holidays) + self.assertNotIn(date(2010, 12, 27), self.holidays) + self.holidays.observed = True + self.assertIn(date(2009, 12, 28), self.holidays) + self.assertIn(date(2010, 12, 27), self.holidays) diff --git a/test/countries/test_chile.py b/test/countries/test_chile.py new file mode 100644 index 000000000..25a643fa7 --- /dev/null +++ b/test/countries/test_chile.py @@ -0,0 +1,99 @@ +# -*- coding: utf-8 -*- + +# python-holidays +# --------------- +# A fast, efficient Python library for generating country, province and state +# specific sets of holidays on the fly. It aims to make determining whether a +# specific date is a holiday as fast and flexible as possible. +# +# Author: ryanss (c) 2014-2017 +# dr-prodigy (c) 2017-2021 +# Website: https://github.com/dr-prodigy/python-holidays +# License: MIT (see LICENSE file) + +import unittest + +from datetime import date + +import holidays + + +class TestChile(unittest.TestCase): + def setUp(self): + self.holidays = holidays.Chile() + self.holidays_AP = holidays.CL(state="AP") + self.holidays_NB = holidays.CHL(state="NB") + + def test_2009(self): + self.assertIn(date(2009, 10, 12), self.holidays) + + def test_2017(self): + self.assertIn(date(2017, 1, 2), self.holidays) + + def test_2018(self): + self.assertIn(date(2018, 9, 17), self.holidays) + + def test_2019(self): + # No laborables (sector público) not included + self.assertIn(date(2019, 1, 1), self.holidays) + # self.assertIn(date(2019, 4, 18), self.holidays) + self.assertIn(date(2019, 4, 19), self.holidays) + self.assertIn(date(2019, 5, 1), self.holidays) + self.assertIn(date(2019, 5, 21), self.holidays) + self.assertIn(date(2019, 6, 29), self.holidays) + self.assertIn(date(2019, 7, 16), self.holidays) + self.assertIn(date(2019, 8, 15), self.holidays) + self.assertIn(date(2019, 9, 18), self.holidays) + self.assertIn(date(2019, 9, 19), self.holidays) + self.assertIn(date(2019, 9, 20), self.holidays) + self.assertIn(date(2019, 10, 12), self.holidays) + self.assertIn(date(2019, 11, 1), self.holidays) + self.assertIn(date(2019, 12, 8), self.holidays) + self.assertIn(date(2019, 12, 25), self.holidays) + + def test_2020(self): + # from https://feriados.cl/2020.htm + self.assertIn(date(2020, 1, 1), self.holidays) + self.assertIn(date(2020, 4, 10), self.holidays) + self.assertIn(date(2020, 4, 11), self.holidays) + self.assertIn(date(2020, 5, 1), self.holidays) + self.assertIn(date(2020, 5, 21), self.holidays) + self.assertIn(date(2020, 6, 29), self.holidays) + self.assertIn(date(2020, 7, 16), self.holidays) + self.assertIn(date(2020, 8, 15), self.holidays) + self.assertIn(date(2020, 9, 18), self.holidays) + self.assertIn(date(2020, 9, 19), self.holidays) + self.assertIn(date(2020, 10, 12), self.holidays) + self.assertIn(date(2020, 10, 31), self.holidays) + self.assertIn(date(2020, 11, 1), self.holidays) + self.assertIn(date(2020, 12, 8), self.holidays) + self.assertIn(date(2020, 12, 25), self.holidays) + self.assertIn(date(2020, 6, 7), self.holidays_AP) + self.assertIn(date(2020, 8, 20), self.holidays_NB) + + def test_2021(self): + # from https://feriados.cl/2021.htm + self.assertIn(date(2021, 1, 1), self.holidays) + self.assertIn(date(2021, 4, 2), self.holidays) + self.assertIn(date(2021, 4, 3), self.holidays) + self.assertIn(date(2021, 5, 1), self.holidays) + self.assertIn(date(2021, 5, 21), self.holidays) + self.assertIn(date(2021, 6, 28), self.holidays) + self.assertIn(date(2021, 7, 16), self.holidays) + self.assertIn(date(2021, 8, 15), self.holidays) + self.assertIn(date(2021, 9, 18), self.holidays) + self.assertIn(date(2021, 9, 19), self.holidays) + self.assertIn(date(2021, 10, 11), self.holidays) + self.assertIn(date(2021, 10, 31), self.holidays) + self.assertIn(date(2021, 11, 1), self.holidays) + self.assertIn(date(2021, 12, 8), self.holidays) + self.assertIn(date(2021, 12, 25), self.holidays) + self.assertIn(date(2021, 6, 7), self.holidays_AP) + self.assertIn(date(2021, 8, 20), self.holidays_NB) + + def test_2024(self): + self.assertIn(date(2024, 10, 12), self.holidays) + + def test_2029(self): + self.assertIn(date(2029, 7, 2), self.holidays) + self.assertIn(date(2029, 10, 15), self.holidays) diff --git a/test/countries/test_colombia.py b/test/countries/test_colombia.py new file mode 100644 index 000000000..289bf9c41 --- /dev/null +++ b/test/countries/test_colombia.py @@ -0,0 +1,61 @@ +# -*- coding: utf-8 -*- + +# python-holidays +# --------------- +# A fast, efficient Python library for generating country, province and state +# specific sets of holidays on the fly. It aims to make determining whether a +# specific date is a holiday as fast and flexible as possible. +# +# Author: ryanss (c) 2014-2017 +# dr-prodigy (c) 2017-2021 +# Website: https://github.com/dr-prodigy/python-holidays +# License: MIT (see LICENSE file) + +import unittest + +from datetime import date + +import holidays + + +class TestCO(unittest.TestCase): + def setUp(self): + self.holidays = holidays.CO(observed=True) + + def test_2016(self): + # http://www.officeholidays.com/countries/colombia/ + self.assertIn(date(2016, 1, 1), self.holidays) + self.assertIn(date(2016, 1, 11), self.holidays) + self.assertIn(date(2016, 3, 21), self.holidays) + self.assertIn(date(2016, 3, 24), self.holidays) + self.assertIn(date(2016, 3, 25), self.holidays) + self.assertIn(date(2016, 5, 1), self.holidays) + self.assertIn(date(2016, 5, 9), self.holidays) + self.assertIn(date(2016, 5, 30), self.holidays) + self.assertIn(date(2016, 6, 6), self.holidays) + self.assertIn(date(2016, 7, 4), self.holidays) + self.assertIn(date(2016, 7, 20), self.holidays) + self.assertIn(date(2016, 8, 7), self.holidays) + self.assertIn(date(2016, 8, 15), self.holidays) + self.assertIn(date(2016, 10, 17), self.holidays) + self.assertIn(date(2016, 11, 7), self.holidays) + self.assertIn(date(2016, 11, 14), self.holidays) + self.assertIn(date(2016, 12, 8), self.holidays) + self.assertIn(date(2016, 12, 25), self.holidays) + + def test_others(self): + # holidays falling on weekend + self.assertNotIn(date(2017, 1, 1), self.holidays) + self.assertNotIn(date(2014, 7, 20), self.holidays) + self.assertNotIn(date(2018, 8, 12), self.holidays) + + self.assertIn(date(2014, 1, 6), self.holidays) + self.assertIn(date(2012, 3, 19), self.holidays) + self.assertIn(date(2015, 6, 29), self.holidays) + self.assertIn(date(2010, 8, 16), self.holidays) + self.assertIn(date(2015, 10, 12), self.holidays) + self.assertIn(date(2010, 11, 1), self.holidays) + self.assertIn(date(2013, 11, 11), self.holidays) + self.holidays.observed = False + self.assertIn(date(2016, 5, 5), self.holidays) + self.assertIn(date(2016, 5, 26), self.holidays) diff --git a/test/countries/test_croatia.py b/test/countries/test_croatia.py new file mode 100644 index 000000000..28a6fba23 --- /dev/null +++ b/test/countries/test_croatia.py @@ -0,0 +1,40 @@ +# -*- coding: utf-8 -*- + +# python-holidays +# --------------- +# A fast, efficient Python library for generating country, province and state +# specific sets of holidays on the fly. It aims to make determining whether a +# specific date is a holiday as fast and flexible as possible. +# +# Author: ryanss (c) 2014-2017 +# dr-prodigy (c) 2017-2021 +# Website: https://github.com/dr-prodigy/python-holidays +# License: MIT (see LICENSE file) + +import unittest + +from datetime import date + +import holidays + + +class TestCroatia(unittest.TestCase): + def setUp(self): + self.holidays = holidays.HR() + + def test_2018(self): + self.assertIn(date(2018, 1, 1), self.holidays) + self.assertIn(date(2018, 1, 6), self.holidays) + self.assertIn(date(2018, 4, 1), self.holidays) + self.assertIn(date(2018, 4, 2), self.holidays) + self.assertIn(date(2018, 5, 1), self.holidays) + self.assertIn(date(2018, 6, 25), self.holidays) + self.assertIn(date(2018, 8, 15), self.holidays) + self.assertIn(date(2018, 10, 8), self.holidays) + self.assertIn(date(2018, 11, 1), self.holidays) + self.assertIn(date(2018, 12, 25), self.holidays) + self.assertIn(date(2018, 12, 26), self.holidays) + + def test_2020_new(self): + self.assertIn(date(2020, 5, 30), self.holidays) + self.assertIn(date(2020, 11, 18), self.holidays) diff --git a/test/countries/test_czechia.py b/test/countries/test_czechia.py new file mode 100644 index 000000000..8707a272c --- /dev/null +++ b/test/countries/test_czechia.py @@ -0,0 +1,51 @@ +# -*- coding: utf-8 -*- + +# python-holidays +# --------------- +# A fast, efficient Python library for generating country, province and state +# specific sets of holidays on the fly. It aims to make determining whether a +# specific date is a holiday as fast and flexible as possible. +# +# Author: ryanss (c) 2014-2017 +# dr-prodigy (c) 2017-2021 +# Website: https://github.com/dr-prodigy/python-holidays +# License: MIT (see LICENSE file) + +import unittest +import warnings + +from datetime import date + +import holidays + + +class TestCZ(unittest.TestCase): + def setUp(self): + self.holidays = holidays.CZ() + + def test_2017(self): + # http://www.officeholidays.com/countries/czech_republic/2017.php + self.assertIn(date(2017, 1, 1), self.holidays) + self.assertIn(date(2017, 4, 14), self.holidays) + self.assertIn(date(2017, 4, 17), self.holidays) + self.assertIn(date(2017, 5, 1), self.holidays) + self.assertIn(date(2017, 5, 8), self.holidays) + self.assertIn(date(2017, 7, 5), self.holidays) + self.assertIn(date(2017, 7, 6), self.holidays) + self.assertIn(date(2017, 9, 28), self.holidays) + self.assertIn(date(2017, 10, 28), self.holidays) + self.assertIn(date(2017, 11, 17), self.holidays) + self.assertIn(date(2017, 12, 24), self.holidays) + self.assertIn(date(2017, 12, 25), self.holidays) + self.assertIn(date(2017, 12, 26), self.holidays) + + def test_others(self): + self.assertIn(date(1991, 5, 9), self.holidays) + + def test_czech_deprecated(self): + with warnings.catch_warnings(record=True) as w: + warnings.simplefilter("always") + czech = holidays.Czech() + self.assertIsInstance(czech, holidays.Czechia) + self.assertEqual(1, len(w)) + self.assertTrue(issubclass(w[-1].category, DeprecationWarning)) diff --git a/test/countries/test_denmark.py b/test/countries/test_denmark.py new file mode 100644 index 000000000..fd603af09 --- /dev/null +++ b/test/countries/test_denmark.py @@ -0,0 +1,34 @@ +# -*- coding: utf-8 -*- + +# python-holidays +# --------------- +# A fast, efficient Python library for generating country, province and state +# specific sets of holidays on the fly. It aims to make determining whether a +# specific date is a holiday as fast and flexible as possible. +# +# Author: ryanss (c) 2014-2017 +# dr-prodigy (c) 2017-2021 +# Website: https://github.com/dr-prodigy/python-holidays +# License: MIT (see LICENSE file) + +import unittest + +from datetime import date + +import holidays + + +class TestDK(unittest.TestCase): + def setUp(self): + self.holidays = holidays.DK() + + def test_2016(self): + # http://www.officeholidays.com/countries/denmark/2016.php + self.assertIn(date(2016, 1, 1), self.holidays) + self.assertIn(date(2016, 3, 24), self.holidays) + self.assertIn(date(2016, 3, 25), self.holidays) + self.assertIn(date(2016, 3, 28), self.holidays) + self.assertIn(date(2016, 4, 22), self.holidays) + self.assertIn(date(2016, 5, 5), self.holidays) + self.assertIn(date(2016, 5, 16), self.holidays) + self.assertIn(date(2016, 12, 25), self.holidays) diff --git a/test/countries/test_djibouti.py b/test/countries/test_djibouti.py new file mode 100644 index 000000000..f65bcf385 --- /dev/null +++ b/test/countries/test_djibouti.py @@ -0,0 +1,55 @@ +# -*- coding: utf-8 -*- + +# python-holidays +# --------------- +# A fast, efficient Python library for generating country, province and state +# specific sets of holidays on the fly. It aims to make determining whether a +# specific date is a holiday as fast and flexible as possible. +# +# Author: ryanss (c) 2014-2017 +# dr-prodigy (c) 2017-2021 +# Website: https://github.com/dr-prodigy/python-holidays +# License: MIT (see LICENSE file) + +import sys +import unittest + +from datetime import date + +import holidays + + +class TestDjibouti(unittest.TestCase): + def setUp(self): + self.holidays = holidays.DJ() + + def test_2019(self): + self.assertIn(date(2019, 5, 1), self.holidays) + self.assertIn(date(2019, 6, 27), self.holidays) + self.assertIn(date(2019, 6, 28), self.holidays) + + def test_labour_day(self): + self.assertIn(date(2019, 5, 1), self.holidays) + + def test_hijri_based(self): + if sys.version_info >= (3, 6): + import importlib.util + + if importlib.util.find_spec("hijri_converter"): + self.holidays = holidays.DJ(years=[2010]) + self.assertIn(date(2019, 6, 5), self.holidays) + self.assertIn(date(2019, 8, 10), self.holidays) + self.assertIn(date(2019, 8, 11), self.holidays) + self.assertIn(date(2019, 8, 12), self.holidays) + self.assertIn(date(2019, 8, 31), self.holidays) + self.assertIn(date(2019, 11, 9), self.holidays) + # eid_alfitr + self.assertIn(date(2019, 6, 5), self.holidays) + # eid_aladha + self.assertIn(date(2019, 8, 11), self.holidays) + # islamic_new_year + self.assertIn(date(2019, 8, 31), self.holidays) + # arafat_2019 + self.assertIn(date(2019, 8, 10), self.holidays) + # muhammad's birthday 2019 + self.assertIn(date(2019, 11, 9), self.holidays) diff --git a/test/countries/test_dominican_republic.py b/test/countries/test_dominican_republic.py new file mode 100644 index 000000000..b98bade50 --- /dev/null +++ b/test/countries/test_dominican_republic.py @@ -0,0 +1,55 @@ +# -*- coding: utf-8 -*- + +# python-holidays +# --------------- +# A fast, efficient Python library for generating country, province and state +# specific sets of holidays on the fly. It aims to make determining whether a +# specific date is a holiday as fast and flexible as possible. +# +# Author: ryanss (c) 2014-2017 +# dr-prodigy (c) 2017-2021 +# Website: https://github.com/dr-prodigy/python-holidays +# License: MIT (see LICENSE file) + +import unittest + +from datetime import date + +import holidays + + +class TestDominicanRepublic(unittest.TestCase): + def setUp(self): + self.do_holidays = holidays.DO() + + def test_do_holidays_2020(self): + year = 2020 + + # New Year's Day + self.assertIn(date(year, 1, 1), self.do_holidays) + # Epiphany + self.assertIn(date(year, 1, 6), self.do_holidays) + # Lady of Altagracia + self.assertIn(date(year, 1, 21), self.do_holidays) + # Juan Pablo Duarte Day + self.assertIn(date(year, 1, 26), self.do_holidays) + # Independence Day + self.assertIn(date(year, 2, 27), self.do_holidays) + # Good Friday + self.assertIn(date(year, 4, 10), self.do_holidays) + # Labor Day + self.assertIn(date(year, 5, 4), self.do_holidays) + # Feast of Corpus Christi + self.assertIn(date(year, 6, 11), self.do_holidays) + # Restoration Day + self.assertIn(date(year, 8, 16), self.do_holidays) + # Our Lady of Mercedes Day + self.assertIn(date(year, 9, 24), self.do_holidays) + # Constitution Day + self.assertIn(date(year, 11, 9), self.do_holidays) + # Christmas Day + self.assertIn(date(year, 12, 25), self.do_holidays) + + # Change day by law test + # New Year's Day + self.assertIn(date(2019, 1, 1), self.do_holidays) diff --git a/test/countries/test_egypt.py b/test/countries/test_egypt.py new file mode 100644 index 000000000..a47b80e47 --- /dev/null +++ b/test/countries/test_egypt.py @@ -0,0 +1,74 @@ +# -*- coding: utf-8 -*- + +# python-holidays +# --------------- +# A fast, efficient Python library for generating country, province and state +# specific sets of holidays on the fly. It aims to make determining whether a +# specific date is a holiday as fast and flexible as possible. +# +# Author: ryanss (c) 2014-2017 +# dr-prodigy (c) 2017-2021 +# Website: https://github.com/dr-prodigy/python-holidays +# License: MIT (see LICENSE file) + +import sys +import unittest + +from datetime import date + +import holidays + + +class TestEgypt(unittest.TestCase): + def setUp(self): + self.holidays = holidays.EG() + + def test_2019(self): + self.assertIn(date(2019, 1, 7), self.holidays) + self.assertIn(date(2019, 1, 25), self.holidays) + self.assertIn(date(2019, 4, 25), self.holidays) + self.assertIn(date(2019, 4, 28), self.holidays) + self.assertIn(date(2019, 4, 29), self.holidays) + self.assertIn(date(2019, 5, 1), self.holidays) + self.assertIn(date(2019, 6, 30), self.holidays) + self.assertIn(date(2019, 7, 23), self.holidays) + self.assertIn(date(2019, 10, 6), self.holidays) + + def test_coptic_christmas(self): + self.assertIn(date(2019, 1, 7), self.holidays) + + def test_25_jan(self): + self.assertIn(date(2019, 1, 25), self.holidays) + + def test_labour_day(self): + self.assertIn(date(2019, 5, 1), self.holidays) + + def test_25_jan_from_2009(self): + # Before 2009 Jan 25th wasn't celebrated + self.holidays = holidays.EG(years=[2010]) + self.assertIn(date(2010, 1, 25), self.holidays) + + def test_hijri_based(self): + if sys.version_info >= (3, 6): + import importlib.util + + if importlib.util.find_spec("hijri_converter"): + self.holidays = holidays.EG(years=[2010]) + self.assertIn(date(2019, 6, 5), self.holidays) + self.assertIn(date(2019, 8, 10), self.holidays) + self.assertIn(date(2019, 8, 11), self.holidays) + self.assertIn(date(2019, 8, 12), self.holidays) + self.assertIn(date(2019, 8, 31), self.holidays) + self.assertIn(date(2019, 11, 9), self.holidays) + # eid_alfitr + self.assertIn(date(2019, 6, 4), self.holidays) + # eid_aladha + self.assertIn(date(2019, 8, 11), self.holidays) + # islamic_new_year + self.assertIn(date(2019, 8, 31), self.holidays) + # eid_elfetr_2010 + self.assertIn(date(2010, 9, 10), self.holidays) + # arafat_2010 + self.assertIn(date(2010, 11, 15), self.holidays) + # muhammad's birthday + self.assertIn(date(2010, 2, 26), self.holidays) diff --git a/test/countries/test_estonia.py b/test/countries/test_estonia.py new file mode 100644 index 000000000..2b01f6e32 --- /dev/null +++ b/test/countries/test_estonia.py @@ -0,0 +1,86 @@ +# -*- coding: utf-8 -*- + +# python-holidays +# --------------- +# A fast, efficient Python library for generating country, province and state +# specific sets of holidays on the fly. It aims to make determining whether a +# specific date is a holiday as fast and flexible as possible. +# +# Author: ryanss (c) 2014-2017 +# dr-prodigy (c) 2017-2021 +# Website: https://github.com/dr-prodigy/python-holidays +# License: MIT (see LICENSE file) + +import unittest + +from datetime import date, datetime + +import holidays + + +class TestEstonia(unittest.TestCase): + def setUp(self): + self.holidays = holidays.EE() + self.cur_date = datetime.now() + + def test_new_years(self): + test_date = date(self.cur_date.year, 1, 1) + self.assertEqual(self.holidays.get(test_date), "uusaasta") + self.assertIn(test_date, self.holidays) + + def test_independence_day(self): + test_date = date(self.cur_date.year, 2, 24) + self.assertEqual(self.holidays.get(test_date), "iseseisvuspäev") + self.assertIn(test_date, self.holidays) + + def test_good_friday(self): + test_date = date(2019, 4, 19) + self.assertEqual(self.holidays.get(test_date), "suur reede") + self.assertIn(test_date, self.holidays) + + def test_easter_sunday(self): + test_date = date(2019, 4, 21) + self.assertEqual( + self.holidays.get(test_date), "ülestõusmispühade 1. püha" + ) + self.assertIn(test_date, self.holidays) + + def test_spring_day(self): + test_date = date(self.cur_date.year, 5, 1) + self.assertEqual(self.holidays.get(test_date), "kevadpüha") + self.assertIn(test_date, self.holidays) + + def test_pentecost(self): + test_date = date(2019, 6, 9) + self.assertEqual(self.holidays.get(test_date), "nelipühade 1. püha") + self.assertIn(test_date, self.holidays) + + def test_victory_day(self): + test_date = date(self.cur_date.year, 6, 23) + self.assertEqual(self.holidays.get(test_date), "võidupüha") + self.assertIn(test_date, self.holidays) + + def test_midsummers_day(self): + test_date = date(self.cur_date.year, 6, 24) + self.assertEqual(self.holidays.get(test_date), "jaanipäev") + self.assertIn(test_date, self.holidays) + + def test_restoration_of_independence_day(self): + test_date = date(self.cur_date.year, 8, 20) + self.assertEqual(self.holidays.get(test_date), "taasiseseisvumispäev") + self.assertIn(test_date, self.holidays) + + def test_christmas_eve(self): + test_date = date(self.cur_date.year, 12, 24) + self.assertEqual(self.holidays.get(test_date), "jõululaupäev") + self.assertIn(test_date, self.holidays) + + def test_christmas_day(self): + test_date = date(self.cur_date.year, 12, 25) + self.assertEqual(self.holidays.get(test_date), "esimene jõulupüha") + self.assertIn(test_date, self.holidays) + + def test_boxing_day(self): + test_date = date(self.cur_date.year, 12, 26) + self.assertEqual(self.holidays.get(test_date), "teine jõulupüha") + self.assertIn(test_date, self.holidays) diff --git a/test/countries/test_european_central_bank.py b/test/countries/test_european_central_bank.py new file mode 100644 index 000000000..1d65be4d6 --- /dev/null +++ b/test/countries/test_european_central_bank.py @@ -0,0 +1,107 @@ +# -*- coding: utf-8 -*- + +# python-holidays +# --------------- +# A fast, efficient Python library for generating country, province and state +# specific sets of holidays on the fly. It aims to make determining whether a +# specific date is a holiday as fast and flexible as possible. +# +# Author: ryanss (c) 2014-2017 +# dr-prodigy (c) 2017-2021 +# Website: https://github.com/dr-prodigy/python-holidays +# License: MIT (see LICENSE file) + +import unittest + +from datetime import date +from dateutil.relativedelta import relativedelta + +import holidays + + +class TestTAR(unittest.TestCase): + def setUp(self): + self.holidays = holidays.TAR() + + def test_new_years(self): + for year in range(1974, 2100): + dt = date(year, 1, 1) + self.assertIn(dt, self.holidays) + self.assertNotIn(dt + relativedelta(days=-1), self.holidays) + + def test_good_friday(self): + 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.assertIn(dt, self.holidays) + self.assertNotIn(dt + relativedelta(days=-1), self.holidays) + self.assertNotIn(dt + relativedelta(days=+1), self.holidays) + + def test_easter_monday(self): + for dt in [ + date(1900, 4, 16), + date(1901, 4, 8), + date(1902, 3, 31), + date(1999, 4, 5), + date(2000, 4, 24), + date(2010, 4, 5), + date(2018, 4, 2), + date(2019, 4, 22), + date(2020, 4, 13), + ]: + self.assertIn(dt, self.holidays) + self.assertNotIn(dt + relativedelta(days=-1), self.holidays) + self.assertNotIn(dt + relativedelta(days=+1), self.holidays) + + def test_labour_day(self): + for year in range(1900, 2100): + dt = date(year, 5, 1) + self.assertIn(dt, self.holidays) + self.assertNotIn(dt + relativedelta(days=-1), self.holidays) + self.assertNotIn(dt + relativedelta(days=+1), self.holidays) + + def test_christmas_day(self): + for year in range(1900, 2100): + dt = date(year, 12, 25) + self.assertIn(dt, self.holidays) + self.assertNotIn(dt + relativedelta(days=-1), self.holidays) + + def test_26_december_day(self): + for year in range(1900, 2100): + dt = date(year, 12, 26) + self.assertIn(dt, self.holidays) + self.assertNotIn(dt + relativedelta(days=+1), self.holidays) + + def test_all_holidays_present(self): + tar_2015 = holidays.TAR(years=[2015]) + all_holidays = [ + "New Year's Day", + "Good Friday", + "Easter Monday", + "1 May (Labour Day)", + "Christmas Day", + "26 December", + ] + for holiday in all_holidays: + self.assertIn(holiday, tar_2015.values()) + + +class TestECB(unittest.TestCase): + def setUp(self): + self.holidays_ecb = holidays.ECB() + self.holidays_tar = holidays.TAR() + + def test_new_years(self): + for year in range(1974, 2100): + self.holidays_ecb._populate(year) + self.holidays_tar._populate(year) + for holiday in self.holidays_tar: + self.assertIn(holiday, self.holidays_ecb) diff --git a/test/countries/test_finland.py b/test/countries/test_finland.py new file mode 100644 index 000000000..ee184bfe4 --- /dev/null +++ b/test/countries/test_finland.py @@ -0,0 +1,67 @@ +# -*- coding: utf-8 -*- + +# python-holidays +# --------------- +# A fast, efficient Python library for generating country, province and state +# specific sets of holidays on the fly. It aims to make determining whether a +# specific date is a holiday as fast and flexible as possible. +# +# Author: ryanss (c) 2014-2017 +# dr-prodigy (c) 2017-2021 +# Website: https://github.com/dr-prodigy/python-holidays +# License: MIT (see LICENSE file) + +import unittest + +from datetime import date + +import holidays + + +class TestFinland(unittest.TestCase): + def setUp(self): + self.holidays = holidays.FI() + + def test_fixed_holidays(self): + self.assertIn(date(2017, 1, 1), self.holidays) + self.assertEqual(self.holidays[date(2017, 1, 1)], "Uudenvuodenpäivä") + + self.assertIn(date(2017, 1, 6), self.holidays) + self.assertEqual(self.holidays[date(2017, 1, 6)], "Loppiainen") + + self.assertIn(date(2017, 5, 1), self.holidays) + self.assertEqual(self.holidays[date(2017, 5, 1)], "Vappu") + + self.assertIn(date(2017, 12, 6), self.holidays) + self.assertEqual(self.holidays[date(2017, 12, 6)], "Itsenäisyyspäivä") + + self.assertIn(date(2017, 12, 25), self.holidays) + self.assertEqual(self.holidays[date(2017, 12, 25)], "Joulupäivä") + + self.assertIn(date(2017, 12, 26), self.holidays) + self.assertEqual(self.holidays[date(2017, 12, 26)], "Tapaninpäivä") + + def test_relative_holidays(self): + self.assertIn(date(2017, 4, 14), self.holidays) + self.assertEqual(self.holidays[date(2017, 4, 14)], "Pitkäperjantai") + + self.assertIn(date(2017, 4, 16), self.holidays) + self.assertEqual(self.holidays[date(2017, 4, 16)], "Pääsiäispäivä") + + self.assertIn(date(2017, 4, 17), self.holidays) + self.assertEqual(self.holidays[date(2017, 4, 17)], "2. pääsiäispäivä") + + self.assertIn(date(2017, 5, 25), self.holidays) + self.assertEqual(self.holidays[date(2017, 5, 25)], "Helatorstai") + + self.assertIn(date(2017, 11, 4), self.holidays) + self.assertEqual(self.holidays[date(2017, 11, 4)], "Pyhäinpäivä") + + def test_Juhannus(self): + self.assertIn(date(2017, 6, 24), self.holidays) + self.assertNotIn(date(2017, 6, 20), self.holidays) + self.assertIn(date(2020, 6, 20), self.holidays) + self.assertIn(date(2021, 6, 26), self.holidays) + self.assertIn(date(2018, 6, 22), self.holidays) + self.assertEqual(self.holidays[date(2018, 6, 22)], "Juhannusaatto") + self.assertEqual(self.holidays[date(2018, 6, 23)], "Juhannuspäivä") diff --git a/test/countries/test_france.py b/test/countries/test_france.py new file mode 100644 index 000000000..c4944dd44 --- /dev/null +++ b/test/countries/test_france.py @@ -0,0 +1,84 @@ +# -*- coding: utf-8 -*- + +# python-holidays +# --------------- +# A fast, efficient Python library for generating country, province and state +# specific sets of holidays on the fly. It aims to make determining whether a +# specific date is a holiday as fast and flexible as possible. +# +# Author: ryanss (c) 2014-2017 +# dr-prodigy (c) 2017-2021 +# Website: https://github.com/dr-prodigy/python-holidays +# License: MIT (see LICENSE file) + +import unittest + +from datetime import date + +import holidays + + +class TestFrance(unittest.TestCase): + def setUp(self): + self.holidays = holidays.France() + self.prov_holidays = { + prov: holidays.FR(prov=prov) for prov in holidays.FRA.PROVINCES + } + + def test_2017(self): + self.assertIn(date(2017, 1, 1), self.holidays) + self.assertIn(date(2017, 4, 17), self.holidays) + self.assertIn(date(2017, 5, 1), self.holidays) + self.assertIn(date(2017, 5, 8), self.holidays) + self.assertIn(date(2017, 5, 25), self.holidays) + self.assertIn(date(2017, 6, 5), self.holidays) + self.assertIn(date(2017, 7, 14), self.holidays) + + def test_others(self): + self.assertEqual( + self.holidays[date(1948, 5, 1)], + "Fête du Travail et de la Concorde sociale", + ) + + def test_alsace_moselle(self): + am_holidays = self.prov_holidays["Alsace-Moselle"] + self.assertIn(date(2017, 4, 14), am_holidays) + self.assertIn(date(2017, 12, 26), am_holidays) + + def test_mayotte(self): + am_holidays = self.prov_holidays["Mayotte"] + self.assertIn(date(2017, 4, 27), am_holidays) + + def test_wallis_et_futuna(self): + am_holidays = self.prov_holidays["Wallis-et-Futuna"] + self.assertIn(date(2017, 4, 28), am_holidays) + self.assertIn(date(2017, 7, 29), am_holidays) + + def test_martinique(self): + am_holidays = self.prov_holidays["Martinique"] + self.assertIn(date(2017, 5, 22), am_holidays) + + def test_guadeloupe(self): + am_holidays = self.prov_holidays["Guadeloupe"] + self.assertIn(date(2017, 5, 27), am_holidays) + self.assertIn(date(2017, 7, 21), am_holidays) + + def test_guyane(self): + am_holidays = self.prov_holidays["Guyane"] + self.assertIn(date(2017, 6, 10), am_holidays) + + def test_polynesie_francaise(self): + am_holidays = self.prov_holidays["Polynésie Française"] + self.assertIn(date(2017, 6, 29), am_holidays) + + def test_nouvelle_caledonie(self): + am_holidays = self.prov_holidays["Nouvelle-Calédonie"] + self.assertIn(date(2017, 9, 24), am_holidays) + + def test_saint_barthelemy(self): + am_holidays = self.prov_holidays["Saint-Barthélémy"] + self.assertIn(date(2017, 10, 9), am_holidays) + + def test_la_reunion(self): + am_holidays = self.prov_holidays["La Réunion"] + self.assertIn(date(2017, 12, 20), am_holidays) diff --git a/test/countries/test_germany.py b/test/countries/test_germany.py new file mode 100644 index 000000000..5810c7175 --- /dev/null +++ b/test/countries/test_germany.py @@ -0,0 +1,332 @@ +# -*- coding: utf-8 -*- + +# python-holidays +# --------------- +# A fast, efficient Python library for generating country, province and state +# specific sets of holidays on the fly. It aims to make determining whether a +# specific date is a holiday as fast and flexible as possible. +# +# Author: ryanss (c) 2014-2017 +# dr-prodigy (c) 2017-2021 +# Website: https://github.com/dr-prodigy/python-holidays +# License: MIT (see LICENSE file) + +import unittest +from itertools import product + +from datetime import date + +import holidays + + +class TestDE(unittest.TestCase): + def setUp(self): + self.holidays = holidays.DE() + self.prov_hols = { + prov: holidays.DE(prov=prov) for prov in holidays.DE.PROVINCES + } + + def test_no_data_before_1990(self): + de_1989 = sum( + holidays.DE(years=[1989], prov=p) for p in holidays.DE.PROVINCES + ) + self.assertEqual(len(de_1989), 0) + + def test_all_holidays_present(self): + de_2015 = sum( + holidays.DE(years=[2015], prov=p) for p in holidays.DE.PROVINCES + ) + in_2015 = sum((de_2015.get_list(key) for key in de_2015), []) + all_de = [ + "Neujahr", + "Heilige Drei Könige", + "Karfreitag", + "Ostersonntag", + "Ostermontag", + "Erster Mai", + "Christi Himmelfahrt", + "Pfingstsonntag", + "Pfingstmontag", + "Fronleichnam", + "Mariä Himmelfahrt", + "Tag der Deutschen Einheit", + "Reformationstag", + "Allerheiligen", + "Buß- und Bettag", + "Erster Weihnachtstag", + "Zweiter Weihnachtstag", + ] + + for holiday in all_de: + self.assertIn(holiday, in_2015, "missing: {}".format(holiday)) + for holiday in in_2015: + self.assertIn(holiday, all_de, "extra: {}".format(holiday)) + + def test_fixed_holidays(self): + fixed_days_whole_country = ( + (1, 1), # Neujahr + (5, 1), # Maifeiertag + (10, 3), # Tag der Deutschen Einheit + (12, 25), # Erster Weihnachtstag + (12, 26), # Zweiter Weihnachtstag + ) + + for y, (m, d) in product(range(1991, 2050), fixed_days_whole_country): + self.assertIn(date(y, m, d), self.holidays) + + def test_tag_der_deutschen_einheit_in_1990(self): + self.assertIn(date(1990, 10, 3), self.holidays) + + def test_heilige_drei_koenige(self): + provinces_that_have = {"BW", "BY", "BYP", "ST"} + provinces_that_dont = set(holidays.DE.PROVINCES) - provinces_that_have + + for province, year in product(provinces_that_have, range(1991, 2050)): + self.assertIn(date(year, 1, 6), self.prov_hols[province]) + for province, year in product(provinces_that_dont, range(1991, 2050)): + self.assertNotIn(date(year, 1, 6), self.prov_hols[province]) + + def test_karfreitag(self): + known_good = [ + (2014, 4, 18), + (2015, 4, 3), + (2016, 3, 25), + (2017, 4, 14), + (2018, 3, 30), + (2019, 4, 19), + (2020, 4, 10), + (2021, 4, 2), + (2022, 4, 15), + (2023, 4, 7), + (2024, 3, 29), + ] + + for province, (y, m, d) in product(holidays.DE.PROVINCES, known_good): + self.assertIn(date(y, m, d), self.prov_hols[province]) + + def test_ostersonntag(self): + known_good = [ + (2014, 4, 20), + (2015, 4, 5), + (2016, 3, 27), + (2017, 4, 16), + (2018, 4, 1), + (2019, 4, 21), + (2020, 4, 12), + (2021, 4, 4), + (2022, 4, 17), + (2023, 4, 9), + (2024, 3, 31), + ] + provinces_that_have = {"BB"} + provinces_that_dont = set(holidays.DE.PROVINCES) - provinces_that_have + + for province, (y, m, d) in product(provinces_that_have, known_good): + self.assertIn(date(y, m, d), self.prov_hols[province]) + for province, (y, m, d) in product(provinces_that_dont, known_good): + self.assertNotIn(date(y, m, d), self.prov_hols[province]) + + def test_ostermontag(self): + known_good = [ + (2014, 4, 21), + (2015, 4, 6), + (2016, 3, 28), + (2017, 4, 17), + (2018, 4, 2), + (2019, 4, 22), + (2020, 4, 13), + (2021, 4, 5), + (2022, 4, 18), + (2023, 4, 10), + (2024, 4, 1), + ] + + for province, (y, m, d) in product(holidays.DE.PROVINCES, known_good): + self.assertIn(date(y, m, d), self.prov_hols[province]) + + def test_75_jahrestag_beendigung_zweiter_weltkrieg(self): + known_good = [(2020, 5, 8)] + provinces_that_have = {"BE"} + provinces_that_dont = set(holidays.DE.PROVINCES) - provinces_that_have + + for province, (y, m, d) in product(provinces_that_have, known_good): + self.assertIn(date(y, m, d), self.prov_hols[province]) + for province, (y, m, d) in product(provinces_that_dont, known_good): + self.assertNotIn(date(y, m, d), self.prov_hols[province]) + + def test_christi_himmelfahrt(self): + known_good = [ + (2014, 5, 29), + (2015, 5, 14), + (2016, 5, 5), + (2017, 5, 25), + (2018, 5, 10), + (2019, 5, 30), + (2020, 5, 21), + (2021, 5, 13), + (2022, 5, 26), + (2023, 5, 18), + (2024, 5, 9), + ] + + for province, (y, m, d) in product(holidays.DE.PROVINCES, known_good): + self.assertIn(date(y, m, d), self.prov_hols[province]) + + def test_weltkindertag(self): + known_good = [(2019, 9, 20), (2021, 9, 20)] + + provinces_that_have = {"TH"} + provinces_that_dont = set(holidays.DE.PROVINCES) - provinces_that_have + for province, (y, m, d) in product(provinces_that_have, known_good): + self.assertIn(date(y, m, d), self.prov_hols[province]) + for province, (y, m, d) in product(provinces_that_dont, known_good): + self.assertNotIn(date(y, m, d), self.prov_hols[province]) + + def test_frauentag(self): + known_good = [ + (2019, 3, 8), + ] + + provinces_that_have = {"BE"} + provinces_that_dont = set(holidays.DE.PROVINCES) - provinces_that_have + for province, (y, m, d) in product(provinces_that_have, known_good): + self.assertIn(date(y, m, d), self.prov_hols[province]) + for province, (y, m, d) in product(provinces_that_dont, known_good): + self.assertNotIn(date(y, m, d), self.prov_hols[province]) + + def test_pfingstsonntag(self): + known_good = [ + (2014, 6, 8), + (2015, 5, 24), + (2016, 5, 15), + (2017, 6, 4), + (2018, 5, 20), + (2019, 6, 9), + (2020, 5, 31), + (2021, 5, 23), + (2022, 6, 5), + (2023, 5, 28), + (2024, 5, 19), + ] + provinces_that_have = {"BB"} + provinces_that_dont = set(holidays.DE.PROVINCES) - provinces_that_have + + for province, (y, m, d) in product(provinces_that_have, known_good): + self.assertIn(date(y, m, d), self.prov_hols[province]) + for province, (y, m, d) in product(provinces_that_dont, known_good): + self.assertNotIn(date(y, m, d), self.prov_hols[province]) + + def test_pfingstmontag(self): + known_good = [ + (2014, 6, 9), + (2015, 5, 25), + (2016, 5, 16), + (2017, 6, 5), + (2018, 5, 21), + (2019, 6, 10), + (2020, 6, 1), + (2021, 5, 24), + (2022, 6, 6), + (2023, 5, 29), + (2024, 5, 20), + ] + + for province, (y, m, d) in product(holidays.DE.PROVINCES, known_good): + self.assertIn(date(y, m, d), self.prov_hols[province]) + + def test_fronleichnam(self): + known_good = [ + (2014, 6, 19), + (2015, 6, 4), + (2016, 5, 26), + (2017, 6, 15), + (2018, 5, 31), + (2019, 6, 20), + (2020, 6, 11), + (2021, 6, 3), + (2022, 6, 16), + (2023, 6, 8), + (2024, 5, 30), + ] + provinces_that_have = {"BW", "BY", "BYP", "HE", "NW", "RP", "SL"} + provinces_that_dont = set(holidays.DE.PROVINCES) - provinces_that_have + + for province, (y, m, d) in product(provinces_that_have, known_good): + self.assertIn(date(y, m, d), self.prov_hols[province]) + for province, (y, m, d) in product(provinces_that_dont, known_good): + self.assertNotIn(date(y, m, d), self.prov_hols[province]) + + def test_mariae_himmelfahrt(self): + provinces_that_have = {"BY", "SL"} + provinces_that_dont = set(holidays.DE.PROVINCES) - provinces_that_have + + for province, year in product(provinces_that_have, range(1991, 2050)): + self.assertIn(date(year, 8, 15), self.prov_hols[province]) + for province, year in product(provinces_that_dont, range(1991, 2050)): + self.assertNotIn(date(year, 8, 15), self.prov_hols[province]) + + def test_reformationstag(self): + prov_that_have = {"BB", "MV", "SN", "ST", "TH"} + prov_yes_since_2018 = prov_that_have.union({"HB", "HH", "NI", "SH"}) + prov_that_dont = set(holidays.DE.PROVINCES) - prov_that_have + prov_not_since_2018 = set(holidays.DE.PROVINCES) - prov_yes_since_2018 + + for province, year in product(prov_that_have, range(1991, 2050)): + # in 2017 all states got the reformationstag for that year + if year == 2017: + continue + self.assertIn(date(year, 10, 31), self.prov_hols[province]) + # additional provinces got this holiday 2018 + for province, year in product(prov_yes_since_2018, range(2018, 2050)): + self.assertIn(date(year, 10, 31), self.prov_hols[province]) + for province, year in product(prov_that_dont, range(1991, 2017)): + self.assertNotIn(date(year, 10, 31), self.prov_hols[province]) + for province, year in product(prov_not_since_2018, range(2018, 2050)): + self.assertNotIn(date(year, 10, 31), self.prov_hols[province]) + # check the 2017 case where all states have the reformationstag + for province in holidays.DE.PROVINCES: + self.assertIn(date(2017, 10, 31), self.prov_hols[province]) + + def test_allerheiligen(self): + provinces_that_have = {"BW", "BY", "BYP", "NW", "RP", "SL"} + provinces_that_dont = set(holidays.DE.PROVINCES) - provinces_that_have + + for province, year in product(provinces_that_have, range(1991, 2050)): + self.assertIn(date(year, 11, 1), self.prov_hols[province]) + for province, year in product(provinces_that_dont, range(1991, 2050)): + self.assertNotIn(date(year, 11, 1), self.prov_hols[province]) + + def test_buss_und_bettag(self): + known_good = [ + (2014, 11, 19), + (2015, 11, 18), + (2016, 11, 16), + (2017, 11, 22), + (2018, 11, 21), + (2019, 11, 20), + (2020, 11, 18), + (2021, 11, 17), + (2022, 11, 16), + (2023, 11, 22), + (2024, 11, 20), + ] + provinces_that_have = {"SN"} + provinces_that_dont = set(holidays.DE.PROVINCES) - provinces_that_have + + for province, (y, m, d) in product(provinces_that_have, known_good): + self.assertIn(date(y, m, d), self.prov_hols[province]) + for province, (y, m, d) in product(provinces_that_dont, known_good): + self.assertNotIn(date(y, m, d), self.prov_hols[province]) + + def test_internationaler_frauentag(self): + prov_that_have = {"BE"} + prov_that_dont = set(holidays.DE.PROVINCES) - prov_that_have + + for province, year in product( + holidays.DE.PROVINCES, range(1991, 2018) + ): + self.assertNotIn(date(year, 3, 8), self.prov_hols[province]) + for province, year in product(prov_that_have, range(2019, 2050)): + self.assertIn(date(year, 3, 8), self.prov_hols[province]) + for province, year in product(prov_that_dont, range(2019, 2050)): + self.assertNotIn(date(year, 3, 8), self.prov_hols[province]) diff --git a/test/countries/test_greece.py b/test/countries/test_greece.py new file mode 100644 index 000000000..90d52ba39 --- /dev/null +++ b/test/countries/test_greece.py @@ -0,0 +1,101 @@ +# -*- coding: utf-8 -*- + +# python-holidays +# --------------- +# A fast, efficient Python library for generating country, province and state +# specific sets of holidays on the fly. It aims to make determining whether a +# specific date is a holiday as fast and flexible as possible. +# +# Author: ryanss (c) 2014-2017 +# dr-prodigy (c) 2017-2021 +# Website: https://github.com/dr-prodigy/python-holidays +# License: MIT (see LICENSE file) + +import unittest + +from datetime import date + +import holidays + + +class TestGreece(unittest.TestCase): + def setUp(self): + self.gr_holidays = holidays.GR() + + def test_fixed_holidays(self): + years = range(2000, 2025) + for y in years: + fdays = ( + (date(y, 1, 1), "Πρωτοχρονιά [New Year's Day]"), + (date(y, 1, 6), "Θεοφάνεια [Epiphany]"), + ( + date(y, 3, 25), + "Εικοστή Πέμπτη Μαρτίου " + "[Independence Day]", + ), + (date(y, 5, 1), "Εργατική Πρωτομαγιά [Labour day]"), + ( + date(y, 8, 15), + "Κοίμηση της Θεοτόκου " + "[Assumption of Mary]", + ), + (date(y, 10, 28), "Ημέρα του Όχι [Ochi Day]"), + (date(y, 12, 25), "Χριστούγεννα [Christmas]"), + ( + date(y, 12, 26), + "Επόμενη ημέρα των Χριστουγέννων " + + "[Day after Christmas]", + ), + ) + + for (d, dstr) in fdays: + self.assertIn(d, self.gr_holidays) + self.assertIn(dstr, self.gr_holidays[d]) + + def test_gr_clean_monday(self): + checkdates = ( + date(2018, 2, 19), + date(2019, 3, 11), + date(2020, 3, 2), + date(2021, 3, 15), + date(2022, 3, 7), + date(2023, 2, 27), + date(2024, 3, 18), + ) + + for d in checkdates: + self.assertIn(d, self.gr_holidays) + self.assertIn("Καθαρά Δευτέρα [Clean Monday]", self.gr_holidays[d]) + + def test_gr_easter_monday(self): + checkdates = ( + date(2018, 4, 9), + date(2019, 4, 29), + date(2020, 4, 20), + date(2021, 5, 3), + date(2022, 4, 25), + date(2023, 4, 17), + date(2024, 5, 6), + ) + + for d in checkdates: + self.assertIn(d, self.gr_holidays) + self.assertIn( + "Δευτέρα του Πάσχα [Easter Monday]", self.gr_holidays[d] + ) + + def test_gr_monday_of_the_holy_spirit(self): + checkdates = ( + date(2018, 5, 28), + date(2019, 6, 17), + date(2020, 6, 8), + date(2021, 6, 21), + date(2022, 6, 13), + date(2023, 6, 5), + date(2024, 6, 24), + ) + + for d in checkdates: + self.assertIn(d, self.gr_holidays) + self.assertIn( + "Δευτέρα του Αγίου Πνεύματος " + "[Monday of the Holy Spirit]", + self.gr_holidays[d], + ) diff --git a/test/countries/test_honduras.py b/test/countries/test_honduras.py new file mode 100644 index 000000000..ac39beaf3 --- /dev/null +++ b/test/countries/test_honduras.py @@ -0,0 +1,40 @@ +# -*- coding: utf-8 -*- + +# python-holidays +# --------------- +# A fast, efficient Python library for generating country, province and state +# specific sets of holidays on the fly. It aims to make determining whether a +# specific date is a holiday as fast and flexible as possible. +# +# Author: ryanss (c) 2014-2017 +# dr-prodigy (c) 2017-2021 +# Website: https://github.com/dr-prodigy/python-holidays +# License: MIT (see LICENSE file) + +import unittest + +from datetime import date + +import holidays + + +class TestHonduras(unittest.TestCase): + def setUp(self): + self.holidays = holidays.HND() + + def test_2014(self): + self.assertIn(date(2014, 10, 3), self.holidays) # Morazan's Day + self.assertIn(date(2014, 10, 12), self.holidays) # Columbus Day + self.assertIn(date(2014, 10, 21), self.holidays) # Army Day + + def test_2018(self): + self.assertIn(date(2018, 1, 1), self.holidays) # New Year + self.assertIn(date(2018, 4, 14), self.holidays) # America's Day + self.assertIn(date(2018, 5, 1), self.holidays) # Workers' Day + self.assertNotIn(date(2018, 5, 6), self.holidays) # Mother's Day + self.assertIn(date(2018, 5, 13), self.holidays) # Mother's Day + self.assertIn(date(2018, 9, 10), self.holidays) # Children weekend + self.assertIn(date(2018, 9, 15), self.holidays) # Independence Day + self.assertIn(date(2018, 9, 17), self.holidays) # Teacher's Day + self.assertIn(date(2018, 10, 3), self.holidays) # Morazan's weekend + self.assertIn(date(2018, 12, 25), self.holidays) # Christmas diff --git a/test/countries/test_hongkong.py b/test/countries/test_hongkong.py new file mode 100644 index 000000000..a5c39f338 --- /dev/null +++ b/test/countries/test_hongkong.py @@ -0,0 +1,403 @@ +# -*- coding: utf-8 -*- + +# python-holidays +# --------------- +# A fast, efficient Python library for generating country, province and state +# specific sets of holidays on the fly. It aims to make determining whether a +# specific date is a holiday as fast and flexible as possible. +# +# Author: ryanss (c) 2014-2017 +# dr-prodigy (c) 2017-2021 +# Website: https://github.com/dr-prodigy/python-holidays +# License: MIT (see LICENSE file) + +import unittest + +from datetime import date + +import holidays + + +class TestHongKong(unittest.TestCase): + def setUp(self): + self.holidays = holidays.HK() + + def test_common(self): + self.assertTrue(self.holidays.isLeapYear(2000)) + self.assertFalse(self.holidays.isLeapYear(2100)) + holidaysNoObserved = holidays.HK(observed=False) + self.assertEqual( + holidaysNoObserved[date(2019, 1, 1)], "The first day of January" + ) + self.assertEqual( + self.holidays[date(2015, 9, 3)], + "The 70th " + + "anniversary day of the victory of the Chinese " + + "people's war of resistance against Japanese " + + "aggression", + ) + + def test_first_day_of_january(self): + exception_years = [2006, 2012, 2017] + for year in range(2006, 2021): + if year in exception_years: + self.assertEqual( + self.holidays[date(year, 1, 2)], + "The day following the first day of January", + ) + else: + self.assertEqual( + self.holidays[date(year, 1, 1)], "The first day of January" + ) + + def test_lunar_new_year(self): + for year, month, day in [(2006, 1, 28), (2007, 2, 17), (2010, 2, 13)]: + self.assertEqual( + self.holidays[date(year, month, day)], + "The day preceding Lunar New Year's Day", + ) + + for year, month, day in [ + (2008, 2, 7), + (2009, 1, 26), + (2011, 2, 3), + (2012, 1, 23), + (2014, 1, 31), + (2015, 2, 19), + (2016, 2, 8), + (2017, 1, 28), + (2018, 2, 16), + (2019, 2, 5), + (2020, 1, 25), + ]: + self.assertEqual( + self.holidays[date(year, month, day)], "Lunar New Year's Day" + ) + + for year, month, day in [ + (2006, 1, 30), + (2007, 2, 19), + (2008, 2, 8), + (2009, 1, 27), + (2010, 2, 15), + (2011, 2, 4), + (2012, 1, 24), + (2013, 2, 11), + (2014, 2, 1), + (2015, 2, 20), + (2016, 2, 9), + (2018, 2, 17), + (2019, 2, 6), + ]: + self.assertEqual( + self.holidays[date(year, month, day)], + "The second day of Lunar New Year", + ) + + for year, month, day in [ + (2006, 1, 31), + (2007, 2, 20), + (2008, 2, 9), + (2009, 1, 28), + (2010, 2, 16), + (2011, 2, 5), + (2012, 1, 25), + (2013, 2, 12), + (2015, 2, 21), + (2016, 2, 10), + (2017, 1, 30), + (2019, 2, 7), + (2020, 1, 27), + ]: + self.assertEqual( + self.holidays[date(year, month, day)], + "The third day of Lunar New Year", + ) + + for year, month, day in [ + (2013, 2, 13), + (2014, 2, 3), + (2017, 1, 31), + (2020, 1, 28), + (2018, 2, 19), + ]: + self.assertEqual( + self.holidays[date(year, month, day)], + "The fourth day of Lunar New Year", + ) + + def test_ching_ming_festival(self): + for year, month, day in [ + (2006, 4, 5), + (2007, 4, 5), + (2008, 4, 4), + (2009, 4, 4), + (2010, 4, 5), + (2011, 4, 5), + (2012, 4, 4), + (2013, 4, 4), + (2014, 4, 5), + (2016, 4, 4), + (2017, 4, 4), + (2018, 4, 5), + (2019, 4, 5), + (2020, 4, 4), + ]: + self.assertEqual( + self.holidays[date(year, month, day)], "Ching Ming Festival" + ) + + self.assertEqual( + self.holidays[date(2015, 4, 6)], + "The day " + "following Ching Ming Festival", + ) + + def test_easter(self): + for year, month, day in [ + (2006, 4, 14), + (2007, 4, 6), + (2008, 3, 21), + (2009, 4, 10), + (2010, 4, 2), + (2011, 4, 22), + (2012, 4, 6), + (2013, 3, 29), + (2014, 4, 18), + (2015, 4, 3), + (2016, 3, 25), + (2017, 4, 14), + (2018, 3, 30), + (2019, 4, 19), + (2020, 4, 10), + ]: + self.assertEqual( + self.holidays[date(year, month, day)], "Good Friday" + ) + + for year, month, day in [ + (2019, 4, 20), + (2013, 3, 30), + (2020, 4, 11), + (2009, 4, 11), + (2018, 3, 31), + (2008, 3, 22), + (2011, 4, 23), + (2010, 4, 3), + (2015, 4, 4), + (2006, 4, 15), + (2017, 4, 15), + (2016, 3, 26), + (2012, 4, 7), + (2007, 4, 7), + (2014, 4, 19), + ]: + self.assertEqual( + self.holidays[date(year, month, day)], + "The day following Good Friday", + ) + + for year, month, day in [ + (2006, 4, 17), + (2007, 4, 9), + (2009, 4, 13), + (2008, 3, 24), + (2011, 4, 25), + (2012, 4, 9), + (2013, 4, 1), + (2014, 4, 21), + (2016, 3, 28), + (2017, 4, 17), + (2018, 4, 2), + (2019, 4, 22), + (2020, 4, 13), + ]: + self.assertEqual( + self.holidays[date(year, month, day)], "Easter Monday" + ) + + name = "The day following Easter Monday" + self.assertEqual(self.holidays[date(2010, 4, 6)], name) + self.assertEqual(self.holidays[date(2015, 4, 7)], name) + + def test_labour_day(self): + for year in [ + 2006, + 2007, + 2008, + 2009, + 2010, + 2012, + 2013, + 2014, + 2015, + 2017, + 2018, + 2019, + 2020, + ]: + self.assertEqual(self.holidays[date(year, 5, 1)], "Labour Day") + + name = "The day following Labour Day" + self.assertEqual(self.holidays[date(2011, 5, 2)], name) + self.assertEqual(self.holidays[date(2016, 5, 2)], name) + + def test_tuen_ng_festival(self): + for year, month, day in [ + (2006, 5, 31), + (2007, 6, 19), + (2009, 5, 28), + (2010, 6, 16), + (2011, 6, 6), + (2012, 6, 23), + (2013, 6, 12), + (2014, 6, 2), + (2015, 6, 20), + (2016, 6, 9), + (2017, 5, 30), + (2018, 6, 18), + (2019, 6, 7), + (2020, 6, 25), + ]: + self.assertEqual( + self.holidays[date(year, month, day)], "Tuen " + "Ng Festival" + ) + + self.assertEqual( + self.holidays[date(2008, 6, 9)], + "The day " + "following Tuen Ng Festival", + ) + + def test_hksar_day(self): + for year in [ + 2006, + 2008, + 2009, + 2010, + 2011, + 2013, + 2014, + 2015, + 2016, + 2017, + 2019, + 2020, + ]: + self.assertEqual( + self.holidays[date(year, 7, 1)], + "Hong Kong " + + "Special Administrative Region Establishment " + + "Day", + ) + + name = ( + "The day following Hong Kong Special Administrative Region " + + "Establishment Day" + ) + self.assertEqual(self.holidays[date(2007, 7, 2)], name) + self.assertEqual(self.holidays[date(2012, 7, 2)], name) + self.assertEqual(self.holidays[date(2018, 7, 2)], name) + + def test_mid_autumn_festival(self): + for year, month, day in [ + (2006, 10, 7), + (2007, 9, 26), + (2008, 9, 15), + (2010, 9, 23), + (2011, 9, 13), + (2012, 10, 1), + (2013, 9, 20), + (2014, 9, 9), + (2015, 9, 28), + (2016, 9, 16), + (2017, 10, 5), + (2018, 9, 25), + (2019, 9, 14), + (2020, 10, 2), + ]: + self.assertEqual( + self.holidays[date(year, month, day)], + "The " + "day following the Chinese Mid-Autumn Festival", + ) + + self.assertEqual( + self.holidays[date(2009, 10, 3)], + "Chinese " + "Mid-Autumn Festival", + ) + + def test_national_day(self): + for year in [ + 2007, + 2008, + 2009, + 2010, + 2011, + 2013, + 2014, + 2015, + 2016, + 2018, + 2019, + 2020, + ]: + self.assertEqual(self.holidays[date(year, 10, 1)], "National Day") + + name = "The day following National Day" + self.assertEqual(self.holidays[date(2006, 10, 2)], name) + self.assertEqual(self.holidays[date(2012, 10, 2)], name) + self.assertEqual(self.holidays[date(2017, 10, 2)], name) + + def test_chung_yeung_festival(self): + for year, month, day in [ + (2006, 10, 30), + (2007, 10, 19), + (2008, 10, 7), + (2009, 10, 26), + (2010, 10, 16), + (2011, 10, 5), + (2012, 10, 23), + (2014, 10, 2), + (2015, 10, 21), + (2017, 10, 28), + (2018, 10, 17), + (2019, 10, 7), + ]: + self.assertEqual( + self.holidays[date(year, month, day)], + "Chung " + "Yeung Festival", + ) + + name = "The day following Chung Yeung Festival" + self.assertEqual(self.holidays[date(2013, 10, 14)], name) + self.assertEqual(self.holidays[date(2016, 10, 10)], name) + self.assertEqual(self.holidays[date(2020, 10, 26)], name) + + def test_christmas_day(self): + for year in [ + 2006, + 2007, + 2008, + 2009, + 2010, + 2012, + 2013, + 2014, + 2015, + 2017, + 2018, + 2019, + 2020, + ]: + self.assertEqual( + self.holidays[date(year, 12, 25)], "Christmas " + "Day" + ) + + name = "The first weekday after Christmas Day" + for year in range(2006, 2010): + self.assertEqual(self.holidays[date(year, 12, 26)], name) + self.assertEqual(self.holidays[date(2010, 12, 27)], name) + for year in range(2011, 2021): + self.assertEqual(self.holidays[date(year, 12, 26)], name) + + name = "The second weekday after Christmas Day" + self.assertEqual(self.holidays[date(2011, 12, 27)], name) + self.assertEqual(self.holidays[date(2016, 12, 27)], name) diff --git a/test/countries/test_hungary.py b/test/countries/test_hungary.py new file mode 100644 index 000000000..e28113061 --- /dev/null +++ b/test/countries/test_hungary.py @@ -0,0 +1,130 @@ +# -*- coding: utf-8 -*- + +# python-holidays +# --------------- +# A fast, efficient Python library for generating country, province and state +# specific sets of holidays on the fly. It aims to make determining whether a +# specific date is a holiday as fast and flexible as possible. +# +# Author: ryanss (c) 2014-2017 +# dr-prodigy (c) 2017-2021 +# Website: https://github.com/dr-prodigy/python-holidays +# License: MIT (see LICENSE file) + +import unittest + +from datetime import date + +import holidays + + +class TestHungary(unittest.TestCase): + def setUp(self): + self.holidays = holidays.HU(observed=False) + self.next_year = date.today().year + 1 + + def test_national_day_was_not_celebrated_during_communism(self): + for year in range(1951, 1988): + self.assertNotIn(date(year, 3, 15), self.holidays) + self.assertIn(date(1989, 3, 15), self.holidays) + + def test_holidays_during_communism(self): + for year in range(1950, 1989): + self.assertIn(date(year, 3, 21), self.holidays) + self.assertIn(date(year, 4, 4), self.holidays) + if year != 1956: + self.assertIn(date(year, 11, 7), self.holidays) + self.assertIn(date(1989, 3, 21), self.holidays) + + def test_foundation_day_renamed_during_communism(self): + for year in range(1950, 1990): + self.assertEqual( + self.holidays[date(year, 8, 20)], "A kenyér ünnepe" + ) + + def test_christian_holidays_2nd_day_was_not_held_in_1955(self): + hu_1955 = holidays.Hungary(years=[1955]) + self.assertNotIn(date(1955, 4, 11), hu_1955) + self.assertNotIn(date(1955, 12, 26), hu_1955) + + def test_good_friday_since_2017(self): + self.assertNotIn(date(2016, 3, 25), self.holidays) + self.assertIn(date(2017, 4, 14), self.holidays) + self.assertIn(date(2018, 3, 30), self.holidays) + + def test_whit_monday_since_1992(self): + self.assertNotIn(date(1991, 5, 20), self.holidays) + self.assertIn(date(1992, 6, 8), self.holidays) + + def test_labour_day_since_1946(self): + self.assertNotIn(date(1945, 5, 1), self.holidays) + for year in range(1946, self.next_year): + self.assertIn(date(year, 5, 1), self.holidays) + + def test_labour_day_was_doubled_in_early_50s(self): + for year in range(1950, 1954): + self.assertIn(date(year, 5, 2), self.holidays) + + def test_october_national_day_since_1991(self): + for year in range(1991, self.next_year): + self.assertIn(date(year, 10, 23), self.holidays) + + def test_all_saints_day_since_1999(self): + for year in range(1999, self.next_year): + self.assertIn(date(year, 11, 1), self.holidays) + + def test_additional_day_off(self): + observed_days_off = holidays.HU( + observed=True, years=range(2010, self.next_year) + ) + for day in [ + date(2010, 12, 24), + date(2011, 3, 14), + date(2011, 10, 31), + date(2012, 3, 16), + date(2012, 4, 30), + date(2012, 10, 22), + date(2012, 11, 2), + date(2012, 12, 24), + date(2013, 8, 19), + date(2013, 12, 24), + date(2013, 12, 27), + date(2014, 5, 2), + date(2014, 10, 24), + date(2014, 12, 24), + date(2015, 1, 2), + date(2015, 8, 21), + date(2015, 12, 24), + date(2016, 3, 14), + date(2016, 10, 31), + date(2018, 3, 16), + date(2018, 4, 30), + date(2018, 10, 22), + date(2018, 11, 2), + date(2018, 12, 24), + date(2018, 12, 31), + date(2019, 8, 19), + date(2019, 12, 24), + date(2019, 12, 27), + ]: + self.assertNotIn(day, self.holidays) + self.assertIn(day, observed_days_off) + + def test_monday_new_years_eve_day_off(self): + observed_day_off = holidays.HU(observed=True) + self.assertIn(date(2018, 12, 31), observed_day_off) + + def test_2018(self): + self.assertIn(date(2018, 1, 1), self.holidays) # newyear + self.assertIn(date(2018, 3, 15), self.holidays) # national holiday + self.assertIn(date(2018, 3, 30), self.holidays) # good friday + self.assertIn(date(2018, 4, 1), self.holidays) # easter 1. + self.assertIn(date(2018, 4, 2), self.holidays) # easter 2. + self.assertIn(date(2018, 5, 1), self.holidays) # Workers' Day + self.assertIn(date(2018, 5, 20), self.holidays) # Pentecost + self.assertIn(date(2018, 5, 21), self.holidays) # Pentecost monday + self.assertIn(date(2018, 8, 20), self.holidays) # State Foundation Day + self.assertIn(date(2018, 10, 23), self.holidays) # National Day + self.assertIn(date(2018, 11, 1), self.holidays) # All Saints' Day + self.assertIn(date(2018, 12, 25), self.holidays) # First christmas + self.assertIn(date(2018, 12, 26), self.holidays) # Second christmas diff --git a/test/countries/test_iceland.py b/test/countries/test_iceland.py new file mode 100644 index 000000000..7aa2f44a9 --- /dev/null +++ b/test/countries/test_iceland.py @@ -0,0 +1,51 @@ +# -*- coding: utf-8 -*- + +# python-holidays +# --------------- +# A fast, efficient Python library for generating country, province and state +# specific sets of holidays on the fly. It aims to make determining whether a +# specific date is a holiday as fast and flexible as possible. +# +# Author: ryanss (c) 2014-2017 +# dr-prodigy (c) 2017-2021 +# Website: https://github.com/dr-prodigy/python-holidays +# License: MIT (see LICENSE file) + +import unittest + +from datetime import date, datetime + +import holidays + + +class TestIceland(unittest.TestCase): + def setUp(self): + self.holidays = holidays.Iceland() + self.cur_date = datetime.now() + + def test_new_year(self): + test_date = date(self.cur_date.year, 1, 1) + self.assertEqual(self.holidays.get(test_date), "Nýársdagur") + self.assertIn(test_date, self.holidays) + + def test_maundy_thursday(self): + test_date = date(2019, 4, 18) + self.assertEqual(self.holidays.get(test_date), "Skírdagur") + self.assertIn(test_date, self.holidays) + + def test_first_day_of_summer(self): + test_date = date(2019, 4, 25) + self.assertEqual(self.holidays.get(test_date), "Sumardagurinn fyrsti") + self.assertIn(test_date, self.holidays) + + def test_commerce_day(self): + test_date = date(2019, 8, 5) + self.assertEqual( + self.holidays.get(test_date), "Frídagur verslunarmanna" + ) + self.assertIn(test_date, self.holidays) + + def test_holy_friday(self): + test_date = date(2019, 4, 19) + self.assertEqual(self.holidays.get(test_date), "Föstudagurinn langi") + self.assertIn(test_date, self.holidays) diff --git a/test/countries/test_india.py b/test/countries/test_india.py new file mode 100644 index 000000000..21548eccb --- /dev/null +++ b/test/countries/test_india.py @@ -0,0 +1,84 @@ +# -*- coding: utf-8 -*- + +# python-holidays +# --------------- +# A fast, efficient Python library for generating country, province and state +# specific sets of holidays on the fly. It aims to make determining whether a +# specific date is a holiday as fast and flexible as possible. +# +# Author: ryanss (c) 2014-2017 +# dr-prodigy (c) 2017-2021 +# Website: https://github.com/dr-prodigy/python-holidays +# License: MIT (see LICENSE file) + +import unittest + +from datetime import date + +import holidays + + +class TestIND(unittest.TestCase): + def setUp(self): + self.holidays = holidays.IND() + + def test_2018(self): + self.assertIn(date(2018, 1, 14), self.holidays) + self.assertIn(date(2018, 1, 26), self.holidays) + self.assertIn(date(2018, 10, 2), self.holidays) + self.assertIn(date(2018, 5, 1), self.holidays) + self.assertIn(date(2018, 8, 15), self.holidays) + self.assertIn(date(2018, 10, 2), self.holidays) + self.assertIn(date(2018, 12, 25), self.holidays) + + gj_holidays = holidays.IND(prov="GJ") + as_holidays = holidays.IND(prov="AS") + tn_holidays = holidays.IND(prov="TN") + wb_holidays = holidays.IND(prov="WB") + cg_holidays = holidays.IND(prov="CG") + sk_holidays = holidays.IND(prov="SK") + ka_holidays = holidays.IND(prov="KA") + br_holidays = holidays.IND(prov="BR") + rj_holidays = holidays.IND(prov="RJ") + od_holidays = holidays.IND(prov="OD") + ap_holidays = holidays.IND(prov="AP") + kl_holidays = holidays.IND(prov="KL") + hr_holidays = holidays.IND(prov="HR") + mh_holidays = holidays.IND(prov="MH") + mp_holidays = holidays.IND(prov="MP") + up_holidays = holidays.IND(prov="UP") + uk_holidays = holidays.IND(prov="UK") + ts_holidays = holidays.IND(prov="TS") + + for dt in [date(2018, 1, 14), date(2018, 5, 1), date(2018, 10, 31)]: + self.assertIn(dt, gj_holidays) + for dt in [date(2018, 4, 15), date(2018, 4, 14)]: + self.assertIn(dt, tn_holidays) + self.assertIn(dt, wb_holidays) + for dt in [date(2018, 1, 14), date(2018, 5, 1), date(2018, 10, 31)]: + self.assertIn(dt, gj_holidays) + self.assertIn(date(2018, 3, 22), br_holidays) + self.assertIn(date(2018, 3, 30), rj_holidays) + self.assertIn(date(2018, 6, 15), rj_holidays) + self.assertIn(date(2018, 4, 1), od_holidays) + self.assertIn(date(2018, 4, 6), ts_holidays) + self.assertIn(date(2018, 4, 15), od_holidays) + self.assertIn(date(2018, 4, 14), od_holidays) + self.assertIn(date(2018, 4, 14), br_holidays) + self.assertIn(date(2018, 4, 14), kl_holidays) + self.assertIn(date(2018, 4, 14), up_holidays) + self.assertIn(date(2018, 4, 14), uk_holidays) + self.assertIn(date(2018, 4, 14), hr_holidays) + self.assertIn(date(2018, 4, 14), mh_holidays) + self.assertIn(date(2018, 4, 14), wb_holidays) + self.assertIn(date(2018, 5, 9), wb_holidays) + self.assertIn(date(2018, 4, 15), as_holidays) + self.assertIn(date(2018, 5, 1), mh_holidays) + self.assertIn(date(2018, 5, 16), sk_holidays) + self.assertIn(date(2018, 10, 6), ts_holidays) + self.assertIn(date(2018, 11, 1), ka_holidays) + self.assertIn(date(2018, 11, 1), ap_holidays) + self.assertIn(date(2018, 11, 1), hr_holidays) + self.assertIn(date(2018, 11, 1), mp_holidays) + self.assertIn(date(2018, 11, 1), kl_holidays) + self.assertIn(date(2018, 11, 1), cg_holidays) diff --git a/test/countries/test_ireland.py b/test/countries/test_ireland.py new file mode 100644 index 000000000..ebc90af8a --- /dev/null +++ b/test/countries/test_ireland.py @@ -0,0 +1,101 @@ +# -*- coding: utf-8 -*- + +# python-holidays +# --------------- +# A fast, efficient Python library for generating country, province and state +# specific sets of holidays on the fly. It aims to make determining whether a +# specific date is a holiday as fast and flexible as possible. +# +# Author: ryanss (c) 2014-2017 +# dr-prodigy (c) 2017-2021 +# Website: https://github.com/dr-prodigy/python-holidays +# License: MIT (see LICENSE file) + +import unittest + +from datetime import date +from dateutil.relativedelta import relativedelta + +import holidays + + +class TestIreland(unittest.TestCase): + def setUp(self): + self.holidays = holidays.Ireland() + + def test_2020(self): + self.assertIn("2020-01-01", self.holidays) # New Year's Day + self.assertIn("2020-03-17", self.holidays) # St. Patrick's Day + self.assertIn("2020-04-13", self.holidays) # Easter Monday + self.assertIn("2020-05-04", self.holidays) # May Day in IE + self.assertNotIn("2020-05-08", self.holidays) # May Day in UK not IE + self.assertIn("2020-06-01", self.holidays) # June Bank Holiday + self.assertIn("2020-08-03", self.holidays) # Summer Bank Holiday + self.assertIn("2020-10-26", self.holidays) # October Bank Holiday + self.assertIn("2020-12-25", self.holidays) # Christmas Day + self.assertIn("2020-12-26", self.holidays) # Boxing Day + self.assertIn("2020-12-28", self.holidays) # Boxing Day (Observed) + + def test_may_day(self): + # Specific Ireland "May Day" + for dt in [ + date(1978, 5, 1), + date(1979, 5, 7), + date(1980, 5, 5), + date(1995, 5, 8), + date(1999, 5, 3), + date(2000, 5, 1), + date(2010, 5, 3), + date(2018, 5, 7), + date(2019, 5, 6), + date(2020, 5, 4), + ]: + self.assertIn(dt, self.holidays) + self.assertNotIn(dt + relativedelta(days=-1), self.holidays) + self.assertNotIn(dt + relativedelta(days=+1), self.holidays) + + def test_st_stephens_day(self): + # St. Stephen's Day + self.holidays.observed = False + + for year in range(1900, 2100): + dt = date(year, 12, 26) + self.assertIn(dt, self.holidays) + self.assertNotIn(dt + relativedelta(days=+1), self.holidays) + self.assertNotIn(date(2009, 12, 28), self.holidays) + self.assertNotIn(date(2010, 12, 27), self.holidays) + self.holidays.observed = True + self.assertIn(date(2004, 12, 28), self.holidays) + self.assertIn(date(2010, 12, 28), self.holidays) + for year, day in enumerate( + [ + 26, + 26, + 26, + 28, + 26, + 26, + 26, + 26, + 28, + 28, + 26, + 26, + 26, + 26, + 26, + 26, + 26, + 26, + 26, + 26, + 28, + ], + 2001, + ): + dt = date(year, 12, day) + self.assertIn(dt, self.holidays, dt) + self.assertIn( + self.holidays[dt], + ["St. Stephen's Day", "St. Stephen's Day (Observed)"], + ) diff --git a/test/countries/test_israel.py b/test/countries/test_israel.py new file mode 100644 index 000000000..0e5aff295 --- /dev/null +++ b/test/countries/test_israel.py @@ -0,0 +1,71 @@ +# -*- coding: utf-8 -*- + +# python-holidays +# --------------- +# A fast, efficient Python library for generating country, province and state +# specific sets of holidays on the fly. It aims to make determining whether a +# specific date is a holiday as fast and flexible as possible. +# +# Author: ryanss (c) 2014-2017 +# dr-prodigy (c) 2017-2021 +# Website: https://github.com/dr-prodigy/python-holidays +# License: MIT (see LICENSE file) + +import unittest + +from datetime import date +from dateutil.relativedelta import relativedelta + +import holidays + + +class TestIsrael(unittest.TestCase): + def test_memorial_day(self): + self._test_observed_holidays("Memorial Day") + + def test_independence_day(self): + self._test_observed_holidays("Independence Day") + + def _test_observed_holidays(self, holiday_name): + days_delta = 0 if holiday_name == "Memorial Day" else 1 + + # Postponed + il_holidays = holidays.IL(years=[2017], observed=True) + official_memorial_day = date(2017, 4, 30) + relativedelta( + days=days_delta + ) + observed_memorial_day = date(2017, 5, 1) + relativedelta( + days=days_delta + ) + self.assertIn(official_memorial_day, il_holidays) + self.assertIn(holiday_name, il_holidays[official_memorial_day]) + self.assertIn(observed_memorial_day, il_holidays) + self.assertIn( + holiday_name + " (Observed)", il_holidays[observed_memorial_day] + ) + + # Earlier + il_holidays = holidays.IL(years=[2018], observed=True) + official_memorial_day = date(2018, 4, 19) + relativedelta( + days=days_delta + ) + observed_memorial_day = date(2018, 4, 18) + relativedelta( + days=days_delta + ) + self.assertIn(official_memorial_day, il_holidays) + self.assertIn(holiday_name, il_holidays[official_memorial_day]) + self.assertIn(observed_memorial_day, il_holidays) + self.assertIn( + holiday_name + " (Observed)", il_holidays[observed_memorial_day] + ) + + # On time + il_holidays = holidays.IL(years=[2020], observed=True) + official_memorial_day = date(2020, 4, 28) + relativedelta( + days=days_delta + ) + self.assertIn(official_memorial_day, il_holidays) + self.assertIn(holiday_name, il_holidays[official_memorial_day]) + + for names in il_holidays.values(): + self.assertNotIn(holiday_name + " (Observed)", names) diff --git a/test/countries/test_italy.py b/test/countries/test_italy.py new file mode 100644 index 000000000..789b88e35 --- /dev/null +++ b/test/countries/test_italy.py @@ -0,0 +1,152 @@ +# -*- coding: utf-8 -*- + +# python-holidays +# --------------- +# A fast, efficient Python library for generating country, province and state +# specific sets of holidays on the fly. It aims to make determining whether a +# specific date is a holiday as fast and flexible as possible. +# +# Author: ryanss (c) 2014-2017 +# dr-prodigy (c) 2017-2021 +# Website: https://github.com/dr-prodigy/python-holidays +# License: MIT (see LICENSE file) + +import unittest + +from datetime import date + +import holidays + + +class TestItaly(unittest.TestCase): + def setUp(self): + self.holidays = holidays.IT() + + def test_2017(self): + # https://www.giorni-festivi.it/ + self.assertIn(date(2017, 1, 1), self.holidays) + self.assertIn(date(2017, 1, 6), self.holidays) + self.assertIn(date(2017, 4, 16), self.holidays) + self.assertIn(date(2017, 4, 17), self.holidays) + self.assertIn(date(2017, 4, 25), self.holidays) + self.assertIn(date(2017, 5, 1), self.holidays) + self.assertIn(date(2017, 6, 2), self.holidays) + self.assertIn(date(2017, 8, 15), self.holidays) + self.assertIn(date(2017, 11, 1), self.holidays) + self.assertIn(date(2017, 12, 8), self.holidays) + self.assertIn(date(2017, 12, 25), self.holidays) + self.assertIn(date(2017, 12, 26), self.holidays) + + def test_new_years(self): + for year in range(1974, 2100): + self.assertIn(date(year, 1, 1), self.holidays) + + def test_easter(self): + self.assertIn(date(2017, 4, 16), self.holidays) + + def test_easter_monday(self): + self.assertIn(date(2017, 4, 17), self.holidays) + + def test_republic_day_before_1948(self): + self.holidays = holidays.IT(years=[1947]) + self.assertNotIn(date(1947, 6, 2), self.holidays) + + def test_republic_day_after_1948(self): + self.holidays = holidays.IT(years=[1948]) + self.assertIn(date(1948, 6, 2), self.holidays) + + def test_liberation_day_before_1946(self): + self.holidays = holidays.IT(years=1945) + self.assertNotIn(date(1945, 4, 25), self.holidays) + + def test_liberation_day_after_1946(self): + self.holidays = holidays.IT(years=1946) + self.assertIn(date(1946, 4, 25), self.holidays) + + def test_christmas(self): + self.holidays = holidays.IT(years=2017) + self.assertIn(date(2017, 12, 25), self.holidays) + + def test_saint_stephan(self): + self.holidays = holidays.IT(years=2017) + self.assertIn(date(2017, 12, 26), self.holidays) + + def test_province_specific_days(self): + prov_an = holidays.IT(prov="AN", years=[2017]) + prov_ao = holidays.IT(prov="AO", years=[2017]) + prov_ba = holidays.IT(prov="BA", years=[2017]) + prov_bl = holidays.IT(prov="BL", years=[2017]) + prov_bo = holidays.IT(prov="BO", years=[2017]) + prov_bz = holidays.IT(prov="BZ", years=[2017]) + prov_bs = holidays.IT(prov="BS", years=[2017]) + prov_cb = holidays.IT(prov="CB", years=[2017]) + prov_ch = holidays.IT(prov="CH", years=[2017]) + prov_cs = holidays.IT(prov="CS", years=[2017]) + prov_ct = holidays.IT(prov="CT", years=[2017]) + prov_en = holidays.IT(prov="EN", years=[2017]) + prov_fc = holidays.IT(prov="FC", years=[2017]) + prov_fe = holidays.IT(prov="FE", years=[2017]) + prov_fi = holidays.IT(prov="FI", years=[2017]) + prov_fr = holidays.IT(prov="FR", years=[2017]) + prov_ge = holidays.IT(prov="GE", years=[2017]) + prov_go = holidays.IT(prov="GO", years=[2017]) + prov_is = holidays.IT(prov="IS", years=[2017]) + prov_kr = holidays.IT(prov="KR", years=[2017]) + prov_lt = holidays.IT(prov="LT", years=[2017]) + prov_mb = holidays.IT(prov="MB", years=[2017]) + prov_me = holidays.IT(prov="ME", years=[2017]) + prov_mi = holidays.IT(prov="MI", years=[2017]) + prov_mn = holidays.IT(prov="MN", years=[2017]) + prov_mo = holidays.IT(prov="MO", years=[2017]) + prov_ms = holidays.IT(prov="MS", years=[2017]) + prov_na = holidays.IT(prov="NA", years=[2017]) + prov_pa = holidays.IT(prov="PA", years=[2017]) + prov_pc = holidays.IT(prov="PC", years=[2017]) + prov_pd = holidays.IT(prov="PD", years=[2017]) + prov_pg = holidays.IT(prov="PG", years=[2017]) + prov_pr = holidays.IT(prov="PR", years=[2017]) + prov_rm = holidays.IT(prov="RM", years=[2017]) + prov_sp = holidays.IT(prov="SP", years=[2017]) + prov_to = holidays.IT(prov="TO", years=[2017]) + prov_ts = holidays.IT(prov="TS", years=[2017]) + prov_vi = holidays.IT(prov="VI", years=[2017]) + + self.assertIn("2017-05-04", prov_an) + self.assertIn("2017-09-07", prov_ao) + self.assertIn("2017-12-06", prov_ba) + self.assertIn("2017-11-11", prov_bl) + self.assertIn("2017-10-04", prov_bo) + self.assertIn("2017-08-15", prov_bz) + self.assertIn("2017-02-15", prov_bs) + self.assertIn("2017-04-23", prov_cb) + self.assertIn("2017-05-11", prov_ch) + self.assertIn("2017-02-12", prov_cs) + self.assertIn("2017-02-05", prov_ct) + self.assertIn("2017-07-02", prov_en) + self.assertIn("2017-06-24", prov_fc) + self.assertIn("2017-02-04", prov_fc) + self.assertIn("2017-04-23", prov_fe) + self.assertIn("2017-06-24", prov_fi) + self.assertIn("2017-06-20", prov_fr) + self.assertIn("2017-06-24", prov_ge) + self.assertIn("2017-03-16", prov_go) + self.assertIn("2017-05-19", prov_is) + self.assertIn("2017-03-19", prov_sp) + self.assertIn("2017-10-09", prov_kr) + self.assertIn("2017-04-25", prov_lt) + self.assertIn("2017-06-24", prov_mb) + self.assertIn("2017-06-03", prov_me) + self.assertIn("2017-12-07", prov_mi) + self.assertIn("2017-03-18", prov_mn) + self.assertIn("2017-01-31", prov_mo) + self.assertIn("2017-10-04", prov_ms) + self.assertIn("2017-09-19", prov_na) + self.assertIn("2017-07-15", prov_pa) + self.assertIn("2017-07-04", prov_pc) + self.assertIn("2017-06-13", prov_pd) + self.assertIn("2017-01-29", prov_pg) + self.assertIn("2017-01-13", prov_pr) + self.assertIn("2017-06-29", prov_rm) + self.assertIn("2017-06-24", prov_to) + self.assertIn("2017-11-03", prov_ts) + self.assertIn("2017-04-25", prov_vi) diff --git a/test/countries/test_japan.py b/test/countries/test_japan.py new file mode 100644 index 000000000..bfab3f94e --- /dev/null +++ b/test/countries/test_japan.py @@ -0,0 +1,157 @@ +# -*- coding: utf-8 -*- + +# python-holidays +# --------------- +# A fast, efficient Python library for generating country, province and state +# specific sets of holidays on the fly. It aims to make determining whether a +# specific date is a holiday as fast and flexible as possible. +# +# Author: ryanss (c) 2014-2017 +# dr-prodigy (c) 2017-2021 +# Website: https://github.com/dr-prodigy/python-holidays +# License: MIT (see LICENSE file) + +import unittest + +from datetime import date + +import holidays + + +class TestJapan(unittest.TestCase): + def setUp(self): + self.holidays = holidays.Japan(observed=False) + + def test_new_years_day(self): + self.assertIn(date(1949, 1, 1), self.holidays) + self.assertIn(date(2017, 1, 1), self.holidays) + self.assertIn(date(2050, 1, 1), self.holidays) + + def test_coming_of_age(self): + self.assertIn(date(1999, 1, 15), self.holidays) + self.assertIn(date(2000, 1, 10), self.holidays) + self.assertIn(date(2017, 1, 9), self.holidays) + self.assertIn(date(2030, 1, 14), self.holidays) + self.assertIn(date(2050, 1, 10), self.holidays) + + self.assertNotIn(date(2000, 1, 15), self.holidays) + self.assertNotIn(date(2017, 1, 15), self.holidays) + self.assertNotIn(date(2030, 1, 15), self.holidays) + + def test_foundation_day(self): + self.assertIn(date(1949, 2, 11), self.holidays) + self.assertIn(date(2017, 2, 11), self.holidays) + self.assertIn(date(2050, 2, 11), self.holidays) + + def test_vernal_equinox_day(self): + self.assertIn(date(1956, 3, 21), self.holidays) + self.assertIn(date(1960, 3, 20), self.holidays) + self.assertIn(date(1970, 3, 21), self.holidays) + self.assertIn(date(1980, 3, 20), self.holidays) + self.assertIn(date(1990, 3, 21), self.holidays) + self.assertIn(date(2000, 3, 20), self.holidays) + self.assertIn(date(2010, 3, 21), self.holidays) + self.assertIn(date(2017, 3, 20), self.holidays) + self.assertIn(date(2020, 3, 20), self.holidays) + self.assertIn(date(2030, 3, 20), self.holidays) + self.assertIn(date(2040, 3, 20), self.holidays) + self.assertIn(date(2092, 3, 19), self.holidays) + + def test_showa_day(self): + self.assertIn(date(1950, 4, 29), self.holidays) + self.assertIn(date(1990, 4, 29), self.holidays) + self.assertIn(date(2010, 4, 29), self.holidays) + + def test_constitution_memorial_day(self): + self.assertIn(date(1950, 5, 3), self.holidays) + self.assertIn(date(2000, 5, 3), self.holidays) + self.assertIn(date(2050, 5, 3), self.holidays) + + def test_greenery_day(self): + self.assertNotIn(date(1950, 5, 4), self.holidays) + self.assertIn(date(2007, 5, 4), self.holidays) + self.assertIn(date(2050, 5, 4), self.holidays) + + def test_childrens_day(self): + self.assertIn(date(1950, 5, 5), self.holidays) + self.assertIn(date(2000, 5, 5), self.holidays) + self.assertIn(date(2050, 5, 5), self.holidays) + + def test_marine_day(self): + self.assertNotIn(date(1950, 7, 20), self.holidays) + self.assertIn(date(2000, 7, 20), self.holidays) + self.assertIn(date(2003, 7, 21), self.holidays) + self.assertIn(date(2017, 7, 17), self.holidays) + self.assertIn(date(2020, 7, 23), self.holidays) + self.assertIn(date(2021, 7, 22), self.holidays) + self.assertIn(date(2050, 7, 18), self.holidays) + + def test_mountain_day(self): + self.assertNotIn(date(1950, 8, 11), self.holidays) + self.assertNotIn(date(2015, 8, 11), self.holidays) + self.assertIn(date(2016, 8, 11), self.holidays) + self.assertIn(date(2017, 8, 11), self.holidays) + self.assertIn(date(2020, 8, 10), self.holidays) + self.assertIn(date(2021, 8, 8), self.holidays) + self.assertIn(date(2050, 8, 11), self.holidays) + + def test_respect_for_the_aged_day(self): + self.assertNotIn(date(1965, 9, 15), self.holidays) + self.assertIn(date(1966, 9, 15), self.holidays) + self.assertIn(date(2002, 9, 15), self.holidays) + self.assertIn(date(2003, 9, 15), self.holidays) + self.assertNotIn(date(2004, 9, 15), self.holidays) + self.assertIn(date(2004, 9, 20), self.holidays) + self.assertIn(date(2017, 9, 18), self.holidays) + self.assertIn(date(2050, 9, 19), self.holidays) + + def test_autumnal_equinox_day(self): + self.assertIn(date(2000, 9, 23), self.holidays) + self.assertIn(date(2010, 9, 23), self.holidays) + self.assertIn(date(2017, 9, 23), self.holidays) + self.assertIn(date(2020, 9, 22), self.holidays) + self.assertIn(date(2030, 9, 23), self.holidays) + self.assertIn(date(1979, 9, 24), self.holidays) + self.assertIn(date(2032, 9, 21), self.holidays) + + def test_health_and_sports_day(self): + self.assertNotIn(date(1965, 10, 10), self.holidays) + self.assertIn(date(1966, 10, 10), self.holidays) + self.assertIn(date(1999, 10, 10), self.holidays) + self.assertNotIn(date(2000, 10, 10), self.holidays) + self.assertIn(date(2000, 10, 9), self.holidays) + self.assertIn(date(2017, 10, 9), self.holidays) + self.assertIn(date(2020, 7, 24), self.holidays) + self.assertIn(date(2021, 7, 23), self.holidays) + self.assertIn(date(2050, 10, 10), self.holidays) + + def test_culture_day(self): + self.assertIn(date(1950, 11, 3), self.holidays) + self.assertIn(date(2000, 11, 3), self.holidays) + self.assertIn(date(2050, 11, 3), self.holidays) + + def test_labour_thanks_giving_day(self): + self.assertIn(date(1950, 11, 23), self.holidays) + self.assertIn(date(2000, 11, 23), self.holidays) + self.assertIn(date(2050, 11, 23), self.holidays) + + def test_emperors_birthday(self): + self.assertIn(date(1989, 12, 23), self.holidays) + self.assertIn(date(2017, 12, 23), self.holidays) + self.assertNotIn(date(2019, 12, 23), self.holidays) + self.assertIn(date(2020, 2, 23), self.holidays) + + def test_reiwa_emperor_holidays(self): + self.assertIn(date(1993, 6, 9), self.holidays) + self.assertIn(date(2019, 4, 30), self.holidays) + self.assertIn(date(2019, 5, 1), self.holidays) + self.assertIn(date(2019, 5, 2), self.holidays) + self.assertIn(date(2019, 10, 22), self.holidays) + + def test_invalid_years(self): + self.assertRaises( + NotImplementedError, lambda: date(1948, 1, 1) in self.holidays + ) + self.assertRaises( + NotImplementedError, lambda: date(2100, 1, 1) in self.holidays + ) diff --git a/test/countries/test_kenya.py b/test/countries/test_kenya.py new file mode 100644 index 000000000..0e9ae02dd --- /dev/null +++ b/test/countries/test_kenya.py @@ -0,0 +1,43 @@ +# -*- coding: utf-8 -*- + +# python-holidays +# --------------- +# A fast, efficient Python library for generating country, province and state +# specific sets of holidays on the fly. It aims to make determining whether a +# specific date is a holiday as fast and flexible as possible. +# +# Author: ryanss (c) 2014-2017 +# dr-prodigy (c) 2017-2021 +# Website: https://github.com/dr-prodigy/python-holidays +# License: MIT (see LICENSE file) + +import unittest + +from datetime import date + +import holidays + + +class TestKenya(unittest.TestCase): + def setUp(self): + self.holidays = holidays.Kenya() + + def test_2019(self): + # New Year's Day + self.assertIn(date(2019, 1, 1), self.holidays) + # Good Friday + self.assertIn(date(2019, 4, 19), self.holidays) + # Easter Monday + self.assertIn(date(2019, 4, 22), self.holidays) + # Labour Day + self.assertIn(date(2019, 5, 1), self.holidays) + # Madaraka Day + self.assertIn(date(2019, 6, 1), self.holidays) + # Mashujaa Day + self.assertIn(date(2019, 10, 20), self.holidays) + # Jamhuri (Independence) Day + self.assertIn(date(2019, 12, 12), self.holidays) + # Christmas Day + self.assertIn(date(2019, 12, 25), self.holidays) + # Boxing Day + self.assertIn(date(2018, 12, 26), self.holidays) diff --git a/test/countries/test_korea.py b/test/countries/test_korea.py new file mode 100644 index 000000000..7a931267a --- /dev/null +++ b/test/countries/test_korea.py @@ -0,0 +1,387 @@ +# -*- coding: utf-8 -*- + +# python-holidays +# --------------- +# A fast, efficient Python library for generating country, province and state +# specific sets of holidays on the fly. It aims to make determining whether a +# specific date is a holiday as fast and flexible as possible. +# +# Author: ryanss (c) 2014-2017 +# dr-prodigy (c) 2017-2021 +# Website: https://github.com/dr-prodigy/python-holidays +# License: MIT (see LICENSE file) + +import unittest + +from datetime import date + +import holidays + + +class TestKorea(unittest.TestCase): + def setUp(self): + self.holidays = holidays.KR() + + def test_common(self): + holidaysNoObserved = holidays.KR(observed=False) + self.assertEqual( + holidaysNoObserved[date(2019, 1, 1)], "New Year's Day" + ) + + self.assertNotIn(date(1582, 10, 2), self.holidays) + self.assertNotIn(date(1582, 11, 14), self.holidays) + + def test_first_day_of_january(self): + for year in range(2006, 2021): + self.assertIn(self.holidays[date(year, 1, 1)], "New Year's Day") + + def test_lunar_new_year(self): + for year, month, day in [ + (2006, 1, 28), + (2007, 2, 17), + (2010, 2, 13), + (2014, 1, 30), + ]: + self.assertEqual( + self.holidays[date(year, month, day)], + "The day preceding of Lunar New Year's Day", + ) + + for year, month, day in [ + (1916, 2, 4), + (1944, 1, 26), + (1954, 2, 4), + (1958, 2, 19), + (1966, 1, 22), + (1988, 2, 18), + (1997, 2, 8), + (2008, 2, 7), + (2009, 1, 26), + (2011, 2, 3), + (2012, 1, 23), + (2014, 1, 31), + (2015, 2, 19), + (2016, 2, 8), + (2017, 1, 28), + (2018, 2, 16), + (2019, 2, 5), + (2020, 1, 25), + (2027, 2, 7), + (2028, 1, 27), + ]: + self.assertEqual( + self.holidays[date(year, month, day)], "Lunar New Year's Day" + ) + + for year, month, day in [ + (2006, 1, 30), + (2007, 2, 19), + (2008, 2, 8), + (2009, 1, 27), + (2010, 2, 15), + (2011, 2, 4), + (2012, 1, 24), + (2013, 2, 11), + (2014, 2, 1), + (2015, 2, 20), + (2016, 2, 9), + (2018, 2, 17), + (2019, 2, 6), + ]: + self.assertEqual( + self.holidays[date(year, month, day)], + "The second day of Lunar New Year's Day", + ) + + for year, month, day in [(2016, 2, 10), (2017, 1, 30), (2020, 1, 27)]: + self.assertEqual( + self.holidays[date(year, month, day)], + "Alternative holiday of Lunar New Year's Day", + ) + + self.assertNotIn(date(2015, 2, 21), self.holidays) + self.assertNotIn(date(2015, 2, 7), self.holidays) + + def test_independence_movement_day(self): + for year, month, day in [ + (2006, 3, 1), + (2007, 3, 1), + (2008, 3, 1), + (2009, 3, 1), + (2010, 3, 1), + (2011, 3, 1), + (2012, 3, 1), + (2013, 3, 1), + (2014, 3, 1), + (2016, 3, 1), + (2017, 3, 1), + (2018, 3, 1), + (2019, 3, 1), + (2020, 3, 1), + ]: + self.assertEqual( + self.holidays[date(year, month, day)], + "Independence Movement Day", + ) + + def test_tree_planting_day(self): + for year, month, day in [ + (1949, 4, 5), + (1962, 4, 5), + (1982, 4, 5), + (1990, 4, 5), + (1995, 4, 5), + (1998, 4, 5), + (2000, 4, 5), + (2007, 4, 5), + ]: + self.assertEqual( + self.holidays[date(year, month, day)], "Tree Planting Day" + ) + + def test_childrens_day(self): + for year, month, day in [ + (2015, 5, 5), + (2016, 5, 5), + (2017, 5, 5), + (2018, 5, 5), + ]: + self.assertEqual( + self.holidays[date(year, month, day)], "Children's Day" + ) + + for year, month, day in [(2018, 5, 7), (2019, 5, 6)]: + self.assertEqual( + self.holidays[date(year, month, day)], + "Alternative holiday of Children's Day", + ) + for year, month, day in [(2025, 5, 6), (2044, 5, 6)]: + self.assertIn( + "Alternative holiday of Children's Day", + self.holidays[date(year, month, day)], + ) + + def test_birthday_of_buddha(self): + name = "Birthday of the Buddha" + for year, month, day in [ + (1931, 5, 25), + (1968, 5, 5), + (2010, 5, 21), + (2011, 5, 10), + (2012, 5, 28), + (2013, 5, 17), + (2014, 5, 6), + (2015, 5, 25), + (2016, 5, 14), + (2017, 5, 3), + (2018, 5, 22), + (2019, 5, 12), + (2020, 4, 30), + (2021, 5, 19), + (2022, 5, 8), + (2023, 5, 27), + (2024, 5, 15), + (2026, 5, 24), + (2027, 5, 13), + (2028, 5, 2), + (2029, 5, 20), + (2030, 5, 9), + ]: + self.assertEqual(self.holidays[date(year, month, day)], name) + + for year, month, day in [(2001, 5, 1)]: + self.assertIn( + "Birthday of the Buddha", self.holidays[date(year, month, day)] + ) + + def test_labour_day(self): + for year in [ + 2006, + 2007, + 2008, + 2009, + 2010, + 2012, + 2013, + 2014, + 2015, + 2017, + 2018, + 2019, + 2020, + ]: + self.assertEqual(self.holidays[date(year, 5, 1)], "Labour Day") + + def test_memorial_day(self): + for year in [ + 2006, + 2007, + 2008, + 2009, + 2010, + 2012, + 2013, + 2014, + 2015, + 2017, + 2018, + 2019, + 2020, + ]: + self.assertEqual(self.holidays[date(year, 6, 6)], "Memorial Day") + + def test_constitution_day(self): + for year in range(1948, 2007): + self.assertEqual( + self.holidays[date(year, 7, 17)], "Constitution Day" + ) + self.assertNotIn(date(2008, 7, 17), self.holidays) + self.assertNotIn(date(1947, 7, 17), self.holidays) + + def test_liberation_day(self): + for year in range(1945, 2020): + self.assertEqual( + self.holidays[date(year, 8, 15)], "Liberation Day" + ) + + def test_chuseok(self): + for year, month, day in [ + (2010, 9, 21), + (2011, 9, 11), + (2012, 9, 29), + (2013, 9, 18), + (2014, 9, 7), + (2015, 9, 26), + (2016, 9, 14), + (2018, 9, 23), + (2019, 9, 12), + (2020, 9, 30), + (2021, 9, 20), + (2022, 9, 9), + (2023, 9, 28), + (2024, 9, 16), + (2025, 10, 5), + (2026, 9, 24), + (2027, 9, 14), + (2028, 10, 2), + (2029, 9, 21), + (2030, 9, 11), + ]: + self.assertEqual( + self.holidays[date(year, month, day)], + "The day preceding of Chuseok", + ) + + for year, month, day in [(2017, 10, 3)]: + self.assertIn( + "The day preceding of Chuseok", + self.holidays[date(year, month, day)], + ) + + for year, month, day in [ + (1942, 9, 25), + (1978, 9, 17), + (2010, 9, 22), + (2011, 9, 12), + (2012, 9, 30), + (2013, 9, 19), + (2014, 9, 8), + (2015, 9, 27), + (2016, 9, 15), + (2017, 10, 4), + (2018, 9, 24), + (2019, 9, 13), + (2020, 10, 1), + (2021, 9, 21), + (2022, 9, 10), + (2023, 9, 29), + (2024, 9, 17), + (2025, 10, 6), + (2026, 9, 25), + (2027, 9, 15), + (2029, 9, 22), + (2030, 9, 12), + (2040, 9, 21), + ]: + self.assertEqual(self.holidays[date(year, month, day)], "Chuseok") + + for year, month, day in [(2028, 10, 3)]: + self.assertIn("Chuseok", self.holidays[date(year, month, day)]) + + for year, month, day in [ + (2010, 9, 23), + (2011, 9, 13), + (2012, 10, 1), + (2013, 9, 20), + (2014, 9, 9), + (2015, 9, 28), + (2016, 9, 16), + (2017, 10, 5), + (2018, 9, 25), + (2019, 9, 14), + (2020, 10, 2), + (2021, 9, 22), + (2022, 9, 11), + (2023, 9, 30), + (2024, 9, 18), + (2025, 10, 7), + (2026, 9, 26), + (2027, 9, 16), + (2028, 10, 4), + (2029, 9, 23), + (2030, 9, 13), + ]: + self.assertEqual( + self.holidays[date(year, month, day)], + "The second day of Chuseok", + ) + + for year, month, day in [ + (2014, 9, 10), + (2015, 9, 29), + (2018, 9, 26), + (2022, 9, 12), + (2025, 10, 8), + (2029, 9, 24), + ]: + self.assertEqual( + self.holidays[date(year, month, day)], + "Alternative holiday of Chuseok", + ) + + def test_national_foundation_day(self): + for year in range(1948, 2050): + if year in [ + 1952, + 1963, + 1971, + 1990, + 2009, + 2017, + 2028, + 2036, + 2039, + 2047, + ]: + self.assertIn( + "National Foundation Day", self.holidays[date(year, 10, 3)] + ) + else: + self.assertEqual( + self.holidays[date(year, 10, 3)], "National Foundation Day" + ) + + def test_hangeul_day(self): + for year in range(1948, 2007): + self.assertEqual(self.holidays[date(year, 10, 9)], "Hangeul Day") + + def test_christmas_day(self): + for year in range(1948, 2050): + self.assertEqual( + self.holidays[date(year, 12, 25)], "Christmas Day" + ) + + def test_years_range(self): + self.holidays = holidays.KR(years=range(2006, 2021)) + for year in range(2006, 2021): + self.assertIn(self.holidays[date(year, 1, 1)], "New Year's Day") diff --git a/test/countries/test_latvia.py b/test/countries/test_latvia.py new file mode 100644 index 000000000..4d565330b --- /dev/null +++ b/test/countries/test_latvia.py @@ -0,0 +1,40 @@ +# -*- coding: utf-8 -*- + +# python-holidays +# --------------- +# A fast, efficient Python library for generating country, province and state +# specific sets of holidays on the fly. It aims to make determining whether a +# specific date is a holiday as fast and flexible as possible. +# +# Author: ryanss (c) 2014-2017 +# dr-prodigy (c) 2017-2021 +# Website: https://github.com/dr-prodigy/python-holidays +# License: MIT (see LICENSE file) + +import unittest + +from datetime import date + +import holidays + + +class TestLatvia(unittest.TestCase): + def setUp(self): + self.holidays = holidays.LV() + + def test_2020(self): + # https://www.officeholidays.com/countries/latvia/2020 + # https://en.wikipedia.org/wiki/Public_holidays_in_Latvia + # https://likumi.lv/ta/id/72608-par-svetku-atceres-un-atzimejamam-dienam + self.assertIn(date(2020, 1, 1), self.holidays) + self.assertIn(date(2020, 4, 10), self.holidays) + self.assertIn(date(2020, 4, 13), self.holidays) + self.assertIn(date(2020, 5, 1), self.holidays) + self.assertIn(date(2020, 5, 4), self.holidays) + self.assertIn(date(2020, 6, 23), self.holidays) + self.assertIn(date(2020, 6, 24), self.holidays) + self.assertIn(date(2020, 11, 18), self.holidays) + self.assertIn(date(2020, 12, 24), self.holidays) + self.assertIn(date(2020, 12, 25), self.holidays) + self.assertIn(date(2020, 12, 26), self.holidays) + self.assertIn(date(2020, 12, 31), self.holidays) diff --git a/test/countries/test_lithuania.py b/test/countries/test_lithuania.py new file mode 100644 index 000000000..2fc6559e8 --- /dev/null +++ b/test/countries/test_lithuania.py @@ -0,0 +1,77 @@ +# -*- coding: utf-8 -*- + +# python-holidays +# --------------- +# A fast, efficient Python library for generating country, province and state +# specific sets of holidays on the fly. It aims to make determining whether a +# specific date is a holiday as fast and flexible as possible. +# +# Author: ryanss (c) 2014-2017 +# dr-prodigy (c) 2017-2021 +# Website: https://github.com/dr-prodigy/python-holidays +# License: MIT (see LICENSE file) + +import unittest + +from datetime import date + +import holidays + + +class TestLithuania(unittest.TestCase): + def setUp(self): + self.holidays = holidays.LT() + + def test_2018(self): + # New Year's Day + self.assertIn(date(2018, 1, 1), self.holidays) + # Day of Restoration of the State of Lithuania + self.assertIn(date(2018, 2, 16), self.holidays) + # Day of Restoration of Independence of Lithuania + self.assertIn(date(2018, 3, 11), self.holidays) + # Easter + self.assertIn(date(2018, 4, 1), self.holidays) + # Easter 2nd day + self.assertIn(date(2018, 4, 2), self.holidays) + # International Workers' Day + self.assertIn(date(2018, 5, 1), self.holidays) + # Mother's day + self.assertIn(date(2018, 5, 6), self.holidays) + # Fathers's day + self.assertIn(date(2018, 6, 3), self.holidays) + # St. John's Day, Day of Dew + self.assertIn(date(2018, 6, 24), self.holidays) + # Statehood Day + self.assertIn(date(2018, 7, 6), self.holidays) + # Assumption Day + self.assertIn(date(2018, 8, 15), self.holidays) + # All Saints' Day + self.assertIn(date(2018, 11, 1), self.holidays) + # Christmas Eve + self.assertIn(date(2018, 12, 24), self.holidays) + # Christmas 1st day + self.assertIn(date(2018, 12, 25), self.holidays) + # Christmas 2nd day + self.assertIn(date(2018, 12, 26), self.holidays) + + def test_easter(self): + self.assertNotIn(date(2019, 4, 20), self.holidays) + self.assertIn(date(2019, 4, 21), self.holidays) + self.assertIn(date(2019, 4, 22), self.holidays) + self.assertNotIn(date(2019, 4, 23), self.holidays) + + def test_mothers_day(self): + self.assertNotIn(date(2019, 5, 4), self.holidays) + self.assertIn(date(2019, 5, 5), self.holidays) + self.assertNotIn(date(2019, 5, 6), self.holidays) + self.assertIn(date(2020, 5, 3), self.holidays) + + def test_fathers_day(self): + self.assertNotIn(date(2019, 6, 1), self.holidays) + self.assertIn(date(2019, 6, 2), self.holidays) + self.assertNotIn(date(2019, 6, 3), self.holidays) + self.assertIn(date(2020, 6, 7), self.holidays) + + def test_day_of_dew(self): + self.assertNotIn(date(2002, 6, 24), self.holidays) + self.assertIn(date(2020, 6, 24), self.holidays) diff --git a/test/countries/test_luxembourg.py b/test/countries/test_luxembourg.py new file mode 100644 index 000000000..ee0986d31 --- /dev/null +++ b/test/countries/test_luxembourg.py @@ -0,0 +1,37 @@ +# -*- coding: utf-8 -*- + +# python-holidays +# --------------- +# A fast, efficient Python library for generating country, province and state +# specific sets of holidays on the fly. It aims to make determining whether a +# specific date is a holiday as fast and flexible as possible. +# +# Author: ryanss (c) 2014-2017 +# dr-prodigy (c) 2017-2021 +# Website: https://github.com/dr-prodigy/python-holidays +# License: MIT (see LICENSE file) + +import unittest + +from datetime import date + +import holidays + + +class TestLU(unittest.TestCase): + def setUp(self): + self.holidays = holidays.LU() + + def test_2019(self): + # https://www.officeholidays.com/countries/luxembourg/2019 + self.assertIn(date(2019, 1, 1), self.holidays) + self.assertIn(date(2019, 4, 22), self.holidays) + self.assertIn(date(2019, 5, 1), self.holidays) + self.assertIn(date(2019, 5, 9), self.holidays) + self.assertIn(date(2019, 5, 30), self.holidays) + self.assertIn(date(2019, 6, 10), self.holidays) + self.assertIn(date(2019, 6, 23), self.holidays) + self.assertIn(date(2019, 8, 15), self.holidays) + self.assertIn(date(2019, 11, 1), self.holidays) + self.assertIn(date(2019, 12, 25), self.holidays) + self.assertIn(date(2019, 12, 26), self.holidays) diff --git a/test/countries/test_malawi.py b/test/countries/test_malawi.py new file mode 100644 index 000000000..b88f66e2b --- /dev/null +++ b/test/countries/test_malawi.py @@ -0,0 +1,45 @@ +# -*- coding: utf-8 -*- + +# python-holidays +# --------------- +# A fast, efficient Python library for generating country, province and state +# specific sets of holidays on the fly. It aims to make determining whether a +# specific date is a holiday as fast and flexible as possible. +# +# Author: ryanss (c) 2014-2017 +# dr-prodigy (c) 2017-2021 +# Website: https://github.com/dr-prodigy/python-holidays +# License: MIT (see LICENSE file) + +import unittest + +from datetime import date + +import holidays + + +class TestMalawi(unittest.TestCase): + def setUp(self): + self.holidays = holidays.MW() + + def test_new_years(self): + self.assertIn("2015-01-01", self.holidays) + self.assertIn("2017-01-01", self.holidays) + self.assertIn("2999-01-01", self.holidays) + self.assertIn("2017-01-02", self.holidays) # sunday + + def test_good_friday(self): + self.assertIn("2022-04-15", self.holidays) + self.assertIn("2018-03-30", self.holidays) + + def test_easter(self): + self.assertIn(date(2017, 4, 14), self.holidays) + self.assertIn(date(2020, 4, 10), self.holidays) + self.assertIn(date(2015, 4, 6), self.holidays) + + def test_static(self): + self.assertIn("2004-03-03", self.holidays) + + def test_not_holiday(self): + self.assertNotIn("2016-12-28", self.holidays) + self.assertNotIn("2015-03-02", self.holidays) diff --git a/test/countries/test_mexico.py b/test/countries/test_mexico.py new file mode 100644 index 000000000..3e27770e5 --- /dev/null +++ b/test/countries/test_mexico.py @@ -0,0 +1,210 @@ +# -*- coding: utf-8 -*- + +# python-holidays +# --------------- +# A fast, efficient Python library for generating country, province and state +# specific sets of holidays on the fly. It aims to make determining whether a +# specific date is a holiday as fast and flexible as possible. +# +# Author: ryanss (c) 2014-2017 +# dr-prodigy (c) 2017-2021 +# Website: https://github.com/dr-prodigy/python-holidays +# License: MIT (see LICENSE file) + +import unittest + +from datetime import date +from dateutil.relativedelta import relativedelta + +import holidays + + +class TestMX(unittest.TestCase): + def setUp(self): + self.holidays = holidays.MX(observed=False) + + def test_new_years(self): + self.assertNotIn(date(2010, 12, 31), self.holidays) + self.assertNotIn(date(2017, 1, 2), self.holidays) + self.holidays.observed = True + self.assertIn(date(2010, 12, 31), self.holidays) + self.assertIn(date(2017, 1, 2), self.holidays) + self.holidays.observed = False + for year in range(1900, 2100): + dt = date(year, 1, 1) + self.assertIn(dt, self.holidays) + self.assertNotIn(dt + relativedelta(days=-1), self.holidays) + self.assertNotIn(dt + relativedelta(days=+1), self.holidays) + + def test_constitution_day(self): + for dt in [ + date(2005, 2, 5), + date(2006, 2, 5), + date(2007, 2, 5), + date(2009, 2, 5), + date(2010, 2, 5), + date(2015, 2, 5), + date(2016, 2, 5), + date(2020, 2, 5), + date(2021, 2, 5), + date(2022, 2, 5), + ]: + self.assertIn(dt, self.holidays) + self.assertNotIn(dt + relativedelta(days=-1), self.holidays) + self.assertNotIn(dt + relativedelta(days=+1), self.holidays) + self.holidays.observed = True + for dt in [ + date(2005, 2, 5), + date(2006, 2, 5), + date(2007, 2, 5), + date(2009, 2, 5), + date(2009, 2, 2), + date(2010, 2, 5), + date(2010, 2, 1), + date(2015, 2, 5), + date(2015, 2, 2), + date(2016, 2, 5), + date(2016, 2, 1), + date(2020, 2, 5), + date(2020, 2, 3), + date(2021, 2, 5), + date(2021, 2, 1), + date(2022, 2, 5), + date(2022, 2, 7), + ]: + self.assertIn(dt, self.holidays) + self.holidays.observed = False + + def test_benito_juarez(self): + for dt in [ + date(2005, 3, 21), + date(2006, 3, 21), + date(2007, 3, 21), + date(2008, 3, 21), + date(2009, 3, 21), + date(2010, 3, 21), + date(2015, 3, 21), + date(2016, 3, 21), + date(2020, 3, 21), + date(2021, 3, 21), + date(2022, 3, 21), + date(2024, 3, 21), + ]: + self.assertIn(dt, self.holidays) + self.assertNotIn(dt + relativedelta(days=-1), self.holidays) + self.assertNotIn(dt + relativedelta(days=+1), self.holidays) + self.holidays.observed = True + for dt in [ + date(2005, 3, 21), + date(2006, 3, 21), + date(2007, 3, 21), + date(2007, 3, 19), + date(2008, 3, 21), + date(2008, 3, 17), + date(2009, 3, 21), + date(2009, 3, 16), + date(2010, 3, 21), + date(2010, 3, 15), + date(2015, 3, 21), + date(2015, 3, 16), + date(2016, 3, 21), + date(2020, 3, 21), + date(2020, 3, 16), + date(2021, 3, 21), + date(2021, 3, 15), + date(2022, 3, 21), + date(2024, 3, 21), + date(2024, 3, 18), + ]: + self.assertIn(dt, self.holidays) + self.holidays.observed = False + + def test_labor_day(self): + self.assertNotIn(date(2010, 4, 30), self.holidays) + self.assertNotIn(date(2011, 5, 2), self.holidays) + self.assertNotIn(date(2022, 5, 2), self.holidays) + self.holidays.observed = True + self.assertIn(date(2010, 4, 30), self.holidays) + self.assertIn(date(2011, 5, 2), self.holidays) + self.assertIn(date(2022, 5, 2), self.holidays) + self.holidays.observed = False + self.assertNotIn(date(1922, 5, 1), self.holidays) + for year in range(1923, 2100): + dt = date(year, 5, 1) + self.assertIn(dt, self.holidays) + self.assertNotIn(dt + relativedelta(days=-1), self.holidays) + self.assertNotIn(dt + relativedelta(days=+1), self.holidays) + + def test_independence_day(self): + self.assertNotIn(date(2006, 9, 15), self.holidays) + self.assertNotIn(date(2007, 9, 17), self.holidays) + self.holidays.observed = True + self.assertIn(date(2006, 9, 15), self.holidays) + self.assertIn(date(2007, 9, 17), self.holidays) + self.holidays.observed = False + for year in range(1900, 2100): + dt = date(year, 9, 16) + self.assertIn(dt, self.holidays) + self.assertNotIn(dt + relativedelta(days=-1), self.holidays) + self.assertNotIn(dt + relativedelta(days=+1), self.holidays) + + def test_revolution_day(self): + for dt in [ + date(2005, 11, 20), + date(2006, 11, 20), + date(2007, 11, 20), + date(2008, 11, 20), + date(2009, 11, 20), + date(2010, 11, 20), + date(2015, 11, 20), + date(2016, 11, 20), + date(2020, 11, 20), + date(2021, 11, 20), + date(2022, 11, 20), + date(2023, 11, 20), + ]: + self.assertIn(dt, self.holidays) + self.assertNotIn(dt + relativedelta(days=-1), self.holidays) + self.assertNotIn(dt + relativedelta(days=+1), self.holidays) + self.holidays.observed = True + for dt in [ + date(2005, 11, 20), + date(2006, 11, 20), + date(2007, 11, 19), + date(2008, 11, 17), + date(2009, 11, 16), + date(2010, 11, 15), + date(2015, 11, 16), + date(2016, 11, 21), + date(2020, 11, 16), + ]: + self.assertIn(dt, self.holidays) + self.holidays.observed = False + + def test_change_of_government(self): + self.assertNotIn(date(2012, 11, 30), self.holidays) + self.assertNotIn(date(2024, 12, 2), self.holidays) + self.holidays.observed = True + self.assertIn(date(2012, 11, 30), self.holidays) + self.assertIn(date(2024, 12, 2), self.holidays) + self.holidays.observed = False + for year in range(1950, 2100): + dt = date(year, 12, 1) + if (year >= 1970) and ((2096 - year) % 6) == 0: + self.assertIn(dt, self.holidays) + self.assertNotIn(dt + relativedelta(days=-1), self.holidays) + self.assertNotIn(dt + relativedelta(days=+1), self.holidays) + else: + self.assertNotIn(dt, self.holidays) + + def test_christmas(self): + for year in range(1900, 2100): + dt = date(year, 12, 25) + self.assertIn(dt, self.holidays) + self.assertNotIn(dt + relativedelta(days=-1), self.holidays) + self.assertNotIn(dt + relativedelta(days=+1), self.holidays) + self.assertNotIn(date(2010, 12, 24), self.holidays) + self.assertNotIn(date(2016, 12, 26), self.holidays) + self.holidays.observed = True + self.assertIn(date(2010, 12, 24), self.holidays) + self.assertIn(date(2016, 12, 26), self.holidays) diff --git a/test/countries/test_morocco.py b/test/countries/test_morocco.py new file mode 100644 index 000000000..ce19d3dc0 --- /dev/null +++ b/test/countries/test_morocco.py @@ -0,0 +1,86 @@ +# -*- coding: utf-8 -*- + +# python-holidays +# --------------- +# A fast, efficient Python library for generating country, province and state +# specific sets of holidays on the fly. It aims to make determining whether a +# specific date is a holiday as fast and flexible as possible. +# +# Author: ryanss (c) 2014-2017 +# dr-prodigy (c) 2017-2021 +# Website: https://github.com/dr-prodigy/python-holidays +# License: MIT (see LICENSE file) + +import sys +import unittest + +from datetime import date + +import holidays + + +class TestMorocco(unittest.TestCase): + def setUp(self): + self.holidays = holidays.Morocco() + + def test_2019(self): + _holidays = [ + date(2019, 1, 1), + date(2019, 1, 11), + date(2019, 5, 1), + date(2019, 7, 30), + date(2019, 8, 14), + date(2019, 8, 20), + date(2019, 8, 21), + date(2019, 11, 6), + date(2019, 11, 18), + ] + + for holiday in _holidays: + self.assertIn(holiday, self.holidays) + + def test_1999(self): + self.holidays = holidays.Morocco(years=[1999]) + _holidays = [ + date(1999, 1, 1), + date(1999, 1, 11), + date(1999, 5, 1), + date(1999, 3, 3), + date(1999, 8, 14), + date(1999, 8, 20), + date(1999, 7, 9), + date(1999, 11, 6), + date(1999, 11, 18), + ] + + for holiday in _holidays: + self.assertIn(holiday, self.holidays) + + def test_1961(self): + self.holidays = holidays.Morocco(years=[1961]) + _holidays = [ + date(1961, 11, 18), + ] + + for holiday in _holidays: + self.assertIn(holiday, self.holidays) + + def test_hijri_based(self): + if sys.version_info >= (3, 6): + import importlib.util + + if importlib.util.find_spec("hijri_converter"): + self.holidays = holidays.Morocco(years=[2019, 1999]) + # eid_alfitr + self.assertIn(date(2019, 6, 4), self.holidays) + self.assertIn(date(2019, 6, 5), self.holidays) + # eid_aladha + self.assertIn(date(2019, 8, 11), self.holidays) + self.assertIn(date(2019, 8, 12), self.holidays) + # islamic_new_year + self.assertIn(date(2019, 8, 31), self.holidays) + + self.assertIn(date(2019, 11, 9), self.holidays) + self.assertIn(date(2019, 11, 10), self.holidays) + + self.assertIn(date(1999, 4, 17), self.holidays) diff --git a/test/countries/test_mozambique.py b/test/countries/test_mozambique.py new file mode 100644 index 000000000..b3b082648 --- /dev/null +++ b/test/countries/test_mozambique.py @@ -0,0 +1,39 @@ +# -*- coding: utf-8 -*- + +# python-holidays +# --------------- +# A fast, efficient Python library for generating country, province and state +# specific sets of holidays on the fly. It aims to make determining whether a +# specific date is a holiday as fast and flexible as possible. +# +# Author: ryanss (c) 2014-2017 +# dr-prodigy (c) 2017-2021 +# Website: https://github.com/dr-prodigy/python-holidays +# License: MIT (see LICENSE file) + +import unittest + +from datetime import date + +import holidays + + +class TestMozambique(unittest.TestCase): + def setUp(self): + self.holidays = holidays.MZ() + + def test_new_years(self): + self.assertIn("1975-01-01", self.holidays) + self.assertIn("2017-01-01", self.holidays) + self.assertIn("2999-01-01", self.holidays) + self.assertIn("2017-01-02", self.holidays) # sunday + + def test_easter(self): + self.assertIn(date(2017, 4, 14), self.holidays) + self.assertIn(date(2020, 4, 10), self.holidays) + self.assertIn(date(1994, 4, 1), self.holidays) + + def test_not_holiday(self): + self.assertNotIn("2018-02-04", self.holidays) + self.assertNotIn("2015-04-13", self.holidays) + self.assertNotIn("2018-03-23", self.holidays) diff --git a/test/countries/test_netherlands.py b/test/countries/test_netherlands.py new file mode 100644 index 000000000..486ac2aa6 --- /dev/null +++ b/test/countries/test_netherlands.py @@ -0,0 +1,110 @@ +# -*- coding: utf-8 -*- + +# python-holidays +# --------------- +# A fast, efficient Python library for generating country, province and state +# specific sets of holidays on the fly. It aims to make determining whether a +# specific date is a holiday as fast and flexible as possible. +# +# Author: ryanss (c) 2014-2017 +# dr-prodigy (c) 2017-2021 +# Website: https://github.com/dr-prodigy/python-holidays +# License: MIT (see LICENSE file) + +import unittest + +from datetime import date + +import holidays + + +class TestNetherlands(unittest.TestCase): + def setUp(self): + self.holidays = holidays.NL() + + def test_2017(self): + # http://www.iamsterdam.com/en/plan-your-trip/practical-info/public-holidays + self.assertIn(date(2017, 1, 1), self.holidays) + self.assertIn(date(2017, 4, 16), self.holidays) + self.assertIn(date(2017, 4, 17), self.holidays) + self.assertIn(date(2017, 4, 27), self.holidays) + self.assertIn(date(2017, 5, 25), self.holidays) + self.assertIn(date(2017, 6, 4), self.holidays) + self.assertIn(date(2017, 6, 5), self.holidays) + self.assertIn(date(2017, 12, 25), self.holidays) + self.assertIn(date(2017, 12, 26), self.holidays) + + def test_new_years(self): + self.assertIn(date(2017, 1, 1), self.holidays) + + def test_easter(self): + self.assertIn(date(2017, 4, 16), self.holidays) + + def test_easter_monday(self): + self.assertIn(date(2017, 4, 17), self.holidays) + + def test_queens_day_between_1891_and_1948(self): + # Between 1891 and 1948 Queens Day was celebrated on 8-31 + self.holidays = holidays.NL(years=[1901]) + self.assertIn(date(1901, 8, 31), self.holidays) + + def test_queens_day_between_1891_and_1948_substituted_later(self): + # Between 1891 and 1948 Queens Day was celebrated on 9-1 + # (one day later) when Queens Day falls on a Sunday + self.holidays = holidays.NL(years=[1947]) + self.assertIn(date(1947, 9, 1), self.holidays) + + def test_queens_day_between_1949_and_2013(self): + self.holidays = holidays.NL(years=[1965]) + self.assertIn(date(1965, 4, 30), self.holidays) + + def test_queens_day_between_1949_and_1980_substituted_later(self): + self.holidays = holidays.NL(years=[1967]) + self.assertIn(date(1967, 5, 1), self.holidays) + + def test_queens_day_between_1980_and_2013_substituted_earlier(self): + self.holidays = holidays.NL(years=[2006]) + self.assertIn(date(2006, 4, 29), self.holidays) + + def test_kings_day_after_2014(self): + self.holidays = holidays.NL(years=[2013]) + self.assertNotIn(date(2013, 4, 27), self.holidays) + + self.holidays = holidays.NL(years=[2017]) + self.assertIn(date(2017, 4, 27), self.holidays) + + def test_kings_day_after_2014_substituted_earlier(self): + self.holidays = holidays.NL(years=[2188]) + self.assertIn(date(2188, 4, 26), self.holidays) + + def test_liberation_day(self): + self.holidays = holidays.NL(years=1900) + self.assertNotIn(date(1900, 5, 5), self.holidays) + + def test_liberation_day_after_1990_non_lustrum_year(self): + self.holidays = holidays.NL(years=2017) + self.assertNotIn(date(2017, 5, 5), self.holidays) + + def test_liberation_day_after_1990_in_lustrum_year(self): + self.holidays = holidays.NL(years=2020) + self.assertIn(date(2020, 5, 5), self.holidays) + + def test_ascension_day(self): + self.holidays = holidays.NL(years=2017) + self.assertIn(date(2017, 5, 25), self.holidays) + + def test_whit_sunday(self): + self.holidays = holidays.NL(years=2017) + self.assertIn(date(2017, 6, 4), self.holidays) + + def test_whit_monday(self): + self.holidays = holidays.NL(years=2017) + self.assertIn(date(2017, 6, 5), self.holidays) + + def test_first_christmas(self): + self.holidays = holidays.NL(years=2017) + self.assertIn(date(2017, 12, 25), self.holidays) + + def test_second_christmas(self): + self.holidays = holidays.NL(years=2017) + self.assertIn(date(2017, 12, 26), self.holidays) diff --git a/test/countries/test_new_zealand.py b/test/countries/test_new_zealand.py new file mode 100644 index 000000000..75146ff3f --- /dev/null +++ b/test/countries/test_new_zealand.py @@ -0,0 +1,808 @@ +# -*- coding: utf-8 -*- + +# python-holidays +# --------------- +# A fast, efficient Python library for generating country, province and state +# specific sets of holidays on the fly. It aims to make determining whether a +# specific date is a holiday as fast and flexible as possible. +# +# Author: ryanss (c) 2014-2017 +# dr-prodigy (c) 2017-2021 +# Website: https://github.com/dr-prodigy/python-holidays +# License: MIT (see LICENSE file) + +import unittest + +from datetime import date +from dateutil.relativedelta import relativedelta + +import holidays + + +class TestNZ(unittest.TestCase): + def setUp(self): + self.holidays = holidays.NZ(observed=True) + + def test_new_years(self): + for year in range(1900, 2100): + dt = date(year, 1, 1) + self.assertIn(dt, self.holidays) + for year, day in enumerate( + [ + 1, + 1, + 1, + 1, + 3, # 2001-05 + 3, + 1, + 1, + 1, + 1, # 2006-10 + 3, + 3, + 1, + 1, + 1, # 2011-15 + 1, + 3, + 1, + 1, + 1, + 1, + ], # 2016-21 + 2001, + ): + dt = date(year, 1, day) + self.assertIn(dt, self.holidays) + self.assertEqual(self.holidays[dt][:10], "New Year's") + self.assertNotIn("1893-01-01", self.holidays) + self.assertIn("1894-01-01", self.holidays) + + def test_day_after_new_years(self): + for year in range(1900, 2100): + dt = date(year, 1, 2) + self.assertIn(dt, self.holidays) + for year, day in enumerate( + [ + 2, + 2, + 2, + 2, + 2, # 2001-05 + 2, + 2, + 2, + 2, + 4, # 2006-10 + 4, + 2, + 2, + 2, + 2, # 2011-15 + 4, + 2, + 2, + 2, + 2, + 4, + ], # 2016-21 + 2001, + ): + dt = date(year, 1, day) + self.assertIn(dt, self.holidays) + self.assertEqual(self.holidays[dt][:10], "Day after ") + self.assertNotIn(date(2016, 1, 3), self.holidays) + + def test_waitangi_day(self): + ntl_holidays = holidays.NZ(prov="Northland") + for year, day in enumerate([3, 8, 7, 6, 5], 1964): + dt = date(year, 2, day) + self.assertIn(dt, ntl_holidays, dt) + self.assertEqual(ntl_holidays[dt][:8], "Waitangi") + for year in range(1900, 1974): + dt = date(year, 2, 6) + self.assertNotIn(dt, self.holidays) + for year in range(1974, 2100): + dt = date(year, 2, 6) + self.assertIn(dt, self.holidays) + for year, day in enumerate( + [ + 6, + 6, + 6, + 6, + 6, # 2001-05 + 6, + 6, + 6, + 6, + 6, # 2006-10 + 6, + 6, + 6, + 6, + 6, # 2011-15 + 8, + 6, + 6, + 6, + 6, + 8, + ], # 2016-21 + 2001, + ): + dt = date(year, 2, day) + self.assertIn(dt, self.holidays) + self.assertEqual(self.holidays[dt][:8], "Waitangi") + self.assertNotIn(date(2005, 2, 7), self.holidays) + self.assertNotIn(date(2010, 2, 8), self.holidays) + self.assertNotIn(date(2011, 2, 7), self.holidays) + + def test_good_friday(self): + 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.assertIn(dt, self.holidays) + self.assertNotIn(dt + relativedelta(days=-1), self.holidays) + self.assertNotIn(dt + relativedelta(days=+1), self.holidays) + + def test_easter_monday(self): + for dt in [ + date(1900, 4, 16), + date(1901, 4, 8), + date(1902, 3, 31), + date(1999, 4, 5), + date(2010, 4, 5), + date(2018, 4, 2), + date(2019, 4, 22), + date(2020, 4, 13), + ]: + self.assertIn(dt, self.holidays) + self.assertNotIn(dt + relativedelta(days=-1), self.holidays) + self.assertNotIn(dt + relativedelta(days=+1), self.holidays) + + def test_anzac_day(self): + for year in range(1900, 1921): + dt = date(year, 4, 25) + self.assertNotIn(dt, self.holidays) + for year in range(1921, 2100): + dt = date(year, 4, 25) + self.assertIn(dt, self.holidays) + for year, day in enumerate( + [ + 25, + 25, + 25, + 25, + 25, # 2001-05 + 25, + 25, + 25, + 25, + 25, # 2006-10 + 25, + 25, + 25, + 25, + 27, # 2011-15 + 25, + 25, + 25, + 25, + 27, + 26, + ], # 2016-21 + 2001, + ): + dt = date(year, 4, day) + self.assertIn(dt, self.holidays, dt) + self.assertEqual(self.holidays[dt][:5], "Anzac") + self.assertNotIn(date(2009, 4, 27), self.holidays) + self.assertNotIn(date(2010, 4, 26), self.holidays) + + def test_sovereigns_birthday(self): + self.assertIn(date(1909, 11, 9), self.holidays) + self.assertIn(date(1936, 6, 23), self.holidays) + self.assertIn(date(1937, 6, 9), self.holidays) + self.assertIn(date(1940, 6, 3), self.holidays) + self.assertIn(date(1952, 6, 2), self.holidays) + for year in range(1912, 1936): + dt = date(year, 6, 3) + self.assertIn(dt, self.holidays) + self.assertEqual(self.holidays[dt], "King's Birthday") + for year, day in enumerate( + [ + 4, + 3, + 2, + 7, + 6, # 2001-05 + 5, + 4, + 2, + 1, + 7, # 2006-10 + 6, + 4, + 3, + 2, + 1, # 2011-15 + 6, + 5, + 4, + 3, + 1, + 7, + ], # 2016-21 + 2001, + ): + dt = date(year, 6, day) + self.assertIn(dt, self.holidays, dt) + self.assertEqual(self.holidays[dt], "Queen's Birthday") + + def test_labour_day(self): + for year, day in enumerate( + [ + 22, + 28, + 27, + 25, + 24, # 2001-05 + 23, + 22, + 27, + 26, + 25, # 2006-10 + 24, + 22, + 28, + 27, + 26, # 2011-15 + 24, + 23, + 22, + 28, + 26, + 25, + ], # 2016-21 + 2001, + ): + dt = date(year, 10, day) + self.assertIn(dt, self.holidays, dt) + self.assertEqual(self.holidays[dt], "Labour Day") + + def test_christmas_day(self): + self.holidays.observed = False + for year in range(1900, 2100): + dt = date(year, 12, 25) + self.assertIn(dt, self.holidays) + self.assertNotIn(dt + relativedelta(days=-1), self.holidays) + self.assertNotIn(date(2010, 12, 24), self.holidays) + self.assertNotEqual( + self.holidays[date(2011, 12, 26)], "Christmas Day (Observed)" + ) + self.holidays.observed = True + self.assertEqual( + self.holidays[date(2011, 12, 27)], "Christmas Day (Observed)" + ) + for year, day in enumerate( + [ + 25, + 25, + 25, + 27, + 27, # 2001-05 + 25, + 25, + 25, + 25, + 27, # 2006-10 + 27, + 25, + 25, + 25, + 25, # 2011-15 + 27, + 25, + 25, + 25, + 25, + 25, + ], # 2016-21 + 2001, + ): + dt = date(year, 12, day) + self.assertIn(dt, self.holidays, dt) + self.assertEqual(self.holidays[dt][:9], "Christmas") + + def test_boxing_day(self): + self.holidays.observed = False + for year in range(1900, 2100): + dt = date(year, 12, 26) + self.assertIn(dt, self.holidays) + self.assertNotIn(dt + relativedelta(days=+1), self.holidays) + self.assertNotIn(date(2009, 12, 28), self.holidays) + self.assertNotIn(date(2010, 12, 27), self.holidays) + self.holidays.observed = True + self.assertIn(date(2009, 12, 28), self.holidays) + self.assertIn(date(2010, 12, 27), self.holidays) + for year, day in enumerate( + [ + 26, + 26, + 26, + 28, + 26, # 2001-05 + 26, + 26, + 26, + 28, + 28, # 2006-10 + 26, + 26, + 26, + 26, + 28, # 2011-15 + 26, + 26, + 26, + 26, + 28, + 28, + ], # 2016-21 + 2001, + ): + dt = date(year, 12, day) + self.assertIn(dt, self.holidays, dt) + self.assertEqual(self.holidays[dt][:6], "Boxing") + + def test_auckland_anniversary_day(self): + auk_holidays = holidays.NZ(prov="Auckland") + for year, day in enumerate( + [ + 29, + 28, + 27, + 26, + 31, # 2001-05 + 30, + 29, + 28, + 26, + 1, # 2006-10 + 31, + 30, + 28, + 27, + 26, # 2011-15 + 1, + 30, + 29, + 28, + 27, + 1, + ], # 2016-21 + 2001, + ): + dt = date(year, 2 if day < 9 else 1, day) + self.assertIn(dt, auk_holidays, dt) + self.assertEqual(auk_holidays[dt], "Auckland Anniversary Day") + + def test_taranaki_anniversary_day(self): + tki_holidays = holidays.NZ(prov="Taranaki") + for year, day in enumerate( + [ + 12, + 11, + 10, + 8, + 14, # 2001-05 + 13, + 12, + 10, + 9, + 8, # 2006-10 + 14, + 12, + 11, + 10, + 9, # 2011-15 + 14, + 13, + 12, + 11, + 9, + 8, + ], # 2016-21 + 2001, + ): + dt = date(year, 3, day) + self.assertIn(dt, tki_holidays, dt) + self.assertEqual(tki_holidays[dt], "Taranaki Anniversary Day") + + def test_hawkes_bay_anniversary_day(self): + hkb_holidays = holidays.NZ(prov="Hawke's Bay") + for year, day in enumerate( + [ + 19, + 25, + 24, + 22, + 21, # 2001-05 + 20, + 19, + 24, + 23, + 22, # 2006-10 + 21, + 19, + 25, + 24, + 23, # 2011-15 + 21, + 20, + 19, + 25, + 23, + 22, + ], # 2016-21 + 2001, + ): + dt = date(year, 10, day) + self.assertIn(dt, hkb_holidays, dt) + self.assertEqual(hkb_holidays[dt], "Hawke's Bay Anniversary Day") + + def test_wellington_anniversary_day(self): + wgn_holidays = holidays.NZ(prov="Wellington") + for year, day in enumerate( + [ + 22, + 21, + 20, + 19, + 24, # 2001-05 + 23, + 22, + 21, + 19, + 25, # 2006-10 + 24, + 23, + 21, + 20, + 19, # 2011-15 + 25, + 23, + 22, + 21, + 20, + 25, + ], # 2016-21 + 2001, + ): + dt = date(year, 1, day) + self.assertIn(dt, wgn_holidays, dt) + self.assertEqual( + wgn_holidays[dt], "Wellington Anniversary Day", dt + ) + + def test_marlborough_anniversary_day(self): + mbh_holidays = holidays.NZ(prov="Marlborough") + for year, day in enumerate( + [ + 29, + 4, + 3, + 1, + 31, # 2001-05 + 30, + 29, + 3, + 2, + 1, # 2006-10 + 31, + 29, + 4, + 3, + 2, # 2011-15 + 31, + 30, + 29, + 4, + 2, + 1, + ], # 2016-21 + 2001, + ): + dt = date(year, 11 if day < 9 else 10, day) + self.assertIn(dt, mbh_holidays, dt) + self.assertEqual( + mbh_holidays[dt], "Marlborough Anniversary Day", dt + ) + + def test_nelson_anniversary_day(self): + nsn_holidays = holidays.NZ(prov="Nelson") + for year, day in enumerate( + [ + 29, + 4, + 3, + 2, + 31, # 2001-05 + 30, + 29, + 4, + 2, + 1, # 2006-10 + 31, + 30, + 4, + 3, + 2, # 2011-15 + 1, + 30, + 29, + 4, + 3, + 1, + ], # 2016-21 + 2001, + ): + dt = date(year, 2 if day < 9 else 1, day) + self.assertIn(dt, nsn_holidays, dt) + self.assertEqual(nsn_holidays[dt], "Nelson Anniversary Day", dt) + + def test_canterbury_anniversary_day(self): + can_holidays = holidays.NZ(prov="Canterbury") + for year, day in enumerate( + [ + 16, + 15, + 14, + 12, + 11, # 2001-05 + 17, + 16, + 14, + 13, + 12, # 2006-10 + 11, + 16, + 15, + 14, + 13, # 2011-15 + 11, + 17, + 16, + 15, + 13, + 12, + ], # 2016-21 + 2001, + ): + dt = date(year, 11, day) + self.assertIn(dt, can_holidays, dt) + self.assertEqual( + can_holidays[dt], "Canterbury Anniversary Day", dt + ) + + def test_south_canterbury_anniversary_day(self): + stc_holidays = holidays.NZ(prov="South Canterbury") + for year, day in enumerate( + [ + 24, + 23, + 22, + 27, + 26, # 2001-05 + 25, + 24, + 22, + 28, + 27, # 2006-10 + 26, + 24, + 23, + 22, + 28, # 2011-15 + 26, + 25, + 24, + 23, + 28, + 27, + ], # 2016-21 + 2001, + ): + dt = date(year, 9, day) + self.assertIn(dt, stc_holidays, dt) + self.assertEqual( + stc_holidays[dt], "South Canterbury Anniversary Day", dt + ) + + def test_westland_anniversary_day(self): + wtc_holidays = holidays.NZ(prov="Westland") + for year, day in enumerate( + [ + 3, + 2, + 1, + 29, + 5, # 2001-05 + 4, + 3, + 1, + 30, + 29, # 2006-10 + 28, + 3, + 2, + 1, + 30, # 2011-15 + 28, + 4, + 3, + 2, + 30, + 29, + ], # 2016-21 + 2001, + ): + dt = date(year, 12 if day < 9 else 11, day) + self.assertIn(dt, wtc_holidays, dt) + self.assertEqual(wtc_holidays[dt], "Westland Anniversary Day", dt) + + def test_otago_anniversary_day(self): + ota_holidays = holidays.NZ(prov="Otago") + for year, day in enumerate( + [ + 26, + 25, + 24, + 22, + 21, # 2001-05 + 20, + 26, + 25, + 23, + 22, # 2006-10 + 21, + 26, + 25, + 24, + 23, # 2011-15 + 21, + 20, + 26, + 25, + 23, + 22, + ], # 2016-21 + 2001, + ): + dt = date(year, 3, day) + self.assertIn(dt, ota_holidays, dt) + self.assertEqual(ota_holidays[dt], "Otago Anniversary Day", dt) + + def test_southland_anniversary_day(self): + stl_holidays = holidays.NZ(prov="Southland") + for year, day in enumerate( + [15, 14, 20, 19, 17, 16, 15, 14, 19, 18, 17], + 2001, # 2001-05 # 2006-11 + ): + dt = date(year, 1, day) + self.assertIn(dt, stl_holidays, dt) + self.assertEqual(stl_holidays[dt], "Southland Anniversary Day", dt) + for year, (month, day) in enumerate( + [ + (4, 10), + (4, 2), + (4, 22), + (4, 7), + (3, 29), + (4, 18), + (4, 3), + (4, 23), + (4, 14), + (4, 6), + ], + 2012, + ): + dt = date(year, month, day) + self.assertIn(dt, stl_holidays, dt) + self.assertEqual( + stl_holidays[dt], "Southland Anniversary Day", dt + ) + + def test_chatham_islands_anniversary_day(self): + cit_holidays = holidays.NZ(prov="Chatham Islands") + for year, day in enumerate( + [ + 3, + 2, + 1, + 29, + 28, # 2001-05 + 27, + 3, + 1, + 30, + 29, # 2006-10 + 28, + 3, + 2, + 1, + 30, # 2011-15 + 28, + 27, + 3, + 2, + 30, + 29, + ], # 2016-21 + 2001, + ): + dt = date(year, 12 if day < 9 else 11, day) + self.assertIn(dt, cit_holidays, dt) + self.assertEqual( + cit_holidays[dt], "Chatham Islands Anniversary Day", dt + ) + + def test_all_holidays_present(self): + nz_1969 = sum( + holidays.NZ(years=[1969], prov=p) for p in holidays.NZ.PROVINCES + ) + holidays_in_1969 = sum((nz_1969.get_list(key) for key in nz_1969), []) + nz_2015 = sum( + holidays.NZ(years=[2015], prov=p) for p in holidays.NZ.PROVINCES + ) + holidays_in_2015 = sum((nz_2015.get_list(key) for key in nz_2015), []) + nz_1974 = sum( + holidays.NZ(years=[1974], prov=p) for p in holidays.NZ.PROVINCES + ) + holidays_in_1974 = sum((nz_1974.get_list(key) for key in nz_1974), []) + all_holidays = [ + "New Year's Day", + "Day after New Year's Day", + "Waitangi Day", + "Good Friday", + "Easter Monday", + "Anzac Day", + "Queen's Birthday", + "Labour Day", + "Christmas Day", + "Boxing Day", + "Auckland Anniversary Day", + "Taranaki Anniversary Day", + "Hawke's Bay Anniversary Day", + "Wellington Anniversary Day", + "Marlborough Anniversary Day", + "Nelson Anniversary Day", + "Canterbury Anniversary Day", + "South Canterbury Anniversary Day", + "Westland Anniversary Day", + "Otago Anniversary Day", + "Southland Anniversary Day", + "Chatham Islands Anniversary Day", + "Queen's Birthday", + "Labour Day", + "Christmas Day", + "Boxing Day", + ] + for holiday in all_holidays: + self.assertIn(holiday, holidays_in_1969, holiday) + self.assertIn(holiday, holidays_in_2015, holiday) + all_holidays.remove("Waitangi Day") + all_holidays.insert(2, "New Zealand Day") + for holiday in all_holidays: + self.assertIn(holiday, holidays_in_1974, holiday) + self.assertNotIn("Waitangi Day", holidays_in_1974) diff --git a/test/countries/test_nicaragua.py b/test/countries/test_nicaragua.py new file mode 100644 index 000000000..1a905a96a --- /dev/null +++ b/test/countries/test_nicaragua.py @@ -0,0 +1,50 @@ +# -*- coding: utf-8 -*- + +# python-holidays +# --------------- +# A fast, efficient Python library for generating country, province and state +# specific sets of holidays on the fly. It aims to make determining whether a +# specific date is a holiday as fast and flexible as possible. +# +# Author: ryanss (c) 2014-2017 +# dr-prodigy (c) 2017-2021 +# Website: https://github.com/dr-prodigy/python-holidays +# License: MIT (see LICENSE file) + +import unittest + +from datetime import date + +import holidays + + +class TestNicaragua(unittest.TestCase): + def setUp(self): + self.ni_holidays = holidays.NI() + + def test_ni_holidays_2020(self): + year = 2020 + mn_holidays = holidays.NI(prov="MN") + + # New Year's Day + self.assertIn(date(year, 1, 1), self.ni_holidays) + # Maundy Thursday + self.assertIn(date(year, 4, 9), self.ni_holidays) + # Good Friday + self.assertIn(date(year, 4, 10), self.ni_holidays) + # Labor Day + self.assertIn(date(year, 5, 1), self.ni_holidays) + # Revolution Day + self.assertIn(date(year, 7, 19), self.ni_holidays) + # Battle of San Jacinto Day + self.assertIn(date(year, 9, 14), self.ni_holidays) + # Independence Day + self.assertIn(date(year, 9, 15), self.ni_holidays) + # Virgin's Day + self.assertIn(date(year, 12, 8), self.ni_holidays) + # Christmas Day + self.assertIn(date(year, 12, 25), self.ni_holidays) + # Santo Domingo Day Down + self.assertIn(date(year, 8, 1), mn_holidays) + # Santo Domingo Day Up + self.assertIn(date(year, 8, 10), mn_holidays) diff --git a/test/countries/test_nigeria.py b/test/countries/test_nigeria.py new file mode 100644 index 000000000..7077fb0ba --- /dev/null +++ b/test/countries/test_nigeria.py @@ -0,0 +1,32 @@ +# -*- coding: utf-8 -*- + +# python-holidays +# --------------- +# A fast, efficient Python library for generating country, province and state +# specific sets of holidays on the fly. It aims to make determining whether a +# specific date is a holiday as fast and flexible as possible. +# +# Author: ryanss (c) 2014-2017 +# dr-prodigy (c) 2017-2021 +# Website: https://github.com/dr-prodigy/python-holidays +# License: MIT (see LICENSE file) + +import unittest + +from datetime import date + +import holidays + + +class TestNigeria(unittest.TestCase): + def setUp(self): + self.holidays = holidays.Nigeria() + + def test_fixed_holidays(self): + self.assertIn(date(2019, 1, 1), self.holidays) + self.assertIn(date(2019, 5, 1), self.holidays) + self.assertIn(date(2019, 5, 27), self.holidays) + self.assertIn(date(2019, 6, 12), self.holidays) + self.assertIn(date(2019, 10, 1), self.holidays) + self.assertIn(date(2019, 12, 25), self.holidays) + self.assertIn(date(2019, 12, 26), self.holidays) diff --git a/test/countries/test_norway.py b/test/countries/test_norway.py new file mode 100644 index 000000000..f6bea111b --- /dev/null +++ b/test/countries/test_norway.py @@ -0,0 +1,132 @@ +# -*- coding: utf-8 -*- + +# python-holidays +# --------------- +# A fast, efficient Python library for generating country, province and state +# specific sets of holidays on the fly. It aims to make determining whether a +# specific date is a holiday as fast and flexible as possible. +# +# Author: ryanss (c) 2014-2017 +# dr-prodigy (c) 2017-2021 +# Website: https://github.com/dr-prodigy/python-holidays +# License: MIT (see LICENSE file) + +import unittest + + +import holidays + + +class TestNorway(unittest.TestCase): + def setUp(self): + self.holidays_without_sundays = holidays.Norway(include_sundays=False) + self.holidays_with_sundays = holidays.Norway() + + def test_new_years(self): + self.assertIn("1900-01-01", self.holidays_without_sundays) + self.assertIn("2017-01-01", self.holidays_without_sundays) + self.assertIn("2999-01-01", self.holidays_without_sundays) + + def test_easter(self): + self.assertIn("2000-04-20", self.holidays_without_sundays) + self.assertIn("2000-04-21", self.holidays_without_sundays) + self.assertIn("2000-04-23", self.holidays_without_sundays) + self.assertIn("2000-04-24", self.holidays_without_sundays) + + self.assertIn("2010-04-01", self.holidays_without_sundays) + self.assertIn("2010-04-02", self.holidays_without_sundays) + self.assertIn("2010-04-04", self.holidays_without_sundays) + self.assertIn("2010-04-05", self.holidays_without_sundays) + + self.assertIn("2021-04-01", self.holidays_without_sundays) + self.assertIn("2021-04-02", self.holidays_without_sundays) + self.assertIn("2021-04-04", self.holidays_without_sundays) + self.assertIn("2021-04-05", self.holidays_without_sundays) + + self.assertIn("2024-03-28", self.holidays_without_sundays) + self.assertIn("2024-03-29", self.holidays_without_sundays) + self.assertIn("2024-03-31", self.holidays_without_sundays) + self.assertIn("2024-04-01", self.holidays_without_sundays) + + def test_workers_day(self): + self.assertNotIn("1900-05-01", self.holidays_without_sundays) + self.assertNotIn("1946-05-01", self.holidays_without_sundays) + self.assertIn("1947-05-01", self.holidays_without_sundays) + self.assertIn("2017-05-01", self.holidays_without_sundays) + self.assertIn("2999-05-01", self.holidays_without_sundays) + + def test_constitution_day(self): + self.assertNotIn("1900-05-17", self.holidays_without_sundays) + self.assertNotIn("1946-05-17", self.holidays_without_sundays) + self.assertIn("1947-05-17", self.holidays_without_sundays) + self.assertIn("2017-05-17", self.holidays_without_sundays) + self.assertIn("2999-05-17", self.holidays_without_sundays) + + def test_pentecost(self): + self.assertIn("2000-06-11", self.holidays_without_sundays) + self.assertIn("2000-06-12", self.holidays_without_sundays) + + self.assertIn("2010-05-23", self.holidays_without_sundays) + self.assertIn("2010-05-24", self.holidays_without_sundays) + + self.assertIn("2021-05-23", self.holidays_without_sundays) + self.assertIn("2021-05-24", self.holidays_without_sundays) + + self.assertIn("2024-05-19", self.holidays_without_sundays) + self.assertIn("2024-05-20", self.holidays_without_sundays) + + def test_christmas(self): + self.assertIn("1901-12-25", self.holidays_without_sundays) + self.assertIn("1901-12-26", self.holidays_without_sundays) + + self.assertIn("2016-12-25", self.holidays_without_sundays) + self.assertIn("2016-12-26", self.holidays_without_sundays) + + self.assertIn("2500-12-25", self.holidays_without_sundays) + self.assertIn("2500-12-26", self.holidays_without_sundays) + + def test_sundays(self): + """ + Sundays are considered holidays in Norway + :return: + """ + self.assertIn("1989-12-31", self.holidays_with_sundays) + self.assertIn("2017-02-05", self.holidays_with_sundays) + self.assertIn("2017-02-12", self.holidays_with_sundays) + self.assertIn("2032-02-29", self.holidays_with_sundays) + + def test_not_holiday(self): + """ + Note: Sundays in Norway are considered holidays, + so make sure none of these are actually Sundays + + TODO: Should add more dates that are often confused for being a holiday + :return: + """ + self.assertNotIn("2017-02-06", self.holidays_without_sundays) + self.assertNotIn("2017-02-07", self.holidays_without_sundays) + self.assertNotIn("2017-02-08", self.holidays_without_sundays) + self.assertNotIn("2017-02-09", self.holidays_without_sundays) + self.assertNotIn("2017-02-10", self.holidays_without_sundays) + + self.assertNotIn("2001-12-24", self.holidays_without_sundays) + self.assertNotIn("2001-05-16", self.holidays_without_sundays) + self.assertNotIn("2001-05-18", self.holidays_without_sundays) + self.assertNotIn("1999-12-31", self.holidays_without_sundays) + self.assertNotIn("2016-12-31", self.holidays_without_sundays) + self.assertNotIn("2016-12-27", self.holidays_without_sundays) + self.assertNotIn("2016-12-28", self.holidays_without_sundays) + + self.assertNotIn("2017-02-06", self.holidays_with_sundays) + self.assertNotIn("2017-02-07", self.holidays_with_sundays) + self.assertNotIn("2017-02-08", self.holidays_with_sundays) + self.assertNotIn("2017-02-09", self.holidays_with_sundays) + self.assertNotIn("2017-02-10", self.holidays_with_sundays) + + self.assertNotIn("2001-12-24", self.holidays_with_sundays) + self.assertNotIn("2001-05-16", self.holidays_with_sundays) + self.assertNotIn("2001-05-18", self.holidays_with_sundays) + self.assertNotIn("1999-12-31", self.holidays_with_sundays) + self.assertNotIn("2016-12-31", self.holidays_with_sundays) + self.assertNotIn("2016-12-27", self.holidays_with_sundays) + self.assertNotIn("2016-12-28", self.holidays_with_sundays) diff --git a/test/countries/test_paraguay.py b/test/countries/test_paraguay.py new file mode 100644 index 000000000..5b8c27d59 --- /dev/null +++ b/test/countries/test_paraguay.py @@ -0,0 +1,89 @@ +# -*- coding: utf-8 -*- + +# python-holidays +# --------------- +# A fast, efficient Python library for generating country, province and state +# specific sets of holidays on the fly. It aims to make determining whether a +# specific date is a holiday as fast and flexible as possible. +# +# Author: ryanss (c) 2014-2017 +# dr-prodigy (c) 2017-2021 +# Website: https://github.com/dr-prodigy/python-holidays +# License: MIT (see LICENSE file) + +import unittest + +from datetime import date, timedelta + +import holidays + + +class TestParaguay(unittest.TestCase): + def setUp(self): + self.holidays = holidays.PY() + + def test_fixed_holidays(self): + checkdates = ( + date(2016, 1, 1), + date(2020, 1, 1), + date(2020, 3, 2), + date(2020, 4, 9), + date(2020, 5, 1), + date(2020, 5, 15), + date(2020, 6, 15), + date(2020, 8, 15), + date(2020, 9, 29), + date(2020, 12, 8), + date(2020, 12, 25), + ) + + for d in checkdates: + self.assertIn(d, self.holidays) + + def test_no_observed(self): + # no observed dates + self.holidays.observed = False + checkdates = ( + date(2017, 1, 1), + date(2014, 3, 2), + date(2020, 4, 12), + date(2016, 5, 1), + date(2016, 5, 15), + date(2016, 6, 12), + date(2015, 8, 15), + date(2018, 9, 29), + date(2018, 12, 8), + ) + + for d in checkdates: + self.assertNotIn(d, self.holidays) + + def test_easter(self): + for year, month, day in [ + (2002, 3, 31), + (2003, 4, 20), + (2004, 4, 11), + (2005, 3, 27), + (2006, 4, 16), + (2007, 4, 8), + (2008, 3, 23), + (2009, 4, 12), + (2010, 4, 4), + (2011, 4, 24), + (2012, 4, 8), + (2013, 3, 31), + (2014, 4, 20), + (2015, 4, 5), + (2016, 3, 27), + (2017, 4, 16), + (2018, 4, 1), + (2019, 4, 21), + (2020, 4, 12), + (2021, 4, 4), + (2022, 4, 17), + ]: + easter = date(year, month, day) + easter_thursday = easter - timedelta(days=3) + easter_friday = easter - timedelta(days=2) + for holiday in [easter_thursday, easter_friday, easter]: + self.assertIn(holiday, self.holidays) diff --git a/test/countries/test_peru.py b/test/countries/test_peru.py new file mode 100644 index 000000000..e093826b7 --- /dev/null +++ b/test/countries/test_peru.py @@ -0,0 +1,37 @@ +# -*- coding: utf-8 -*- + +# python-holidays +# --------------- +# A fast, efficient Python library for generating country, province and state +# specific sets of holidays on the fly. It aims to make determining whether a +# specific date is a holiday as fast and flexible as possible. +# +# Author: ryanss (c) 2014-2017 +# dr-prodigy (c) 2017-2021 +# Website: https://github.com/dr-prodigy/python-holidays +# License: MIT (see LICENSE file) + +import unittest + +from datetime import date + +import holidays + + +class TestPeru(unittest.TestCase): + def setUp(self): + self.holidays = holidays.Peru() + + def test_2019(self): + # No laborables (sector público) not included + self.assertIn(date(2019, 1, 1), self.holidays) + self.assertIn(date(2019, 4, 18), self.holidays) + self.assertIn(date(2019, 4, 19), self.holidays) + self.assertIn(date(2019, 5, 1), self.holidays) + self.assertIn(date(2019, 6, 29), self.holidays) + self.assertIn(date(2019, 7, 29), self.holidays) + self.assertIn(date(2019, 8, 30), self.holidays) + self.assertIn(date(2019, 10, 8), self.holidays) + self.assertIn(date(2019, 11, 1), self.holidays) + self.assertIn(date(2019, 12, 8), self.holidays) + self.assertIn(date(2019, 12, 25), self.holidays) diff --git a/test/countries/test_poland.py b/test/countries/test_poland.py new file mode 100644 index 000000000..e1f08601b --- /dev/null +++ b/test/countries/test_poland.py @@ -0,0 +1,48 @@ +# -*- coding: utf-8 -*- + +# python-holidays +# --------------- +# A fast, efficient Python library for generating country, province and state +# specific sets of holidays on the fly. It aims to make determining whether a +# specific date is a holiday as fast and flexible as possible. +# +# Author: ryanss (c) 2014-2017 +# dr-prodigy (c) 2017-2021 +# Website: https://github.com/dr-prodigy/python-holidays +# License: MIT (see LICENSE file) + +import unittest +import warnings + +from datetime import date + +import holidays + + +class TestPL(unittest.TestCase): + def setUp(self): + self.holidays = holidays.PL() + + def test_2017(self): + # http://www.officeholidays.com/countries/poland/2017.php + self.assertIn(date(2017, 1, 1), self.holidays) + self.assertIn(date(2017, 1, 6), self.holidays) + self.assertIn(date(2017, 4, 16), self.holidays) + self.assertIn(date(2017, 4, 17), self.holidays) + self.assertIn(date(2017, 5, 1), self.holidays) + self.assertIn(date(2017, 5, 3), self.holidays) + self.assertIn(date(2017, 6, 4), self.holidays) + self.assertIn(date(2017, 6, 15), self.holidays) + self.assertIn(date(2017, 8, 15), self.holidays) + self.assertIn(date(2017, 11, 1), self.holidays) + self.assertIn(date(2017, 11, 11), self.holidays) + self.assertIn(date(2017, 12, 25), self.holidays) + self.assertIn(date(2017, 12, 26), self.holidays) + + def test_polish_deprecated(self): + with warnings.catch_warnings(record=True) as w: + warnings.simplefilter("always") + poland = holidays.Polish() + self.assertIsInstance(poland, holidays.Poland) + self.assertEqual(1, len(w)) + self.assertTrue(issubclass(w[-1].category, DeprecationWarning)) diff --git a/test/countries/test_portugal.py b/test/countries/test_portugal.py new file mode 100644 index 000000000..ca29abe99 --- /dev/null +++ b/test/countries/test_portugal.py @@ -0,0 +1,49 @@ +# -*- coding: utf-8 -*- + +# python-holidays +# --------------- +# A fast, efficient Python library for generating country, province and state +# specific sets of holidays on the fly. It aims to make determining whether a +# specific date is a holiday as fast and flexible as possible. +# +# Author: ryanss (c) 2014-2017 +# dr-prodigy (c) 2017-2021 +# Website: https://github.com/dr-prodigy/python-holidays +# License: MIT (see LICENSE file) + +import unittest + +from datetime import date + +import holidays + + +class TestPT(unittest.TestCase): + def setUp(self): + self.holidays = holidays.PT() + + def test_2017(self): + # http://www.officeholidays.com/countries/portugal/2017.php + self.assertIn(date(2017, 1, 1), self.holidays) # New Year + self.assertIn(date(2017, 4, 14), self.holidays) # Good Friday + self.assertIn(date(2017, 4, 16), self.holidays) # Easter + self.assertIn(date(2017, 4, 25), self.holidays) # Liberation Day + self.assertIn(date(2017, 5, 1), self.holidays) # Labour Day + self.assertIn(date(2017, 6, 10), self.holidays) # Portugal Day + self.assertIn(date(2017, 6, 15), self.holidays) # Corpus Christi + self.assertIn(date(2017, 8, 15), self.holidays) # Assumption Day + self.assertIn(date(2017, 10, 5), self.holidays) # Republic Day + self.assertIn(date(2017, 11, 1), self.holidays) # All Saints Day + self.assertIn(date(2017, 12, 1), self.holidays) # Independence + self.assertIn(date(2017, 12, 8), self.holidays) # Immaculate + self.assertIn(date(2017, 12, 25), self.holidays) # Christmas + + +class TestPortugalExt(unittest.TestCase): + def setUp(self): + self.holidays = holidays.PortugalExt() + + def test_2017(self): + self.assertIn(date(2017, 12, 24), self.holidays) # Christmas' Eve + self.assertIn(date(2017, 12, 26), self.holidays) # S.Stephan + self.assertIn(date(2017, 12, 26), self.holidays) # New Year's Eve diff --git a/test/countries/test_romania.py b/test/countries/test_romania.py new file mode 100644 index 000000000..6f081ab49 --- /dev/null +++ b/test/countries/test_romania.py @@ -0,0 +1,47 @@ +# -*- coding: utf-8 -*- + +# python-holidays +# --------------- +# A fast, efficient Python library for generating country, province and state +# specific sets of holidays on the fly. It aims to make determining whether a +# specific date is a holiday as fast and flexible as possible. +# +# Author: ryanss (c) 2014-2017 +# dr-prodigy (c) 2017-2021 +# Website: https://github.com/dr-prodigy/python-holidays +# License: MIT (see LICENSE file) + +import unittest + +from datetime import date + +import holidays + + +class TestRomania(unittest.TestCase): + def setUp(self): + self.holidays = holidays.RO() + + def test_2020(self): + # https://en.wikipedia.org/wiki/Public_holidays_in_Romania + # https://publicholidays.ro/2020-dates/ + self.assertIn(date(2020, 1, 1), self.holidays) + self.assertIn(date(2020, 1, 2), self.holidays) + self.assertIn(date(2020, 1, 24), self.holidays) + self.assertIn(date(2020, 4, 17), self.holidays) + self.assertIn(date(2020, 4, 19), self.holidays) + self.assertIn(date(2020, 4, 20), self.holidays) + self.assertIn(date(2020, 5, 1), self.holidays) + self.assertIn(date(2020, 6, 1), self.holidays) + self.assertIn(date(2020, 6, 7), self.holidays) + self.assertIn(date(2020, 6, 8), self.holidays) + self.assertIn(date(2020, 8, 15), self.holidays) + self.assertIn(date(2020, 11, 30), self.holidays) + self.assertIn(date(2020, 12, 1), self.holidays) + self.assertIn(date(2020, 12, 25), self.holidays) + self.assertIn(date(2020, 12, 26), self.holidays) + + def test_children_s_day(self): + # Children’s Day became an official Romanian public holiday in 2017. + self.assertNotIn(date(2016, 6, 1), self.holidays) + self.assertIn(date(2017, 6, 1), self.holidays) diff --git a/test/countries/test_russia.py b/test/countries/test_russia.py new file mode 100644 index 000000000..080ecb43c --- /dev/null +++ b/test/countries/test_russia.py @@ -0,0 +1,45 @@ +# -*- coding: utf-8 -*- + +# python-holidays +# --------------- +# A fast, efficient Python library for generating country, province and state +# specific sets of holidays on the fly. It aims to make determining whether a +# specific date is a holiday as fast and flexible as possible. +# +# Author: ryanss (c) 2014-2017 +# dr-prodigy (c) 2017-2021 +# Website: https://github.com/dr-prodigy/python-holidays +# License: MIT (see LICENSE file) + +import unittest + +from datetime import date + +import holidays + + +class TestRussia(unittest.TestCase): + def setUp(self): + self.holidays = holidays.RU() + + def test_before_2005(self): + self.assertIn(date(2004, 11, 7), self.holidays) + self.assertNotIn(date(2004, 11, 4), self.holidays) + + def test_2018(self): + # https://en.wikipedia.org/wiki/Public_holidays_in_Russia + self.assertIn(date(2018, 1, 1), self.holidays) + self.assertIn(date(2018, 1, 2), self.holidays) + self.assertIn(date(2018, 1, 3), self.holidays) + self.assertIn(date(2018, 1, 4), self.holidays) + self.assertIn(date(2018, 1, 5), self.holidays) + self.assertIn(date(2018, 1, 6), self.holidays) + self.assertIn(date(2018, 1, 7), self.holidays) + self.assertIn(date(2018, 1, 8), self.holidays) + self.assertIn(date(2018, 2, 23), self.holidays) + self.assertIn(date(2018, 3, 8), self.holidays) + self.assertIn(date(2018, 5, 1), self.holidays) + self.assertIn(date(2018, 5, 9), self.holidays) + self.assertIn(date(2018, 6, 12), self.holidays) + self.assertIn(date(2018, 11, 4), self.holidays) + self.assertNotIn(date(2018, 11, 7), self.holidays) diff --git a/test/countries/test_saudi_arabia.py b/test/countries/test_saudi_arabia.py new file mode 100644 index 000000000..705460541 --- /dev/null +++ b/test/countries/test_saudi_arabia.py @@ -0,0 +1,169 @@ +# -*- coding: utf-8 -*- + +# python-holidays +# --------------- +# A fast, efficient Python library for generating country, province and state +# specific sets of holidays on the fly. It aims to make determining whether a +# specific date is a holiday as fast and flexible as possible. +# +# Author: ryanss (c) 2014-2017 +# dr-prodigy (c) 2017-2021 +# Website: https://github.com/dr-prodigy/python-holidays +# License: MIT (see LICENSE file) + +import sys +import unittest + +from datetime import date + +import holidays + + +class TestSaudiArabia(unittest.TestCase): + def setUp(self): + self.holidays = holidays.SA(observed=True) + + def test_2020(self): + # Eid al-Fitr Holiday + # (skipping 14, and 15 because they are weekends) + self.assertIn(date(2021, 5, 12), self.holidays) + self.assertIn(date(2021, 5, 13), self.holidays) + self.assertIn(date(2021, 5, 16), self.holidays) + self.assertIn(date(2021, 5, 17), self.holidays) + # Eid al-Fitr Holiday + self.assertIn(date(2021, 7, 19), self.holidays) + self.assertIn(date(2021, 7, 20), self.holidays) + self.assertIn(date(2021, 7, 21), self.holidays) + self.assertIn(date(2021, 7, 22), self.holidays) + # National day holiday + self.assertIn(date(2021, 9, 23), self.holidays) + + def test_national_day(self): + self.assertIn(date(2020, 9, 23), self.holidays) + # National day started as a holiday at 2005 + self.assertNotIn(date(2004, 9, 23), self.holidays) + self.assertIn(date(2005, 9, 23), self.holidays) + + def test_national_day_observed(self): + # September 23rd, 2016 was Friday (Weekend) + # so, observed is Thursday + self.assertIn(date(2016, 9, 22), self.holidays) + self.assertIn(date(2016, 9, 23), self.holidays) + self.assertNotIn(date(2016, 9, 24), self.holidays) + + # September 23rd, 2017 was Saturday (Weekend) + # so, observed is Sunday + self.assertNotIn(date(2017, 9, 22), self.holidays) + self.assertIn(date(2017, 9, 23), self.holidays) + self.assertIn(date(2017, 9, 24), self.holidays) + + def test_national_day_not_observed(self): + self.holidays.observed = False + self.assertNotIn(date(2016, 9, 22), self.holidays) + self.assertNotIn(date(2017, 9, 24), self.holidays) + + def test_hijri_based(self): + if sys.version_info >= (3, 6): + import importlib.util + + if importlib.util.find_spec("hijri_converter"): + self.holidays = holidays.SA(years=[2020]) + # eid alfitr + self.assertIn(date(2020, 5, 23), self.holidays) + self.assertIn(date(2020, 5, 24), self.holidays) + self.assertIn(date(2020, 5, 25), self.holidays) + self.assertIn(date(2020, 5, 26), self.holidays) + + # eid aladha + self.assertIn(date(2020, 7, 30), self.holidays) + self.assertIn(date(2020, 7, 31), self.holidays) + self.assertIn(date(2020, 8, 1), self.holidays) + self.assertIn(date(2020, 8, 2), self.holidays) + + def test_hijri_based_observed(self): + if sys.version_info >= (3, 6): + import importlib.util + + if importlib.util.find_spec("hijri_converter"): + self.holidays = holidays.SA(years=range(2014, 2021)) + # observed eid alfitr + self.assertIn(date(2020, 5, 27), self.holidays) + + # self.assertIn(date(2016, 7, 10), self.holidays) + # self.assertIn(date(2016, 7, 11), self.holidays) + + self.assertIn(date(2018, 6, 18), self.holidays) + self.assertIn(date(2018, 6, 19), self.holidays) + + self.assertIn(date(2019, 6, 9), self.holidays) + + # osbserved eid aladha + self.assertIn(date(2014, 10, 8), self.holidays) + + # self.assertIn(date(2017, 8, 3), self.holidays) + # self.assertIn(date(2017, 8, 4), self.holidays) + + # self.assertIn(date(2019, 8, 13), self.holidays) + # self.assertIn(date(2019, 8, 14), self.holidays) + + # self.assertIn(date(2017, 8, 6), self.holidays) + + def test_hijri_based_not_observed(self): + + if sys.version_info >= (3, 6): + import importlib.util + + if importlib.util.find_spec("hijri_converter"): + self.holidays = holidays.SA( + observed=False, years=range(2014, 2021) + ) + # observed eid alfitr + self.assertNotIn(date(2020, 5, 27), self.holidays) + + # self.assertNotIn(date(2016, 7, 10), self.holidays) + # self.assertNotIn(date(2016, 7, 11), self.holidays) + + self.assertNotIn(date(2018, 6, 18), self.holidays) + self.assertNotIn(date(2018, 6, 19), self.holidays) + + self.assertNotIn(date(2019, 6, 9), self.holidays) + + # osbserved eid aladha + self.assertNotIn(date(2014, 10, 8), self.holidays) + + # self.assertNotIn(date(2017, 8, 3), self.holidays) + # self.assertNotIn(date(2017, 8, 4), self.holidays) + + # self.assertNotIn(date(2019, 8, 13), self.holidays) + # self.assertNotIn(date(2019, 8, 14), self.holidays) + + # self.assertNotIn(date(2017, 8, 6), self.holidays) + + def test_hijri_based_with_two_holidays_in_one_year(self): + """ + Note: this might required change if weekend changes + took effect in the holiday.SA class (weekend changed + on June 28th, 2013), from (Thursdays and Fridays) to + (Fridays, Saturdays). + Currently, using newest weekend days (Fridays, and Saturdays) + """ + if sys.version_info >= (3, 6): + import importlib.util + + if importlib.util.find_spec("hijri_converter"): + self.holidays = holidays.SA(years=[2006]) + # eid_alfitr + # 23rd is a weekend day (Saturday), so there + # is a one day shift + self.assertIn(date(2006, 10, 23), self.holidays) + self.assertIn(date(2006, 10, 24), self.holidays) + self.assertIn(date(2006, 10, 25), self.holidays) + self.assertIn(date(2006, 10, 26), self.holidays) + # eid_aladha 1 (hijiry year 1426) + self.assertIn(date(2006, 1, 9), self.holidays) + self.assertIn(date(2006, 1, 10), self.holidays) + self.assertIn(date(2006, 1, 11), self.holidays) + self.assertIn(date(2006, 1, 12), self.holidays) + # eid_aladha 2 (hijiry year 1427) + # The remaining holidays fall in the next year 2007 + self.assertIn(date(2006, 12, 31), self.holidays) diff --git a/test/countries/test_serbia.py b/test/countries/test_serbia.py new file mode 100644 index 000000000..972c3ed7b --- /dev/null +++ b/test/countries/test_serbia.py @@ -0,0 +1,66 @@ +# -*- coding: utf-8 -*- + +# python-holidays +# --------------- +# A fast, efficient Python library for generating country, province and state +# specific sets of holidays on the fly. It aims to make determining whether a +# specific date is a holiday as fast and flexible as possible. +# +# Author: ryanss (c) 2014-2017 +# dr-prodigy (c) 2017-2021 +# Website: https://github.com/dr-prodigy/python-holidays +# License: MIT (see LICENSE file) + +import unittest + +from datetime import date + +import holidays + + +class TestSerbia(unittest.TestCase): + def setUp(self): + self.holidays = holidays.Serbia(observed=True) + + def test_new_year(self): + # If January 1st is in Weekend, test oberved + self.assertIn(date(2017, 1, 1), self.holidays) + self.assertIn(date(2017, 1, 2), self.holidays) + self.assertIn(date(2017, 1, 3), self.holidays) + self.holidays.observed = False + self.assertNotIn(date(2017, 1, 3), self.holidays) + + def test_statehood_day(self): + # If February 15th is in Weekend, test oberved + self.assertIn(date(2020, 2, 15), self.holidays) + self.assertIn(date(2020, 2, 16), self.holidays) + self.assertIn(date(2020, 2, 17), self.holidays) + self.holidays.observed = False + self.assertNotIn(date(2020, 2, 17), self.holidays) + + def test_labour_day(self): + # If May 1st is in Weekend, test oberved + self.assertIn(date(2016, 5, 1), self.holidays) + self.assertIn(date(2016, 5, 2), self.holidays) + self.assertIn(date(2016, 5, 3), self.holidays) + self.holidays.observed = False + self.assertNotIn(date(2016, 5, 3), self.holidays) + + def test_armistice_day(self): + # If November 11th is in Weekend, test oberved + self.assertIn(date(2018, 11, 11), self.holidays) + self.assertIn(date(2018, 11, 12), self.holidays) + self.holidays.observed = False + self.assertNotIn(date(2018, 11, 12), self.holidays) + + def test_religious_holidays(self): + # Orthodox Christmas + self.assertIn(date(2020, 1, 7), self.holidays) + self.assertNotIn(date(2020, 1, 8), self.holidays) + # Orthodox Easter + self.assertNotIn(date(2020, 4, 16), self.holidays) + self.assertIn(date(2020, 4, 17), self.holidays) + self.assertIn(date(2020, 4, 18), self.holidays) + self.assertIn(date(2020, 4, 19), self.holidays) + self.assertIn(date(2020, 4, 20), self.holidays) + self.assertNotIn(date(2020, 4, 21), self.holidays) diff --git a/test/countries/test_singapore.py b/test/countries/test_singapore.py new file mode 100644 index 000000000..e22628d89 --- /dev/null +++ b/test/countries/test_singapore.py @@ -0,0 +1,93 @@ +# -*- coding: utf-8 -*- + +# python-holidays +# --------------- +# A fast, efficient Python library for generating country, province and state +# specific sets of holidays on the fly. It aims to make determining whether a +# specific date is a holiday as fast and flexible as possible. +# +# Author: ryanss (c) 2014-2017 +# dr-prodigy (c) 2017-2021 +# Website: https://github.com/dr-prodigy/python-holidays +# License: MIT (see LICENSE file) + +import sys +import unittest + +from datetime import date + +import holidays + + +class TestSingapore(unittest.TestCase): + def setUp(self): + self.holidays = holidays.Singapore() + + def test_Singapore(self): + # <= 1968 holidays + self.assertIn(date(1968, 4, 13), self.holidays) + self.assertIn(date(1968, 4, 15), self.holidays) + self.assertIn(date(1968, 12, 26), self.holidays) + # latest polling day + self.assertIn(date(2015, 9, 11), self.holidays) + # SG50 + self.assertIn(date(2015, 8, 7), self.holidays) + # Year with lunar leap month + self.assertIn(date(2015, 8, 7), self.holidays) + # Latest holidays + # Source: https://www.mom.gov.sg/employment-practices/public-holidays + # 2018 + self.assertIn(date(2018, 1, 1), self.holidays) + self.assertIn(date(2018, 2, 16), self.holidays) + self.assertIn(date(2018, 2, 17), self.holidays) + self.assertIn(date(2018, 3, 30), self.holidays) + self.assertIn(date(2018, 5, 1), self.holidays) + self.assertIn(date(2018, 5, 29), self.holidays) + self.assertIn(date(2018, 6, 15), self.holidays) + self.assertIn(date(2018, 8, 9), self.holidays) + self.assertIn(date(2018, 8, 22), self.holidays) + self.assertIn(date(2018, 11, 6), self.holidays) + self.assertIn(date(2018, 12, 25), self.holidays) + # total holidays (11 + 0 falling on a Sunday) + self.assertEqual(len(holidays.Singapore(years=[2018])), 11 + 0) + # 2019 + self.assertIn(date(2019, 1, 1), self.holidays) + self.assertIn(date(2019, 2, 5), self.holidays) + self.assertIn(date(2019, 2, 6), self.holidays) + self.assertIn(date(2019, 4, 19), self.holidays) + self.assertIn(date(2019, 5, 1), self.holidays) + self.assertIn(date(2019, 5, 19), self.holidays) + self.assertIn(date(2019, 6, 5), self.holidays) + self.assertIn(date(2019, 8, 9), self.holidays) + self.assertIn(date(2019, 8, 11), self.holidays) + self.assertIn(date(2019, 10, 27), self.holidays) + self.assertIn(date(2019, 12, 25), self.holidays) + # total holidays (11 + 3 falling on a Sunday) + self.assertEqual(len(holidays.Singapore(years=[2019])), 11 + 3) + # 2020 + self.assertIn(date(2020, 1, 1), self.holidays) + self.assertIn(date(2020, 1, 25), self.holidays) + self.assertIn(date(2020, 1, 26), self.holidays) + self.assertIn(date(2020, 4, 10), self.holidays) + self.assertIn(date(2020, 5, 1), self.holidays) + self.assertIn(date(2020, 5, 7), self.holidays) + self.assertIn(date(2020, 5, 24), self.holidays) + self.assertIn(date(2020, 7, 31), self.holidays) + self.assertIn(date(2020, 8, 9), self.holidays) + self.assertIn(date(2020, 11, 14), self.holidays) + self.assertIn(date(2020, 12, 25), self.holidays) + # total holidays (11 + 3 falling on a Sunday) + self.assertEqual(len(holidays.Singapore(years=[2020])), 11 + 4) + # holidays estimated using lunar calendar + self.assertIn(date(2021, 5, 26), self.holidays) + self.assertIn(date(2021, 11, 4), self.holidays) + # holidays estimated using library hijri-converter + if sys.version_info >= (3, 6): + import importlib.util + + if importlib.util.find_spec("hijri_converter"): + # <= 1968 holidays + self.assertIn(date(1968, 1, 2), self.holidays) + # 2021 + self.assertIn(date(2021, 5, 13), self.holidays) + self.assertIn(date(2021, 7, 20), self.holidays) diff --git a/test/countries/test_slovakia.py b/test/countries/test_slovakia.py new file mode 100644 index 000000000..eb0150133 --- /dev/null +++ b/test/countries/test_slovakia.py @@ -0,0 +1,51 @@ +# -*- coding: utf-8 -*- + +# python-holidays +# --------------- +# A fast, efficient Python library for generating country, province and state +# specific sets of holidays on the fly. It aims to make determining whether a +# specific date is a holiday as fast and flexible as possible. +# +# Author: ryanss (c) 2014-2017 +# dr-prodigy (c) 2017-2021 +# Website: https://github.com/dr-prodigy/python-holidays +# License: MIT (see LICENSE file) + +import unittest +import warnings + +from datetime import date + +import holidays + + +class TestSK(unittest.TestCase): + def setUp(self): + self.holidays = holidays.SK() + + def test_2018(self): + # https://www.officeholidays.com/countries/slovakia/2018.php + self.assertIn(date(2018, 1, 1), self.holidays) + self.assertIn(date(2018, 1, 6), self.holidays) + self.assertIn(date(2018, 3, 30), self.holidays) + self.assertIn(date(2018, 5, 1), self.holidays) + self.assertIn(date(2018, 5, 8), self.holidays) + self.assertIn(date(2018, 4, 2), self.holidays) + self.assertIn(date(2018, 7, 5), self.holidays) + self.assertIn(date(2018, 8, 29), self.holidays) + self.assertIn(date(2018, 9, 1), self.holidays) + self.assertIn(date(2018, 9, 15), self.holidays) + self.assertIn(date(2018, 10, 30), self.holidays) + self.assertIn(date(2018, 11, 1), self.holidays) + self.assertIn(date(2018, 11, 17), self.holidays) + self.assertIn(date(2018, 12, 24), self.holidays) + self.assertIn(date(2018, 12, 25), self.holidays) + self.assertIn(date(2018, 12, 26), self.holidays) + + def test_slovak_deprecated(self): + with warnings.catch_warnings(record=True) as w: + warnings.simplefilter("always") + slovakia = holidays.Slovak() + self.assertIsInstance(slovakia, holidays.Slovakia) + self.assertEqual(1, len(w)) + self.assertTrue(issubclass(w[-1].category, DeprecationWarning)) diff --git a/test/countries/test_slovenia.py b/test/countries/test_slovenia.py new file mode 100644 index 000000000..a6b4e27e4 --- /dev/null +++ b/test/countries/test_slovenia.py @@ -0,0 +1,69 @@ +# -*- coding: utf-8 -*- + +# python-holidays +# --------------- +# A fast, efficient Python library for generating country, province and state +# specific sets of holidays on the fly. It aims to make determining whether a +# specific date is a holiday as fast and flexible as possible. +# +# Author: ryanss (c) 2014-2017 +# dr-prodigy (c) 2017-2021 +# Website: https://github.com/dr-prodigy/python-holidays +# License: MIT (see LICENSE file) + +import unittest + +from datetime import date + +import holidays + + +class TestSI(unittest.TestCase): + def setUp(self): + self.holidays = holidays.SI() + + def test_holidays(self): + """ + Test all expected holiday dates + :return: + """ + # New Year + self.assertIn(date(2017, 1, 1), self.holidays) + self.assertIn(date(2017, 1, 2), self.holidays) + # Prešeren's day + self.assertIn(date(2017, 2, 8), self.holidays) + # Easter monday - 2016 and 2017 + self.assertIn(date(2016, 3, 28), self.holidays) + self.assertIn(date(2017, 4, 17), self.holidays) + # Day of uprising against occupation + self.assertIn(date(2017, 4, 27), self.holidays) + # Labour day + self.assertIn(date(2017, 5, 1), self.holidays) + # Labour day + self.assertIn(date(2017, 5, 2), self.holidays) + # Statehood day + self.assertIn(date(2017, 6, 25), self.holidays) + # Assumption day + self.assertIn(date(2017, 8, 15), self.holidays) + # Reformation day + self.assertIn(date(2017, 10, 31), self.holidays) + # Remembrance day + self.assertIn(date(2017, 11, 1), self.holidays) + # Christmas + self.assertIn(date(2017, 12, 25), self.holidays) + # Day of independence and unity + self.assertIn(date(2017, 12, 26), self.holidays) + + def test_non_holidays(self): + """ + Test dates that should be excluded from holidays list + :return: + """ + # January 2nd was not public holiday between 2012 and 2017 + self.assertNotIn(date(2013, 1, 2), self.holidays) + self.assertNotIn(date(2014, 1, 2), self.holidays) + self.assertNotIn(date(2015, 1, 2), self.holidays) + self.assertNotIn(date(2016, 1, 2), self.holidays) + + def test_missing_years(self): + self.assertNotIn(date(1990, 1, 1), self.holidays) diff --git a/test/countries/test_south_africa.py b/test/countries/test_south_africa.py new file mode 100644 index 000000000..1e1c3828d --- /dev/null +++ b/test/countries/test_south_africa.py @@ -0,0 +1,72 @@ +# -*- coding: utf-8 -*- + +# python-holidays +# --------------- +# A fast, efficient Python library for generating country, province and state +# specific sets of holidays on the fly. It aims to make determining whether a +# specific date is a holiday as fast and flexible as possible. +# +# Author: ryanss (c) 2014-2017 +# dr-prodigy (c) 2017-2021 +# Website: https://github.com/dr-prodigy/python-holidays +# License: MIT (see LICENSE file) + +import unittest + +from datetime import date + +import holidays + + +class TestSouthAfrica(unittest.TestCase): + def setUp(self): + self.holidays = holidays.ZA() + + def test_new_years(self): + self.assertIn("1910-01-01", self.holidays) + self.assertIn("2017-01-01", self.holidays) + self.assertIn("2999-01-01", self.holidays) + self.assertIn("2017-01-02", self.holidays) # sunday + + def test_easter(self): + self.assertIn(date(2017, 4, 14), self.holidays) + self.assertIn(date(2017, 4, 17), self.holidays) + self.assertIn(date(1994, 4, 1), self.holidays) + + def test_static(self): + self.assertIn("2004-08-09", self.holidays) + self.assertIn("2022-12-27", self.holidays) # Christmas (Observed) + + def test_not_holiday(self): + self.assertNotIn("2016-12-28", self.holidays) + self.assertNotIn("2015-03-02", self.holidays) + + def test_onceoff(self): + self.assertIn("1999-12-31", self.holidays) # Y2K + self.assertIn("2008-05-02", self.holidays) # Y2K + self.assertIn("2000-01-02", self.holidays) # Y2K + self.assertNotIn("2017-08-03", self.holidays) + + def test_historic(self): + self.assertIn("1980-05-31", self.holidays) # Union/Republic Day + self.assertNotIn("2018-05-31", self.holidays) + + self.assertIn("1952-12-16", self.holidays) # Day of the Vow + self.assertIn("1988-05-06", self.holidays) # Workers' Day + self.assertIn("1961-07-10", self.holidays) # Family Day + + self.assertIn("1947-08-04", self.holidays) # King's Birthday + self.assertNotIn("1948-08-04", self.holidays) + + self.assertIn("1975-09-01", self.holidays) # Settler's Day + self.assertNotIn("1976-09-01", self.holidays) + + def test_elections(self): + self.assertTrue("1999-06-02" in self.holidays) # Election Day 1999 + self.assertTrue("2004-04-14" in self.holidays) # Election Day 2004 + self.assertTrue("2006-03-01" in self.holidays) # Local Election + self.assertTrue("2009-04-22" in self.holidays) # Election Day 2008 + self.assertTrue("2011-05-18" in self.holidays) # Election Day 2011 + self.assertTrue("2014-05-07" in self.holidays) # Election Day 2014 + self.assertTrue("2016-08-03" in self.holidays) # Election Day 2016 + self.assertTrue("2019-05-08" in self.holidays) # Election Day 2019 diff --git a/test/countries/test_spain.py b/test/countries/test_spain.py new file mode 100644 index 000000000..7e8baaa5f --- /dev/null +++ b/test/countries/test_spain.py @@ -0,0 +1,146 @@ +# -*- coding: utf-8 -*- + +# python-holidays +# --------------- +# A fast, efficient Python library for generating country, province and state +# specific sets of holidays on the fly. It aims to make determining whether a +# specific date is a holiday as fast and flexible as possible. +# +# Author: ryanss (c) 2014-2017 +# dr-prodigy (c) 2017-2021 +# Website: https://github.com/dr-prodigy/python-holidays +# License: MIT (see LICENSE file) + +import unittest +from itertools import product + +from datetime import date + +import holidays + + +class TestES(unittest.TestCase): + def setUp(self): + self.holidays = holidays.ES(observed=False) + self.holidays_observed = holidays.ES() + self.prov_holidays = { + prov: holidays.ES(observed=False, prov=prov) + for prov in holidays.ES.PROVINCES + } + + def test_fixed_holidays(self): + fixed_days_whole_country = ( + (1, 1), + (1, 6), + (5, 1), + (8, 15), + (10, 12), + (11, 1), + (12, 6), + (12, 8), + (12, 25), + ) + for y, (m, d) in product(range(1950, 2050), fixed_days_whole_country): + self.assertIn(date(y, m, d), self.holidays) + + def test_fixed_holidays_observed(self): + fixed_days_whole_country = ( + (1, 1), + (1, 6), + (5, 1), + (8, 15), + (10, 12), + (11, 2), + (12, 7), + (12, 8), + (12, 25), + ) + for (m, d) in fixed_days_whole_country: + self.assertIn(date(2020, m, d), self.holidays_observed) + + def test_variable_days_in_2016(self): + for prov, prov_holidays in self.prov_holidays.items(): + self.assertEqual( + date(2016, 3, 24) in prov_holidays, prov not in ["CT", "VC"] + ) + self.assertEqual( + date(2016, 3, 25) in prov_holidays, prov not in ["CT", "VC"] + ) + self.assertEqual( + date(2016, 3, 28) in prov_holidays, + prov in ["CT", "PV", "NC", "VC", "IB", "CM"], + ) + + def test_province_specific_days(self): + province_days = { + (2, 28): ["AN"], + (3, 1): ["IB"], + (4, 23): ["AR", "CL"], + (5, 30): ["CN"], + (5, 31): ["CM"], + (5, 2): ["MD"], + (6, 9): ["MC", "RI"], + (7, 25): ["GA"], + (7, 28): ["CB"], + (9, 8): ["AS", "EX"], + (9, 11): ["CT"], + (9, 27): ["NC"], + (10, 9): ["VC"], + (10, 25): ["PV"], + } + for prov, prov_holidays in self.prov_holidays.items(): + for year in range(2010, 2025): + self.assertEqual( + date(year, 12, 26) in prov_holidays, prov in ["CT", "IB"] + ) + if year < 2015: + self.assertEqual( + date(year, 3, 19) in prov_holidays, + prov + in [ + "AR", + "CL", + "CM", + "EX", + "GA", + "MD", + "ML", + "MC", + "NC", + "PV", + "VC", + ], + ) + elif year == 2015: + self.assertEqual( + date(year, 3, 19) in prov_holidays, + prov in ["CM", "MD", "ML", "MC", "NC", "PV", "VC"], + ) + elif year == 2016: + self.assertEqual( + date(year, 3, 19) in prov_holidays, + prov in ["ML", "MC", "PV", "VC"], + ) + elif year == 2017: + self.assertEqual( + date(year, 3, 19) in prov_holidays, prov in ["PV"] + ) + elif 2018 <= year <= 2019: + self.assertEqual( + date(year, 3, 19) in prov_holidays, + prov in ["GA", "MC", "NC", "PV", "VC"], + ) + elif year == 2020: + self.assertEqual( + date(year, 3, 19) in prov_holidays, + prov in ["CM", "GA", "MC", "NC", "PV", "VC"], + ) + self.assertEqual( + date(year, 6, 24) in prov_holidays, + prov in ["CT", "GA", "VC"], + ) + for fest_day, fest_prov in province_days.items(): + self.assertEqual( + date(year, *fest_day) in prov_holidays, + prov in fest_prov, + ) diff --git a/test/countries/test_sweden.py b/test/countries/test_sweden.py new file mode 100644 index 000000000..3f7874c69 --- /dev/null +++ b/test/countries/test_sweden.py @@ -0,0 +1,120 @@ +# -*- coding: utf-8 -*- + +# python-holidays +# --------------- +# A fast, efficient Python library for generating country, province and state +# specific sets of holidays on the fly. It aims to make determining whether a +# specific date is a holiday as fast and flexible as possible. +# +# Author: ryanss (c) 2014-2017 +# dr-prodigy (c) 2017-2021 +# Website: https://github.com/dr-prodigy/python-holidays +# License: MIT (see LICENSE file) + +import unittest + + +import holidays + + +class TestSweden(unittest.TestCase): + def setUp(self): + self.holidays_without_sundays = holidays.Sweden(include_sundays=False) + self.holidays_with_sundays = holidays.Sweden() + + def test_new_years(self): + self.assertIn("1900-01-01", self.holidays_without_sundays) + self.assertIn("2017-01-01", self.holidays_without_sundays) + self.assertIn("2999-01-01", self.holidays_without_sundays) + + def test_easter(self): + self.assertNotIn("2000-04-20", self.holidays_without_sundays) + self.assertIn("2000-04-21", self.holidays_without_sundays) + self.assertIn("2000-04-23", self.holidays_without_sundays) + self.assertIn("2000-04-24", self.holidays_without_sundays) + + self.assertNotIn("2010-04-01", self.holidays_without_sundays) + self.assertIn("2010-04-02", self.holidays_without_sundays) + self.assertIn("2010-04-04", self.holidays_without_sundays) + self.assertIn("2010-04-05", self.holidays_without_sundays) + + self.assertNotIn("2021-04-01", self.holidays_without_sundays) + self.assertIn("2021-04-02", self.holidays_without_sundays) + self.assertIn("2021-04-04", self.holidays_without_sundays) + self.assertIn("2021-04-05", self.holidays_without_sundays) + + self.assertNotIn("2024-03-28", self.holidays_without_sundays) + self.assertIn("2024-03-29", self.holidays_without_sundays) + self.assertIn("2024-03-31", self.holidays_without_sundays) + self.assertIn("2024-04-01", self.holidays_without_sundays) + + def test_workers_day(self): + self.assertNotIn("1800-05-01", self.holidays_without_sundays) + self.assertNotIn("1879-05-01", self.holidays_without_sundays) + self.assertIn("1939-05-01", self.holidays_without_sundays) + self.assertIn("2017-05-01", self.holidays_without_sundays) + self.assertIn("2999-05-01", self.holidays_without_sundays) + + def test_constitution_day(self): + self.assertNotIn("1900-06-06", self.holidays_without_sundays) + self.assertNotIn("2004-06-06", self.holidays_without_sundays) + self.assertIn("2005-06-06", self.holidays_without_sundays) + self.assertIn("2017-06-06", self.holidays_without_sundays) + self.assertIn("2999-06-06", self.holidays_without_sundays) + + def test_pentecost(self): + self.assertIn("2000-06-11", self.holidays_without_sundays) + self.assertIn("2000-06-12", self.holidays_without_sundays) + + self.assertIn("2010-05-23", self.holidays_without_sundays) + self.assertNotIn("2010-05-24", self.holidays_without_sundays) + + self.assertIn("2021-05-23", self.holidays_without_sundays) + self.assertNotIn("2021-05-24", self.holidays_without_sundays) + + self.assertIn("2003-06-09", self.holidays_without_sundays) + + self.assertIn("2024-05-19", self.holidays_without_sundays) + self.assertNotIn("2024-05-20", self.holidays_without_sundays) + + def test_christmas(self): + self.assertIn("1901-12-25", self.holidays_without_sundays) + self.assertIn("1901-12-26", self.holidays_without_sundays) + + self.assertIn("2016-12-25", self.holidays_without_sundays) + self.assertIn("2016-12-26", self.holidays_without_sundays) + + self.assertIn("2500-12-25", self.holidays_without_sundays) + self.assertIn("2500-12-26", self.holidays_without_sundays) + + def test_sundays(self): + """ + Sundays are considered holidays in Sweden + :return: + """ + self.assertIn("1989-12-31", self.holidays_with_sundays) + self.assertIn("2017-02-05", self.holidays_with_sundays) + self.assertIn("2017-02-12", self.holidays_with_sundays) + self.assertIn("2032-02-29", self.holidays_with_sundays) + + def test_not_holiday(self): + """ + Note: Sundays in Sweden are considered holidays, + so make sure none of these are actually Sundays + :return: + """ + self.assertNotIn("2017-02-06", self.holidays_without_sundays) + self.assertNotIn("2017-02-07", self.holidays_without_sundays) + self.assertNotIn("2017-02-08", self.holidays_without_sundays) + self.assertNotIn("2017-02-09", self.holidays_without_sundays) + self.assertNotIn("2017-02-10", self.holidays_without_sundays) + self.assertNotIn("2016-12-27", self.holidays_without_sundays) + self.assertNotIn("2016-12-28", self.holidays_without_sundays) + + self.assertNotIn("2017-02-06", self.holidays_with_sundays) + self.assertNotIn("2017-02-07", self.holidays_with_sundays) + self.assertNotIn("2017-02-08", self.holidays_with_sundays) + self.assertNotIn("2017-02-09", self.holidays_with_sundays) + self.assertNotIn("2017-02-10", self.holidays_with_sundays) + self.assertNotIn("2016-12-27", self.holidays_with_sundays) + self.assertNotIn("2016-12-28", self.holidays_with_sundays) diff --git a/test/countries/test_switzerland.py b/test/countries/test_switzerland.py new file mode 100644 index 000000000..9c8c5f0a5 --- /dev/null +++ b/test/countries/test_switzerland.py @@ -0,0 +1,503 @@ +# -*- coding: utf-8 -*- + +# python-holidays +# --------------- +# A fast, efficient Python library for generating country, province and state +# specific sets of holidays on the fly. It aims to make determining whether a +# specific date is a holiday as fast and flexible as possible. +# +# Author: ryanss (c) 2014-2017 +# dr-prodigy (c) 2017-2021 +# Website: https://github.com/dr-prodigy/python-holidays +# License: MIT (see LICENSE file) + +import unittest +from itertools import product + +from datetime import date + +import holidays + + +class TestSwitzerland(unittest.TestCase): + def setUp(self): + self.holidays = holidays.CH() + self.prov_hols = dict( + (prov, holidays.CH(prov=prov)) for prov in holidays.CH.PROVINCES + ) + + def test_all_holidays_present(self): + ch_2018 = sum( + holidays.CH(years=[2018], prov=p) for p in holidays.CH.PROVINCES + ) + in_2018 = sum((ch_2018.get_list(key) for key in ch_2018), []) + all_ch = [ + "Neujahrestag", + "Berchtoldstag", + "Heilige Drei Könige", + "Jahrestag der Ausrufung der Republik", + "Josefstag", + "Näfelser Fahrt", + "Karfreitag", + "Ostern", + "Ostermontag", + "Tag der Arbeit", + "Auffahrt", + "Pfingsten", + "Pfingstmontag", + "Fronleichnam", + "Fest der Unabhängigkeit", + "Peter und Paul", + "Nationalfeiertag", + "Mariä Himmelfahrt", + "Lundi du Jeûne", + "Bruder Klaus", + "Allerheiligen", + "Mariä Empfängnis", + "Escalade de Genève", + "Weihnachten", + "Stephanstag", + "Wiederherstellung der Republik", + ] + + for holiday in all_ch: + self.assertTrue(holiday in all_ch, "missing: {}".format(holiday)) + for holiday in in_2018: + self.assertTrue(holiday in in_2018, "extra: {}".format(holiday)) + + def test_fixed_holidays(self): + fixed_days_whole_country = ( + (1, 1), # Neujahrestag + (8, 1), # Nationalfeiertag + (12, 25), # Weihnachten + ) + for y, (m, d) in product(range(1291, 2050), fixed_days_whole_country): + self.assertTrue(date(y, m, d) in self.holidays) + + def test_berchtoldstag(self): + provinces_that_have = { + "AG", + "BE", + "FR", + "GL", + "GR", + "JU", + "LU", + "NE", + "OW", + "SH", + "SO", + "TG", + "VD", + "ZG", + "ZH", + } + provinces_that_dont = set(holidays.CH.PROVINCES) - provinces_that_have + + for province, year in product(provinces_that_have, range(1970, 2050)): + self.assertTrue(date(year, 1, 2) in self.prov_hols[province]) + for province, year in product(provinces_that_dont, range(1970, 2050)): + self.assertTrue(date(year, 1, 2) not in self.prov_hols[province]) + + def test_heilige_drei_koenige(self): + provinces_that_have = {"SZ", "TI", "UR"} + provinces_that_dont = set(holidays.CH.PROVINCES) - provinces_that_have + + for province, year in product(provinces_that_have, range(1970, 2050)): + self.assertTrue(date(year, 1, 6) in self.prov_hols[province]) + for province, year in product(provinces_that_dont, range(1970, 2050)): + self.assertTrue(date(year, 1, 6) not in self.prov_hols[province]) + + def test_jahrestag_der_ausrufung_der_republik(self): + provinces_that_have = {"NE"} + provinces_that_dont = set(holidays.CH.PROVINCES) - provinces_that_have + + for province, year in product(provinces_that_have, range(1970, 2050)): + self.assertTrue(date(year, 3, 1) in self.prov_hols[province]) + for province, year in product(provinces_that_dont, range(1970, 2050)): + self.assertTrue(date(year, 3, 1) not in self.prov_hols[province]) + + def test_josefstag(self): + provinces_that_have = {"NW", "SZ", "TI", "UR", "VS"} + provinces_that_dont = set(holidays.CH.PROVINCES) - provinces_that_have + + for province, year in product(provinces_that_have, range(1970, 2050)): + self.assertTrue(date(year, 3, 19) in self.prov_hols[province]) + for province, year in product(provinces_that_dont, range(1970, 2050)): + self.assertTrue(date(year, 3, 19) not in self.prov_hols[province]) + + def test_naefelser_fahrt(self): + known_good = [ + (2018, 4, 5), + (2019, 4, 4), + (2020, 4, 2), + (2021, 4, 8), + (2022, 4, 7), + (2023, 4, 13), + (2024, 4, 4), + (2025, 4, 3), + (2026, 4, 9), + (2027, 4, 1), + (2028, 4, 6), + (2029, 4, 5), + (2030, 4, 4), + (2031, 4, 3), + (2032, 4, 1), + (2033, 4, 7), + (2034, 4, 13), + (2035, 4, 5), + ] + provinces_that_have = {"GL"} + provinces_that_dont = set(holidays.CH.PROVINCES) - provinces_that_have + + for province, (y, m, d) in product(provinces_that_have, known_good): + self.assertTrue(date(y, m, d) in self.prov_hols[province]) + for province, (y, m, d) in product(provinces_that_dont, known_good): + self.assertTrue(date(y, m, d) not in self.prov_hols[province]) + + def test_karfreitag(self): + known_good = [ + (2018, 3, 30), + (2019, 4, 19), + (2020, 4, 10), + (2021, 4, 2), + (2022, 4, 15), + (2023, 4, 7), + (2024, 3, 29), + (2025, 4, 18), + (2026, 4, 3), + (2027, 3, 26), + (2028, 4, 14), + (2029, 3, 30), + (2030, 4, 19), + (2031, 4, 11), + (2032, 3, 26), + (2033, 4, 15), + (2034, 4, 7), + (2035, 3, 23), + ] + provinces_that_dont = {"VS"} + provinces_that_have = set(holidays.CH.PROVINCES) - provinces_that_dont + for province, (y, m, d) in product(provinces_that_have, known_good): + self.assertTrue(date(y, m, d) in self.prov_hols[province]) + for province, (y, m, d) in product(provinces_that_dont, known_good): + self.assertTrue(date(y, m, d) not in self.prov_hols[province]) + + def test_ostern(self): + known_good = [ + (2018, 4, 1), + (2019, 4, 21), + (2020, 4, 12), + (2021, 4, 4), + (2022, 4, 17), + (2023, 4, 9), + (2024, 3, 31), + (2025, 4, 20), + (2026, 4, 5), + (2027, 3, 28), + (2028, 4, 16), + (2029, 4, 1), + (2030, 4, 21), + (2031, 4, 13), + (2032, 3, 28), + (2033, 4, 17), + (2034, 4, 9), + (2035, 3, 25), + ] + + for province, (y, m, d) in product(holidays.CH.PROVINCES, known_good): + self.assertTrue(date(y, m, d) in self.prov_hols[province]) + + def test_ostermontag(self): + known_good = [ + (2018, 4, 2), + (2019, 4, 22), + (2020, 4, 13), + (2021, 4, 5), + (2022, 4, 18), + (2023, 4, 10), + (2024, 4, 1), + (2025, 4, 21), + (2026, 4, 6), + (2027, 3, 29), + (2028, 4, 17), + (2029, 4, 2), + (2030, 4, 22), + (2031, 4, 14), + (2032, 3, 29), + (2033, 4, 18), + (2034, 4, 10), + (2035, 3, 26), + ] + provinces_that_dont = {"VS"} + provinces_that_have = set(holidays.CH.PROVINCES) - provinces_that_dont + for province, (y, m, d) in product(provinces_that_have, known_good): + self.assertTrue(date(y, m, d) in self.prov_hols[province]) + for province, (y, m, d) in product(provinces_that_dont, known_good): + self.assertTrue(date(y, m, d) not in self.prov_hols[province]) + + def test_auffahrt(self): + known_good = [ + (2018, 5, 10), + (2019, 5, 30), + (2020, 5, 21), + (2021, 5, 13), + (2022, 5, 26), + (2023, 5, 18), + (2024, 5, 9), + (2025, 5, 29), + (2026, 5, 14), + (2027, 5, 6), + (2028, 5, 25), + (2029, 5, 10), + (2030, 5, 30), + (2031, 5, 22), + (2032, 5, 6), + (2033, 5, 26), + (2034, 5, 18), + (2035, 5, 3), + ] + + for province, (y, m, d) in product(holidays.CH.PROVINCES, known_good): + self.assertTrue(date(y, m, d) in self.prov_hols[province]) + + def test_pfingsten(self): + known_good = [ + (2018, 5, 20), + (2019, 6, 9), + (2020, 5, 31), + (2021, 5, 23), + (2022, 6, 5), + (2023, 5, 28), + (2024, 5, 19), + (2025, 6, 8), + (2026, 5, 24), + (2027, 5, 16), + (2028, 6, 4), + (2029, 5, 20), + (2030, 6, 9), + (2031, 6, 1), + (2032, 5, 16), + (2033, 6, 5), + (2034, 5, 28), + (2035, 5, 13), + ] + + for province, (y, m, d) in product(holidays.CH.PROVINCES, known_good): + self.assertTrue(date(y, m, d) in self.prov_hols[province]) + + def test_pfingstmontag(self): + known_good = [ + (2018, 5, 21), + (2019, 6, 10), + (2020, 6, 1), + (2021, 5, 24), + (2022, 6, 6), + (2023, 5, 29), + (2024, 5, 20), + (2025, 6, 9), + (2026, 5, 25), + (2027, 5, 17), + (2028, 6, 5), + (2029, 5, 21), + (2030, 6, 10), + (2031, 6, 2), + (2032, 5, 17), + (2033, 6, 6), + (2034, 5, 29), + (2035, 5, 14), + ] + + for province, (y, m, d) in product(holidays.CH.PROVINCES, known_good): + self.assertTrue(date(y, m, d) in self.prov_hols[province]) + + def test_fronleichnam(self): + known_good = [ + (2014, 6, 19), + (2015, 6, 4), + (2016, 5, 26), + (2017, 6, 15), + (2018, 5, 31), + (2019, 6, 20), + (2020, 6, 11), + (2021, 6, 3), + (2022, 6, 16), + (2023, 6, 8), + (2024, 5, 30), + ] + provinces_that_have = { + "AI", + "JU", + "LU", + "NW", + "OW", + "SZ", + "TI", + "UR", + "VS", + "ZG", + } + provinces_that_dont = set(holidays.CH.PROVINCES) - provinces_that_have + + for province, (y, m, d) in product(provinces_that_have, known_good): + self.assertTrue(date(y, m, d) in self.prov_hols[province]) + for province, (y, m, d) in product(provinces_that_dont, known_good): + self.assertTrue(date(y, m, d) not in self.prov_hols[province]) + + def test_fest_der_unabhaengikeit(self): + provinces_that_have = {"JU"} + provinces_that_dont = set(holidays.CH.PROVINCES) - provinces_that_have + + for province, year in product(provinces_that_have, range(1970, 2050)): + self.assertTrue(date(year, 6, 23) in self.prov_hols[province]) + # 2011 is "Fronleichnam" on the same date, we don't test this year + for province, year in product(provinces_that_dont, range(1970, 2010)): + self.assertTrue(date(year, 6, 23) not in self.prov_hols[province]) + for province, year in product(provinces_that_dont, range(2012, 2050)): + self.assertTrue(date(year, 6, 23) not in self.prov_hols[province]) + + def test_peter_und_paul(self): + provinces_that_have = {"TI"} + provinces_that_dont = set(holidays.CH.PROVINCES) - provinces_that_have + + for province, year in product(provinces_that_have, range(1970, 2050)): + self.assertTrue(date(year, 6, 29) in self.prov_hols[province]) + for province, year in product(provinces_that_dont, range(1970, 2050)): + self.assertTrue(date(year, 6, 29) not in self.prov_hols[province]) + + def test_mariae_himmelfahrt(self): + provinces_that_have = { + "AI", + "JU", + "LU", + "NW", + "OW", + "SZ", + "TI", + "UR", + "VS", + "ZG", + } + provinces_that_dont = set(holidays.CH.PROVINCES) - provinces_that_have + + for province, year in product(provinces_that_have, range(1970, 2050)): + self.assertTrue(date(year, 8, 15) in self.prov_hols[province]) + for province, year in product(provinces_that_dont, range(1970, 2050)): + self.assertTrue(date(year, 8, 15) not in self.prov_hols[province]) + + def test_lundi_du_jeune(self): + known_good = [ + (2014, 9, 22), + (2015, 9, 21), + (2016, 9, 19), + (2017, 9, 18), + (2018, 9, 17), + (2019, 9, 16), + (2020, 9, 21), + (2021, 9, 20), + (2022, 9, 19), + (2023, 9, 18), + (2024, 9, 16), + ] + provinces_that_have = {"VD"} + provinces_that_dont = set(holidays.CH.PROVINCES) - provinces_that_have + + for province, (y, m, d) in product(provinces_that_have, known_good): + self.assertTrue(date(y, m, d) in self.prov_hols[province]) + for province, (y, m, d) in product(provinces_that_dont, known_good): + self.assertTrue(date(y, m, d) not in self.prov_hols[province]) + + def test_bruder_chlaus(self): + provinces_that_have = {"OW"} + provinces_that_dont = set(holidays.CH.PROVINCES) - provinces_that_have + + for province, year in product(provinces_that_have, range(1970, 2050)): + self.assertTrue(date(year, 9, 25) in self.prov_hols[province]) + for province, year in product(provinces_that_dont, range(1970, 2050)): + self.assertTrue(date(year, 9, 25) not in self.prov_hols[province]) + + def test_allerheiligen(self): + provinces_that_have = { + "AI", + "GL", + "JU", + "LU", + "NW", + "OW", + "SG", + "SZ", + "TI", + "UR", + "VS", + "ZG", + } + provinces_that_dont = set(holidays.CH.PROVINCES) - provinces_that_have + + for province, year in product(provinces_that_have, range(1970, 2050)): + self.assertTrue(date(year, 11, 1) in self.prov_hols[province]) + for province, year in product(provinces_that_dont, range(1970, 2050)): + self.assertTrue(date(year, 11, 1) not in self.prov_hols[province]) + + def test_jeune_genevois(self): + known_good = [ + (2014, 9, 11), + (2015, 9, 10), + (2016, 9, 8), + (2017, 9, 7), + (2018, 9, 6), + (2019, 9, 5), + (2020, 9, 10), + (2021, 9, 9), + (2022, 9, 8), + (2023, 9, 7), + (2024, 9, 5), + (2025, 9, 11), + ] + provinces_that_have = {"GE"} + provinces_that_dont = set(holidays.CH.PROVINCES) - provinces_that_have + + for province, (y, m, d) in product(provinces_that_have, known_good): + self.assertTrue(date(y, m, d) in self.prov_hols[province]) + for province, (y, m, d) in product(provinces_that_dont, known_good): + self.assertTrue(date(y, m, d) not in self.prov_hols[province]) + + def test_stephanstag(self): + provinces_that_have = { + "AG", + "AR", + "AI", + "BL", + "BS", + "BE", + "FR", + "GL", + "GR", + "LU", + "NE", + "NW", + "OW", + "SG", + "SH", + "SZ", + "SO", + "TG", + "TI", + "UR", + "ZG", + "ZH", + } + provinces_that_dont = set(holidays.CH.PROVINCES) - provinces_that_have + + for province, year in product(provinces_that_have, range(1970, 2050)): + self.assertTrue(date(year, 12, 26) in self.prov_hols[province]) + for province, year in product(provinces_that_dont, range(1970, 2050)): + self.assertTrue(date(year, 12, 26) not in self.prov_hols[province]) + + def test_wiedererstellung_der_republik(self): + provinces_that_have = {"GE"} + provinces_that_dont = set(holidays.CH.PROVINCES) - provinces_that_have + + for province, year in product(provinces_that_have, range(1970, 2050)): + self.assertTrue(date(year, 12, 31) in self.prov_hols[province]) + for province, year in product(provinces_that_dont, range(1970, 2050)): + self.assertTrue(date(year, 12, 31) not in self.prov_hols[province]) diff --git a/test/countries/test_turkey.py b/test/countries/test_turkey.py new file mode 100644 index 000000000..28aed1f2e --- /dev/null +++ b/test/countries/test_turkey.py @@ -0,0 +1,49 @@ +# -*- coding: utf-8 -*- + +# python-holidays +# --------------- +# A fast, efficient Python library for generating country, province and state +# specific sets of holidays on the fly. It aims to make determining whether a +# specific date is a holiday as fast and flexible as possible. +# +# Author: ryanss (c) 2014-2017 +# dr-prodigy (c) 2017-2021 +# Website: https://github.com/dr-prodigy/python-holidays +# License: MIT (see LICENSE file) + +import sys +import unittest + +from datetime import date + +import holidays + + +class TestTurkey(unittest.TestCase): + def setUp(self): + self.holidays = holidays.TR() + + def test_2019(self): + self.assertIn(date(2019, 1, 1), self.holidays) + self.assertIn(date(2019, 4, 23), self.holidays) + self.assertIn(date(2019, 5, 1), self.holidays) + self.assertIn(date(2019, 5, 19), self.holidays) + self.assertIn(date(2019, 7, 15), self.holidays) + self.assertIn(date(2019, 8, 30), self.holidays) + self.assertIn(date(2019, 10, 29), self.holidays) + + def test_hijri_based(self): + if sys.version_info >= (3, 6): + import importlib.util + + if importlib.util.find_spec("hijri_converter"): + self.holidays = holidays.TR(years=[2020]) + # Ramadan Feast + self.assertIn(date(2020, 5, 24), self.holidays) + self.assertIn(date(2020, 5, 25), self.holidays) + self.assertIn(date(2020, 5, 26), self.holidays) + # Sacrifice Feast + self.assertIn(date(2020, 7, 31), self.holidays) + self.assertIn(date(2020, 8, 1), self.holidays) + self.assertIn(date(2020, 8, 2), self.holidays) + self.assertIn(date(2020, 8, 3), self.holidays) diff --git a/test/countries/test_ukraine.py b/test/countries/test_ukraine.py new file mode 100644 index 000000000..3ac6d169b --- /dev/null +++ b/test/countries/test_ukraine.py @@ -0,0 +1,51 @@ +# -*- coding: utf-8 -*- + +# python-holidays +# --------------- +# A fast, efficient Python library for generating country, province and state +# specific sets of holidays on the fly. It aims to make determining whether a +# specific date is a holiday as fast and flexible as possible. +# +# Author: ryanss (c) 2014-2017 +# dr-prodigy (c) 2017-2021 +# Website: https://github.com/dr-prodigy/python-holidays +# License: MIT (see LICENSE file) + +import unittest + +from datetime import date + +import holidays + + +class TestUkraine(unittest.TestCase): + def setUp(self): + self.holidays = holidays.UA() + + def test_before_1918(self): + self.assertNotIn(date(1917, 12, 31), self.holidays) + + def test_2018(self): + # http://www.buhoblik.org.ua/kadry-zarplata/vremya/1676-1676-kalendar.html + self.assertIn(date(2018, 1, 1), self.holidays) + self.assertIn(date(2018, 1, 7), self.holidays) + self.assertIn(date(2018, 12, 25), self.holidays) + self.assertIn(date(2018, 4, 8), self.holidays) + self.assertIn(date(2018, 5, 27), self.holidays) + self.assertIn(date(2018, 5, 9), self.holidays) + self.assertIn(date(2018, 6, 28), self.holidays) + self.assertIn(date(2018, 8, 24), self.holidays) + self.assertIn(date(2018, 10, 14), self.holidays) + + def test_old_holidays(self): + self.assertIn(date(2018, 5, 1), self.holidays) + self.assertIn(date(2016, 5, 2), self.holidays) + self.assertIn(date(1991, 7, 16), self.holidays) + self.assertIn(date(1950, 1, 22), self.holidays) + self.assertIn(date(1999, 11, 7), self.holidays) + self.assertIn(date(1999, 11, 8), self.holidays) + self.assertIn(date(1945, 5, 9), self.holidays) + self.assertIn(date(1945, 9, 3), self.holidays) + self.assertIn(date(1981, 10, 7), self.holidays) + self.assertIn(date(1937, 12, 5), self.holidays) + self.assertIn(date(1918, 3, 18), self.holidays) diff --git a/test/countries/test_united_arab_emirates.py b/test/countries/test_united_arab_emirates.py new file mode 100644 index 000000000..202ad057f --- /dev/null +++ b/test/countries/test_united_arab_emirates.py @@ -0,0 +1,57 @@ +# -*- coding: utf-8 -*- + +# python-holidays +# --------------- +# A fast, efficient Python library for generating country, province and state +# specific sets of holidays on the fly. It aims to make determining whether a +# specific date is a holiday as fast and flexible as possible. +# +# Author: ryanss (c) 2014-2017 +# dr-prodigy (c) 2017-2021 +# Website: https://github.com/dr-prodigy/python-holidays +# License: MIT (see LICENSE file) + +import sys +import unittest + +from datetime import date + +import holidays + + +class UnitedArabEmirates(unittest.TestCase): + def setUp(self): + self.holidays = holidays.AE() + + def test_2020(self): + self.assertIn(date(2020, 1, 1), self.holidays) + self.assertIn(date(2020, 12, 1), self.holidays) + self.assertIn(date(2020, 12, 2), self.holidays) + self.assertIn(date(2020, 12, 3), self.holidays) + + def test_commemoration_day_since_2015(self): + # Before 2009 Jan 25th wasn't celebrated + self.holidays = holidays.AE(years=[2015]) + self.assertIn(date(2015, 11, 30), self.holidays) + + def test_hijri_based(self): + if sys.version_info >= (3, 6): + import importlib.util + + if importlib.util.find_spec("hijri_converter"): + self.holidays = holidays.AE(years=[2020]) + # Eid Al-Fitr + self.assertIn(date(2020, 5, 24), self.holidays) + self.assertIn(date(2020, 5, 25), self.holidays) + self.assertIn(date(2020, 5, 26), self.holidays) + # Arafat Day & Eid Al-Adha + self.assertIn(date(2020, 7, 30), self.holidays) + self.assertIn(date(2020, 7, 31), self.holidays) + self.assertIn(date(2020, 8, 1), self.holidays) + self.assertIn(date(2020, 8, 2), self.holidays) + # Islamic New Year + self.assertIn(date(2020, 8, 23), self.holidays) + # Leilat Al-Miraj 2018 + self.assertIn(date(2018, 4, 13), self.holidays) + # Prophet's Birthday 2018 + self.assertIn(date(2018, 11, 19), self.holidays) diff --git a/test/countries/test_united_kingdom.py b/test/countries/test_united_kingdom.py new file mode 100644 index 000000000..906292f01 --- /dev/null +++ b/test/countries/test_united_kingdom.py @@ -0,0 +1,246 @@ +# -*- coding: utf-8 -*- + +# python-holidays +# --------------- +# A fast, efficient Python library for generating country, province and state +# specific sets of holidays on the fly. It aims to make determining whether a +# specific date is a holiday as fast and flexible as possible. +# +# Author: ryanss (c) 2014-2017 +# dr-prodigy (c) 2017-2021 +# Website: https://github.com/dr-prodigy/python-holidays +# License: MIT (see LICENSE file) + +import unittest + +from datetime import date +from dateutil.relativedelta import relativedelta + +import holidays + + +class TestUK(unittest.TestCase): + def setUp(self): + self.holidays = holidays.England() + self.holidays = holidays.Wales() + self.holidays = holidays.Scotland() + self.holidays = holidays.IsleOfMan() + self.holidays = holidays.NorthernIreland() + self.holidays = holidays.UK() + + def test_new_years(self): + for year in range(1974, 2100): + dt = date(year, 1, 1) + self.assertIn(dt, self.holidays) + if year == 2000: + self.assertIn(dt + relativedelta(days=-1), self.holidays) + else: + self.assertNotIn(dt + relativedelta(days=-1), self.holidays) + + def test_good_friday(self): + 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.assertIn(dt, self.holidays) + self.assertNotIn(dt + relativedelta(days=-1), self.holidays) + self.assertNotIn(dt + relativedelta(days=+1), self.holidays) + + def test_easter_monday(self): + for dt in [ + date(1900, 4, 16), + date(1901, 4, 8), + date(1902, 3, 31), + date(1999, 4, 5), + date(2000, 4, 24), + date(2010, 4, 5), + date(2018, 4, 2), + date(2019, 4, 22), + date(2020, 4, 13), + ]: + self.assertIn(dt, self.holidays) + self.assertNotIn(dt + relativedelta(days=-1), self.holidays) + self.assertNotIn(dt + relativedelta(days=+1), self.holidays) + + def test_royal_weddings(self): + for dt in [date(1981, 7, 29), date(2011, 4, 29)]: + self.assertIn(dt, self.holidays) + self.assertNotIn(dt + relativedelta(years=-1), self.holidays) + self.assertNotIn(dt + relativedelta(years=+1), self.holidays) + + def test_queens_jubilees(self): + for dt in [ + date(1977, 6, 7), + date(2002, 6, 3), + date(2012, 6, 5), + date(2022, 6, 3), + ]: + self.assertIn(dt, self.holidays) + self.assertNotIn(dt + relativedelta(years=-1), self.holidays) + self.assertNotIn(dt + relativedelta(years=+1), self.holidays) + + def test_may_day(self): + for dt in [ + date(1978, 5, 1), + date(1979, 5, 7), + date(1980, 5, 5), + date(1999, 5, 3), + date(2000, 5, 1), + date(2010, 5, 3), + date(2018, 5, 7), + date(2019, 5, 6), + date(2020, 5, 8), + ]: + self.assertIn(dt, self.holidays) + self.assertNotIn(dt + relativedelta(days=-1), self.holidays) + self.assertNotIn(dt + relativedelta(days=+1), self.holidays) + self.assertNotIn(date(2020, 5, 4), self.holidays) + + def test_spring_bank_holiday(self): + for dt in [ + date(1978, 5, 29), + date(1979, 5, 28), + date(1980, 5, 26), + date(1999, 5, 31), + date(2000, 5, 29), + date(2010, 5, 31), + date(2018, 5, 28), + date(2019, 5, 27), + date(2020, 5, 25), + ]: + self.assertIn(dt, self.holidays) + self.assertNotIn(dt + relativedelta(days=-1), self.holidays) + self.assertNotIn(dt + relativedelta(days=+1), self.holidays) + + def test_christmas_day(self): + self.holidays.observed = False + for year in range(1900, 2100): + dt = date(year, 12, 25) + self.assertIn(dt, self.holidays) + self.assertNotIn(dt + relativedelta(days=-1), self.holidays) + self.assertNotIn(date(2010, 12, 24), self.holidays) + self.assertNotEqual( + self.holidays[date(2011, 12, 26)], "Christmas Day (Observed)" + ) + self.holidays.observed = True + self.assertEqual( + self.holidays[date(2011, 12, 27)], "Christmas Day (Observed)" + ) + for year, day in enumerate( + [ + 25, + 25, + 25, + 27, + 27, # 2001-05 + 25, + 25, + 25, + 25, + 27, # 2006-10 + 27, + 25, + 25, + 25, + 25, # 2011-15 + 27, + 25, + 25, + 25, + 25, + 25, + ], # 2016-21 + 2001, + ): + dt = date(year, 12, day) + self.assertIn(dt, self.holidays, dt) + self.assertEqual(self.holidays[dt][:9], "Christmas") + + def test_boxing_day(self): + self.holidays.observed = False + + for year in range(1900, 2100): + dt = date(year, 12, 26) + self.assertIn(dt, self.holidays) + self.assertNotIn(dt + relativedelta(days=+1), self.holidays) + self.assertNotIn(date(2009, 12, 28), self.holidays) + self.assertNotIn(date(2010, 12, 27), self.holidays) + self.holidays.observed = True + self.assertIn(date(2004, 12, 28), self.holidays) + self.assertIn(date(2010, 12, 28), self.holidays) + for year, day in enumerate( + [ + 26, + 26, + 26, + 28, + 26, + 26, + 26, + 26, + 28, + 28, + 26, + 26, + 26, + 26, + 26, + 26, + 26, + 26, + 26, + 26, + 28, + ], + 2001, + ): + dt = date(year, 12, day) + self.assertIn(dt, self.holidays, dt) + self.assertEqual(self.holidays[dt][:6], "Boxing") + + def test_all_holidays_present(self): + uk_2015 = holidays.UK(years=[2015]) + all_holidays = [ + "New Year's Day", + "Good Friday", + "Easter Monday [England, Wales, Northern Ireland]", + "May Day", + "Spring Bank Holiday", + "Christmas Day", + "Boxing Day", + ] + for holiday in all_holidays: + self.assertIn(holiday, uk_2015.values()) + + +class TestScotland(unittest.TestCase): + def setUp(self): + self.holidays = holidays.Scotland() + + def test_2017(self): + self.assertIn("2017-01-01", self.holidays) + self.assertIn("2017-01-02", self.holidays) + self.assertIn("2017-01-03", self.holidays) + self.assertIn("2017-04-14", self.holidays) + self.assertIn("2017-05-01", self.holidays) + self.assertIn("2017-05-29", self.holidays) + self.assertIn("2017-08-07", self.holidays) + self.assertIn("2017-11-30", self.holidays) + self.assertIn("2017-12-25", self.holidays) + self.assertIn("2017-12-26", self.holidays) + + +class TestIsleOfMan(unittest.TestCase): + def setUp(self): + self.holidays = holidays.IsleOfMan() + + def test_2018(self): + self.assertIn("2018-06-01", self.holidays) + self.assertIn("2018-07-05", self.holidays) diff --git a/test/countries/test_united_states.py b/test/countries/test_united_states.py new file mode 100644 index 000000000..4fb4fbf2d --- /dev/null +++ b/test/countries/test_united_states.py @@ -0,0 +1,1203 @@ +# -*- coding: utf-8 -*- + +# python-holidays +# --------------- +# A fast, efficient Python library for generating country, province and state +# specific sets of holidays on the fly. It aims to make determining whether a +# specific date is a holiday as fast and flexible as possible. +# +# Author: ryanss (c) 2014-2017 +# dr-prodigy (c) 2017-2021 +# Website: https://github.com/dr-prodigy/python-holidays +# License: MIT (see LICENSE file) + +import unittest + +from datetime import date +from dateutil.relativedelta import relativedelta + +import holidays + + +class TestUS(unittest.TestCase): + def setUp(self): + self.holidays = holidays.US(observed=False) + + def test_new_years(self): + self.assertNotIn(date(2010, 12, 31), self.holidays) + self.assertNotIn(date(2017, 1, 2), self.holidays) + self.holidays.observed = True + self.assertIn(date(2010, 12, 31), self.holidays) + self.assertIn(date(2017, 1, 2), self.holidays) + self.holidays.observed = False + for year in range(1900, 2100): + dt = date(year, 1, 1) + self.assertIn(dt, self.holidays) + self.assertNotIn(dt + relativedelta(days=-1), self.holidays) + self.assertNotIn(dt + relativedelta(days=+1), self.holidays) + + def test_epiphany(self): + pr_holidays = holidays.US(state="PR") + for year in range(2010, 2021): + self.assertNotIn(date(year, 1, 6), self.holidays) + self.assertIn(date(year, 1, 6), pr_holidays) + + def test_three_kings_day(self): + vi_holidays = holidays.US(state="VI") + for year in range(2010, 2021): + self.assertNotIn(date(year, 1, 6), self.holidays) + self.assertIn(date(year, 1, 6), vi_holidays) + + def test_lee_jackson_day(self): + va_holidays = holidays.US(state="VA") + self.assertNotIn(date(1888, 1, 19), va_holidays) + self.assertNotIn(date(1983, 1, 19), va_holidays) + self.assertNotIn( + "Lee Jackson Day", va_holidays.get_list(date(2000, 1, 17)) + ) + for dt in [ + date(1889, 1, 19), + date(1982, 1, 19), + date(1983, 1, 17), + date(1999, 1, 18), + date(2000, 1, 14), + date(2001, 1, 12), + date(2013, 1, 18), + date(2014, 1, 17), + date(2018, 1, 12), + ]: + self.assertNotIn("Lee Jackson Day", self.holidays.get_list(dt)) + self.assertIn(dt, va_holidays) + self.assertIn("Lee Jackson Day", va_holidays.get_list(dt)) + + def test_inauguration_day(self): + name = "Inauguration Day" + dc_holidays = holidays.US(state="DC") + la_holidays = holidays.US(state="LA") + md_holidays = holidays.US(state="MD") + va_holidays = holidays.US(state="VA") + for year in (1789, 1793, 1877, 1929, 1933): + self.assertNotIn(name, self.holidays.get_list(date(year, 3, 4))) + self.assertIn(name, dc_holidays.get_list(date(year, 3, 4))) + self.assertIn(name, la_holidays.get_list(date(year, 3, 4))) + self.assertIn(name, md_holidays.get_list(date(year, 3, 4))) + self.assertIn(name, va_holidays.get_list(date(year, 3, 4))) + for year in (1937, 1941, 1957, 2013, 2017): + self.assertNotIn(name, self.holidays.get_list(date(year, 1, 20))) + self.assertIn(name, dc_holidays.get_list(date(year, 1, 20))) + self.assertIn(name, la_holidays.get_list(date(year, 1, 20))) + self.assertIn(name, md_holidays.get_list(date(year, 1, 20))) + self.assertIn(name, va_holidays.get_list(date(year, 1, 20))) + for year in (1785, 1788, 2010, 2011, 2012, 2014, 2015, 2016): + self.assertNotIn(name, dc_holidays.get_list(date(year, 3, 4))) + self.assertNotIn(name, la_holidays.get_list(date(year, 3, 4))) + self.assertNotIn(name, md_holidays.get_list(date(year, 3, 4))) + self.assertNotIn(name, va_holidays.get_list(date(year, 3, 4))) + self.assertNotIn(name, dc_holidays.get_list(date(year, 1, 20))) + self.assertNotIn(name, la_holidays.get_list(date(year, 1, 20))) + self.assertNotIn(name, md_holidays.get_list(date(year, 1, 20))) + self.assertNotIn(name, va_holidays.get_list(date(year, 1, 20))) + + def test_martin_luther(self): + for dt in [ + date(1986, 1, 20), + date(1999, 1, 18), + date(2000, 1, 17), + date(2012, 1, 16), + date(2013, 1, 21), + date(2014, 1, 20), + date(2015, 1, 19), + date(2016, 1, 18), + date(2020, 1, 20), + ]: + self.assertIn(dt, self.holidays) + self.assertNotIn(dt + relativedelta(days=-1), self.holidays) + self.assertNotIn(dt + relativedelta(days=+1), self.holidays) + self.assertNotIn( + "Martin Luther King Jr. Day", holidays.US(years=[1985]).values() + ) + self.assertIn( + "Martin Luther King Jr. Day", holidays.US(years=[1986]).values() + ) + self.assertEqual( + holidays.US(state="AL").get("2015-01-19"), + "Robert E. Lee/Martin Luther King Birthday", + ) + self.assertEqual( + holidays.US(state="AR").get("2015-01-19"), + ("Dr. Martin Luther King Jr. " "and Robert E. Lee's Birthdays"), + ) + self.assertEqual( + holidays.US(state="MS").get("2015-01-19"), + ("Dr. Martin Luther King Jr. " "and Robert E. Lee's Birthdays"), + ) + self.assertEqual( + holidays.US(state="AZ").get("2015-01-19"), + "Dr. Martin Luther King Jr./Civil Rights Day", + ) + self.assertEqual( + holidays.US(state="NH").get("2015-01-19"), + "Dr. Martin Luther King Jr./Civil Rights Day", + ) + self.assertEqual( + holidays.US(state="ID").get("2015-01-19"), + "Martin Luther King Jr. - Idaho Human Rights Day", + ) + self.assertNotEqual( + holidays.US(state="ID").get("2000-01-17"), + "Martin Luther King Jr. - Idaho Human Rights Day", + ) + self.assertEqual( + holidays.US(state="GA").get("2011-01-17"), + "Robert E. Lee's Birthday", + ) + + def test_lincolns_birthday(self): + ca_holidays = holidays.US(state="CA") + ct_holidays = holidays.US(state="CT") + il_holidays = holidays.US(state="IL") + ia_holidays = holidays.US(state="IA") + nj_holidays = holidays.US(state="NJ") + ny_holidays = holidays.US(state="NY") + for year in range(1971, 2010): + self.assertNotIn(date(year, 2, 12), self.holidays) + self.assertIn(date(year, 2, 12), ca_holidays) + self.assertIn(date(year, 2, 12), ct_holidays) + self.assertIn(date(year, 2, 12), il_holidays) + self.assertIn(date(year, 2, 12), ia_holidays) + self.assertIn(date(year, 2, 12), nj_holidays) + self.assertIn(date(year, 2, 12), ny_holidays) + if date(year, 2, 12).weekday() == 5: + self.assertNotIn(date(year, 2, 11), self.holidays) + self.assertIn(date(year, 2, 11), ca_holidays) + self.assertIn(date(year, 2, 11), ct_holidays) + self.assertIn(date(year, 2, 11), il_holidays) + self.assertIn(date(year, 2, 11), ia_holidays) + self.assertIn(date(year, 2, 11), nj_holidays) + self.assertIn(date(year, 2, 11), ny_holidays) + else: + self.assertNotIn(date(year, 2, 11), ca_holidays) + self.assertNotIn(date(year, 2, 11), ct_holidays) + self.assertNotIn(date(year, 2, 11), il_holidays) + self.assertNotIn(date(year, 2, 11), ia_holidays) + self.assertNotIn(date(year, 2, 11), nj_holidays) + self.assertNotIn(date(year, 2, 11), ny_holidays) + if date(year, 2, 12).weekday() == 6: + self.assertNotIn(date(year, 2, 13), self.holidays) + self.assertIn(date(year, 2, 13), ca_holidays) + self.assertIn(date(year, 2, 13), ct_holidays) + self.assertIn(date(year, 2, 13), il_holidays) + self.assertIn(date(year, 2, 13), ia_holidays) + self.assertIn(date(year, 2, 13), nj_holidays) + self.assertIn(date(year, 2, 13), ny_holidays) + else: + self.assertNotIn(date(year, 2, 13), ca_holidays) + self.assertNotIn(date(year, 2, 13), ct_holidays) + self.assertNotIn(date(year, 2, 13), il_holidays) + self.assertNotIn(date(year, 2, 13), ia_holidays) + self.assertNotIn(date(year, 2, 13), nj_holidays) + self.assertNotIn(date(year, 2, 13), ny_holidays) + for year in range(2010, 2050): + self.assertNotIn(date(year, 2, 12), self.holidays) + self.assertNotIn(date(year, 2, 12), ca_holidays) + self.assertIn(date(year, 2, 12), ct_holidays) + self.assertIn(date(year, 2, 12), il_holidays) + self.assertIn(date(year, 2, 12), ia_holidays) + self.assertIn(date(year, 2, 12), nj_holidays) + self.assertIn(date(year, 2, 12), ny_holidays) + if date(year, 2, 12).weekday() == 5: + self.assertNotIn(date(year, 2, 11), self.holidays) + self.assertNotIn(date(year, 2, 11), ca_holidays) + self.assertIn(date(year, 2, 11), ct_holidays) + self.assertIn(date(year, 2, 11), il_holidays) + self.assertIn(date(year, 2, 11), ia_holidays) + self.assertIn(date(year, 2, 11), nj_holidays) + self.assertIn(date(year, 2, 11), ny_holidays) + else: + self.assertNotIn(date(year, 2, 11), ca_holidays) + self.assertNotIn(date(year, 2, 11), ct_holidays) + self.assertNotIn(date(year, 2, 11), il_holidays) + self.assertNotIn(date(year, 2, 11), ia_holidays) + self.assertNotIn(date(year, 2, 11), nj_holidays) + self.assertNotIn(date(year, 2, 11), ny_holidays) + if date(year, 2, 12).weekday() == 6: + self.assertNotIn(date(year, 2, 13), self.holidays) + self.assertNotIn(date(year, 2, 13), ca_holidays) + self.assertIn(date(year, 2, 13), ct_holidays) + self.assertIn(date(year, 2, 13), il_holidays) + self.assertIn(date(year, 2, 13), ia_holidays) + self.assertIn(date(year, 2, 13), nj_holidays) + self.assertIn(date(year, 2, 13), ny_holidays) + else: + self.assertNotIn(date(year, 2, 13), ca_holidays) + self.assertNotIn(date(year, 2, 13), ct_holidays) + self.assertNotIn(date(year, 2, 13), il_holidays) + self.assertNotIn(date(year, 2, 13), ia_holidays) + self.assertNotIn(date(year, 2, 13), nj_holidays) + self.assertNotIn(date(year, 2, 13), ny_holidays) + + def test_susan_b_anthony_day(self): + ca_holidays = holidays.US(state="CA") + fl_holidays = holidays.US(state="FL") + ny_holidays = holidays.US(state="NY") + wi_holidays = holidays.US(state="WI") + self.assertNotIn(date(1975, 2, 15), wi_holidays) + self.assertNotIn(date(2000, 2, 15), ca_holidays) + self.assertNotIn(date(2000, 2, 15), fl_holidays) + self.assertNotIn(date(2000, 2, 15), ny_holidays) + self.assertIn(date(2000, 2, 15), wi_holidays) + self.assertIn(date(2004, 2, 15), ny_holidays) + self.assertNotIn(date(2010, 2, 15), fl_holidays) + self.assertIn(date(2010, 2, 15), ny_holidays) + self.assertNotIn(date(2013, 2, 15), self.holidays) + self.assertNotIn(date(2013, 2, 15), ca_holidays) + self.assertIn(date(2013, 2, 15), fl_holidays) + self.assertIn(date(2013, 2, 15), ny_holidays) + self.assertNotIn(date(2014, 2, 15), self.holidays) + self.assertIn(date(2014, 2, 15), ca_holidays) + self.assertIn(date(2014, 2, 15), fl_holidays) + self.assertIn(date(2014, 2, 15), ny_holidays) + self.assertIn(date(2014, 2, 15), wi_holidays) + + def test_washingtons_birthday(self): + de_holidays = holidays.US(state="DE") + fl_holidays = holidays.US(state="FL") + ga_holidays = holidays.US(state="GA") + nm_holidays = holidays.US(state="NM") + for dt in [ + date(1969, 2, 22), + date(1970, 2, 22), + date(1971, 2, 15), + date(1997, 2, 17), + date(1999, 2, 15), + date(2000, 2, 21), + date(2012, 2, 20), + date(2013, 2, 18), + date(2014, 2, 17), + date(2015, 2, 16), + date(2016, 2, 15), + date(2020, 2, 17), + ]: + self.assertIn(dt, self.holidays) + self.assertNotIn(dt + relativedelta(days=-1), self.holidays) + self.assertNotIn(dt + relativedelta(days=+1), self.holidays) + self.assertNotIn(dt, de_holidays) + self.assertNotEqual(fl_holidays.get(dt), "Washington's Birthday") + self.assertNotIn(dt, ga_holidays) + self.assertNotIn(dt, nm_holidays) + for dt in [date(2013, 12, 24), date(2014, 12, 26), date(2015, 12, 24)]: + self.assertIn(dt, ga_holidays) + self.assertIn("Washington's Birthday", ga_holidays.get_list(dt)) + self.assertEqual( + holidays.US(state="AL").get("2015-02-16"), + "George Washington/Thomas Jefferson Birthday", + ) + self.assertEqual( + holidays.US(state="AR").get("2015-02-16"), + ("George Washington's Birthday " "and Daisy Gatson Bates Day"), + ) + self.assertEqual( + holidays.US(state="PR").get("2015-02-16"), "Presidents' Day" + ) + self.assertEqual( + holidays.US(state="VI").get("2015-02-16"), "Presidents' Day" + ) + + def test_mardi_gras(self): + la_holidays = holidays.US(state="LA") + self.assertNotIn(date(1856, 2, 5), la_holidays) + for dt in [ + date(1857, 2, 24), + date(2008, 2, 5), + date(2011, 3, 8), + date(2012, 2, 21), + date(2014, 3, 4), + date(2018, 2, 13), + ]: + self.assertNotIn(dt, self.holidays) + self.assertIn(dt, la_holidays) + + def test_guam_discovery_day(self): + gu_holidays = holidays.US(state="GU") + self.assertNotIn(date(1969, 3, 1), gu_holidays) + for dt in [ + date(1970, 3, 2), + date(1971, 3, 1), + date(1977, 3, 7), + date(2014, 3, 3), + date(2015, 3, 2), + date(2016, 3, 7), + ]: + self.assertNotIn(dt, self.holidays) + self.assertIn(dt, gu_holidays) + self.assertEqual(gu_holidays.get(dt), "Guam Discovery Day") + + def test_casimir_pulaski_day(self): + il_holidays = holidays.US(state="IL") + self.assertNotIn(date(1977, 3, 7), il_holidays) + for dt in [ + date(1978, 3, 6), + date(1982, 3, 1), + date(1983, 3, 7), + date(2014, 3, 3), + date(2015, 3, 2), + date(2016, 3, 7), + ]: + self.assertNotIn(dt, self.holidays) + self.assertIn(dt, il_holidays) + self.assertEqual(il_holidays.get(dt), "Casimir Pulaski Day") + + def test_texas_independence_day(self): + tx_holidays = holidays.US(state="TX") + self.assertNotIn(date(1873, 3, 2), tx_holidays) + for year in range(1874, 2050): + self.assertNotIn(date(year, 3, 2), self.holidays) + self.assertIn(date(year, 3, 2), tx_holidays) + + def test_town_meeting_day(self): + vt_holidays = holidays.US(state="VT") + self.assertNotIn(date(1799, 3, 5), vt_holidays) + for dt in [ + date(1800, 3, 4), + date(1803, 3, 1), + date(1804, 3, 6), + date(2011, 3, 1), + date(2015, 3, 3), + date(2017, 3, 7), + ]: + self.assertNotIn(dt, self.holidays) + self.assertIn(dt, vt_holidays) + + def test_evacuation_day(self): + ma_holidays = holidays.US(state="MA") + self.assertNotIn(date(1900, 3, 17), ma_holidays) + for year in range(1901, 2050): + self.assertNotIn(date(year, 3, 17), self.holidays) + self.assertIn(date(year, 3, 17), ma_holidays) + self.assertNotIn(date(1995, 3, 20), ma_holidays) + for dt in [date(2012, 3, 19), date(2013, 3, 18), date(2018, 3, 19)]: + self.assertIn(dt, ma_holidays) + ma_holidays.observed = False + for dt in [date(2012, 3, 19), date(2013, 3, 18), date(2018, 3, 19)]: + self.assertNotIn(dt, ma_holidays) + + def test_emancipation_day_in_puerto_rico(self): + pr_holidays = holidays.US(state="PR") + for year in range(2010, 2021): + self.assertNotIn(date(year, 3, 22), self.holidays) + self.assertIn(date(year, 3, 22), pr_holidays) + self.assertNotIn(date(2014, 3, 21), pr_holidays) + self.assertNotIn(date(2014, 3, 23), pr_holidays) + self.assertIn(date(2015, 3, 23), pr_holidays) + + def test_prince_jonah_kuhio_kalanianaole_day(self): + hi_holidays = holidays.US(state="HI") + self.assertNotIn(date(1948, 3, 26), hi_holidays) + for year in range(1949, 2050): + self.assertNotIn(date(year, 3, 26), self.holidays) + self.assertIn(date(year, 3, 26), hi_holidays) + for dt in [date(1949, 3, 25), date(2016, 3, 25), date(2017, 3, 27)]: + self.assertNotIn(dt, self.holidays) + self.assertIn(dt, hi_holidays) + self.assertEqual( + hi_holidays.get(dt), + "Prince Jonah Kuhio Kalanianaole Day (Observed)", + ) + hi_holidays.observed = False + for dt in [date(1949, 3, 25), date(2016, 3, 25), date(2017, 3, 27)]: + self.assertNotIn(dt, hi_holidays) + + def test_stewards_day(self): + ak_holidays = holidays.US(state="AK") + self.assertNotIn(date(1917, 3, 30), ak_holidays) + for dt in [ + date(1918, 3, 30), + date(1954, 3, 30), + date(1955, 3, 28), + date(2002, 3, 25), + date(2014, 3, 31), + date(2018, 3, 26), + ]: + self.assertNotIn(dt, self.holidays) + self.assertIn(dt, ak_holidays) + + def test_cesar_chavez_day(self): + ca_holidays = holidays.US(state="CA") + tx_holidays = holidays.US(state="TX") + for year in range(1995, 2000): + self.assertNotIn(date(year, 3, 31), self.holidays) + self.assertIn(date(year, 3, 31), ca_holidays) + for year in range(2000, 2020): + self.assertNotIn(date(year, 3, 31), self.holidays) + self.assertIn(date(year, 3, 31), ca_holidays) + self.assertIn(date(year, 3, 31), tx_holidays) + for year in (1996, 2002, 2013, 2019): + self.assertNotIn(date(year, 4, 1), self.holidays) + self.assertIn(date(year, 4, 1), ca_holidays) + self.assertNotIn(date(year, 4, 1), tx_holidays) + + def test_transfer_day(self): + vi_holidays = holidays.US(state="VI") + for year in range(2010, 2021): + self.assertNotIn(date(year, 3, 31), self.holidays) + self.assertIn(date(year, 3, 31), vi_holidays) + + def test_emancipation_day(self): + dc_holidays = holidays.US(state="DC") + self.assertNotIn(date(2004, 4, 16), dc_holidays) + for year in range(2005, 2020): + self.assertNotIn(date(year, 4, 16), self.holidays) + self.assertIn(date(year, 4, 16), dc_holidays) + self.assertIn(date(2005, 4, 15), dc_holidays) + self.assertIn(date(2006, 4, 17), dc_holidays) + dc_holidays.observed = False + self.assertNotIn(date(2005, 4, 15), dc_holidays) + self.assertNotIn(date(2006, 4, 17), dc_holidays) + + def test_patriots_day(self): + me_holidays = holidays.US(state="ME") + ma_holidays = holidays.US(state="MA") + self.assertNotIn(date(1983, 4, 19), me_holidays) + self.assertNotIn(date(1983, 4, 19), ma_holidays) + for year in range(1894, 1969): + self.assertNotIn(date(year, 4, 19), self.holidays) + self.assertIn(date(year, 4, 19), me_holidays) + self.assertIn(date(year, 4, 19), ma_holidays) + for dt in [ + date(1969, 4, 21), + date(1974, 4, 15), + date(1975, 4, 21), + date(2015, 4, 20), + date(2016, 4, 18), + date(2019, 4, 15), + ]: + self.assertNotIn(dt, self.holidays) + self.assertIn(dt, me_holidays) + self.assertIn(dt, ma_holidays) + + def test_holy_thursday(self): + vi_holidays = holidays.US(state="VI") + for dt in [ + date(2010, 4, 1), + date(2011, 4, 21), + date(2013, 3, 28), + date(2014, 4, 17), + date(2015, 4, 2), + date(2016, 3, 24), + ]: + self.assertNotIn(dt, self.holidays) + self.assertIn(dt, 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.assertNotIn(dt, self.holidays) + self.assertIn(dt, ct_holidays) + self.assertIn(dt, de_holidays) + self.assertIn(dt, gu_holidays) + self.assertIn(dt, in_holidays) + self.assertIn(dt, ky_holidays) + self.assertIn(dt, la_holidays) + self.assertIn(dt, nj_holidays) + self.assertIn(dt, nc_holidays) + self.assertIn(dt, tn_holidays) + self.assertIn(dt, tx_holidays) + self.assertIn(dt, vi_holidays) + + def test_easter_monday(self): + vi_holidays = holidays.US(state="VI") + for dt in [ + date(1900, 4, 16), + date(1901, 4, 8), + date(1902, 3, 31), + date(1999, 4, 5), + date(2010, 4, 5), + date(2018, 4, 2), + date(2019, 4, 22), + date(2020, 4, 13), + ]: + self.assertNotIn(dt, self.holidays) + self.assertIn(dt, vi_holidays) + + def test_confederate_memorial_day(self): + al_holidays = holidays.US(state="AL") + ga_holidays = holidays.US(state="GA") + ms_holidays = holidays.US(state="MS") + sc_holidays = holidays.US(state="SC") + tx_holidays = holidays.US(state="TX") + self.assertNotIn(date(1865, 4, 24), self.holidays) + self.assertNotIn(date(1865, 4, 24), al_holidays) + for dt in [ + date(1866, 4, 23), + date(1878, 4, 22), + date(1884, 4, 28), + date(2014, 4, 28), + date(2015, 4, 27), + date(2019, 4, 22), + ]: + self.assertNotIn(dt, self.holidays) + self.assertIn(dt, al_holidays) + self.assertIn(dt, ga_holidays) + self.assertIn(dt, ms_holidays) + self.assertIn(dt, sc_holidays) + self.assertNotIn(date(1930, 1, 19), tx_holidays) + self.assertNotIn(date(1931, 1, 19), self.holidays) + self.assertIn(date(1931, 1, 19), tx_holidays) + self.assertIn(date(2020, 4, 10), ga_holidays) + + def test_san_jacinto_day(self): + tx_holidays = holidays.US(state="TX") + self.assertNotIn(date(1874, 4, 21), tx_holidays) + for year in (1875, 2050): + self.assertNotIn(date(year, 4, 21), self.holidays) + self.assertIn(date(year, 4, 21), tx_holidays) + + def test_arbor_day(self): + ne_holidays = holidays.US(state="NE") + for dt in [ + date(1875, 4, 22), + date(1988, 4, 22), + date(1989, 4, 28), + date(2009, 4, 24), + date(2010, 4, 30), + date(2014, 4, 25), + ]: + self.assertNotIn(dt, self.holidays) + self.assertIn(dt, ne_holidays) + + def test_primary_election_day(self): + in_holidays = holidays.US(state="IN") + self.assertNotIn(date(2004, 5, 4), in_holidays) + for dt in [ + date(2006, 5, 2), + date(2008, 5, 6), + date(2010, 5, 4), + date(2012, 5, 8), + date(2014, 5, 6), + date(2015, 5, 5), + date(2016, 5, 3), + ]: + self.assertNotIn(dt, self.holidays) + self.assertIn(dt, in_holidays) + + def test_truman_day(self): + mo_holidays = holidays.US(state="MO", observed=False) + self.assertNotIn(date(1948, 5, 8), self.holidays) + self.assertNotIn(date(1948, 5, 8), mo_holidays) + for year in range(1949, 2100): + dt = date(year, 5, 8) + self.assertNotIn(dt, self.holidays) + self.assertIn(dt, mo_holidays) + self.assertNotIn(dt + relativedelta(days=-1), mo_holidays) + self.assertNotIn(dt + relativedelta(days=+1), mo_holidays) + self.assertNotIn(date(2004, 5, 7), mo_holidays) + self.assertNotIn(date(2005, 5, 10), mo_holidays) + mo_holidays.observed = True + self.assertIn(date(2004, 5, 7), mo_holidays) + self.assertIn(date(2005, 5, 10), mo_holidays) + + def test_memorial_day(self): + for dt in [ + date(1969, 5, 30), + date(1970, 5, 30), + date(1971, 5, 31), + date(1997, 5, 26), + date(1999, 5, 31), + date(2000, 5, 29), + date(2012, 5, 28), + date(2013, 5, 27), + date(2014, 5, 26), + date(2015, 5, 25), + date(2016, 5, 30), + date(2020, 5, 25), + ]: + self.assertIn(dt, self.holidays) + self.assertNotIn(dt + relativedelta(days=-1), self.holidays) + self.assertNotIn(dt + relativedelta(days=+1), self.holidays) + + def test_jefferson_davis_birthday(self): + al_holidays = holidays.US(state="AL") + self.assertNotIn(date(1889, 6, 3), self.holidays) + self.assertNotIn(date(1889, 6, 3), 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.assertNotIn(dt, self.holidays) + self.assertIn(dt, al_holidays) + + def test_kamehameha_day(self): + hi_holidays = holidays.US(state="HI") + self.assertNotIn(date(1871, 6, 11), hi_holidays) + for year in range(1872, 2050): + self.assertNotIn(date(year, 6, 11), self.holidays) + self.assertIn(date(year, 6, 11), hi_holidays) + self.assertNotIn(date(2006, 6, 12), hi_holidays) + for dt in [date(2011, 6, 10), date(2016, 6, 10), date(2017, 6, 12)]: + self.assertIn(dt, hi_holidays) + self.assertEqual(hi_holidays.get(dt), "Kamehameha Day (Observed)") + hi_holidays.observed = False + for dt in [date(2011, 6, 10), date(2016, 6, 10), date(2017, 6, 12)]: + self.assertNotIn(dt, hi_holidays) + + def test_emancipation_day_in_texas(self): + tx_holidays = holidays.US(state="TX") + self.assertNotIn(date(1979, 6, 19), tx_holidays) + for year in (1980, 2050): + self.assertNotIn(date(year, 6, 19), self.holidays) + self.assertIn(date(year, 6, 19), tx_holidays) + + def test_west_virginia_day(self): + wv_holidays = holidays.US(state="WV") + self.assertNotIn(date(1926, 6, 20), wv_holidays) + for year in (1927, 2050): + self.assertNotIn(date(year, 6, 20), self.holidays) + self.assertIn(date(year, 6, 20), wv_holidays) + self.assertIn(date(2015, 6, 19), wv_holidays) + self.assertIn(date(2010, 6, 21), wv_holidays) + wv_holidays.observed = False + self.assertNotIn(date(2015, 6, 19), wv_holidays) + self.assertNotIn(date(2010, 6, 21), wv_holidays) + + def test_emancipation_day_in_virgin_islands(self): + vi_holidays = holidays.US(state="VI") + for year in (2010, 2021): + self.assertNotIn(date(year, 7, 3), self.holidays) + self.assertIn(date(year, 7, 3), vi_holidays) + + def test_independence_day(self): + for year in range(1900, 2100): + dt = date(year, 7, 4) + self.assertIn(dt, self.holidays) + self.assertNotIn(dt + relativedelta(days=-1), self.holidays) + self.assertNotIn(dt + relativedelta(days=+1), self.holidays) + self.assertNotIn(date(2010, 7, 5), self.holidays) + self.assertNotIn(date(2020, 7, 3), self.holidays) + self.holidays.observed = True + self.assertIn(date(2010, 7, 5), self.holidays) + self.assertIn(date(2020, 7, 3), self.holidays) + + def test_liberation_day_guam(self): + gu_holidays = holidays.US(state="GU") + self.assertNotIn(date(1944, 7, 21), gu_holidays) + for year in range(1945, 2100): + self.assertNotIn(date(year, 7, 21), self.holidays) + self.assertIn(date(year, 7, 21), gu_holidays) + + def test_pioneer_day(self): + ut_holidays = holidays.US(state="UT") + self.assertNotIn(date(1848, 7, 24), ut_holidays) + for year in (1849, 2050): + self.assertNotIn(date(year, 7, 24), self.holidays) + self.assertIn(date(year, 7, 24), ut_holidays) + self.assertIn("2010-07-23", ut_holidays) + self.assertIn("2011-07-25", ut_holidays) + ut_holidays.observed = False + self.assertNotIn("2010-07-23", ut_holidays) + self.assertNotIn("2011-07-25", ut_holidays) + + def test_constitution_day(self): + pr_holidays = holidays.US(state="PR") + for year in range(2010, 2021): + self.assertNotIn(date(year, 7, 25), self.holidays) + self.assertIn(date(year, 7, 25), pr_holidays) + self.assertNotIn(date(2015, 7, 24), pr_holidays) + self.assertNotIn(date(2015, 7, 26), pr_holidays) + self.assertIn(date(2021, 7, 26), pr_holidays) + + def test_victory_day(self): + ri_holidays = holidays.US(state="RI") + self.assertNotIn(date(1947, 8, 11), ri_holidays) + for dt in [ + date(1948, 8, 9), + date(1995, 8, 14), + date(2005, 8, 8), + date(2015, 8, 10), + date(2016, 8, 8), + date(2017, 8, 14), + ]: + self.assertNotIn(dt, self.holidays) + self.assertIn(dt, ri_holidays) + + def test_statehood_day(self): + hi_holidays = holidays.US(state="HI") + self.assertNotIn(date(1958, 8, 15), hi_holidays) + for dt in [ + date(1959, 8, 21), + date(1969, 8, 15), + date(1999, 8, 20), + date(2014, 8, 15), + date(2015, 8, 21), + date(2016, 8, 19), + ]: + self.assertNotIn(dt, self.holidays) + self.assertIn(dt, hi_holidays) + + def test_bennington_battle_day(self): + vt_holidays = holidays.US(state="VT") + self.assertNotIn(date(1777, 8, 16), vt_holidays) + for year in range(1778, 2050): + self.assertNotIn(date(year, 8, 16), self.holidays) + self.assertIn(date(year, 8, 16), vt_holidays) + vt_holidays.observed = False + self.assertNotIn( + "Bennington Battle Day (Observed)", + vt_holidays.get_list(date(1997, 8, 15)), + ) + vt_holidays.observed = True + self.assertIn( + "Bennington Battle Day (Observed)", + vt_holidays.get_list(date(1997, 8, 15)), + ) + self.assertNotIn( + "Bennington Battle Day (Observed)", + vt_holidays.get_list(date(1997, 8, 17)), + ) + self.assertIn( + "Bennington Battle Day (Observed)", + vt_holidays.get_list(date(1998, 8, 17)), + ) + self.assertNotIn( + "Bennington Battle Day (Observed)", + vt_holidays.get_list(date(1999, 8, 15)), + ) + self.assertNotIn( + "Bennington Battle Day (Observed)", + vt_holidays.get_list(date(1999, 8, 17)), + ) + + def test_lyndon_baines_johnson_day(self): + tx_holidays = holidays.US(state="TX") + self.assertNotIn(date(1972, 8, 27), tx_holidays) + for year in (1973, 2050): + self.assertNotIn(date(year, 8, 27), self.holidays) + self.assertIn(date(year, 8, 27), tx_holidays) + + def test_labor_day(self): + for dt in [ + date(1997, 9, 1), + date(1999, 9, 6), + date(2000, 9, 4), + date(2012, 9, 3), + date(2013, 9, 2), + date(2014, 9, 1), + date(2015, 9, 7), + date(2016, 9, 5), + date(2020, 9, 7), + ]: + self.assertIn(dt, self.holidays) + self.assertNotIn(dt + relativedelta(days=-1), self.holidays) + self.assertNotIn(dt + relativedelta(days=+1), self.holidays) + + def test_columbus_day(self): + ak_holidays = holidays.US(state="AK") + de_holidays = holidays.US(state="DE") + fl_holidays = holidays.US(state="FL") + hi_holidays = holidays.US(state="HI") + sd_holidays = holidays.US(state="SD") + vi_holidays = holidays.US(state="VI") + for dt in [ + date(1937, 10, 12), + date(1969, 10, 12), + date(1970, 10, 12), + date(1999, 10, 11), + date(2000, 10, 9), + date(2001, 10, 8), + date(2013, 10, 14), + date(2018, 10, 8), + date(2019, 10, 14), + ]: + self.assertIn(dt, self.holidays) + self.assertNotIn(dt, ak_holidays) + self.assertNotIn(dt, de_holidays) + self.assertNotIn(dt, fl_holidays) + self.assertNotIn(dt, hi_holidays) + self.assertNotIn(dt + relativedelta(days=-1), self.holidays) + self.assertNotIn(dt + relativedelta(days=+1), self.holidays) + self.assertEqual(sd_holidays.get(dt), "Native American Day") + self.assertEqual( + vi_holidays.get(dt), + "Columbus Day and Puerto Rico Friendship Day", + ) + self.assertNotIn(date(1936, 10, 12), self.holidays) + + def test_alaska_day(self): + ak_holidays = holidays.US(state="AK", observed=False) + self.assertNotIn(date(1866, 10, 18), ak_holidays) + for year in range(1867, 2050): + self.assertIn(date(year, 10, 18), ak_holidays) + self.assertNotIn(date(year, 10, 17), ak_holidays) + self.assertNotIn(date(year, 10, 19), ak_holidays) + self.assertNotIn(date(year, 10, 18), self.holidays) + ak_holidays.observed = True + self.assertIn(date(2014, 10, 17), ak_holidays) + self.assertIn(date(2015, 10, 19), ak_holidays) + + def test_nevada_day(self): + nv_holidays = holidays.US(state="NV") + self.assertNotIn(date(1932, 10, 31), 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.assertNotIn(dt, self.holidays) + self.assertIn(dt, nv_holidays) + self.assertIn( + "Nevada Day (Observed)", nv_holidays.get_list(date(1998, 10, 30)) + ) + self.assertIn( + "Nevada Day (Observed)", nv_holidays.get_list(date(1999, 11, 1)) + ) + nv_holidays.observed = False + self.assertNotIn( + "Nevada Day (Observed)", nv_holidays.get_list(date(1998, 10, 30)) + ) + self.assertNotIn( + "Nevada Day (Observed)", nv_holidays.get_list(date(1999, 11, 1)) + ) + + def test_liberty_day(self): + vi_holidays = holidays.US(state="VI") + for year in range(2010, 2021): + self.assertNotIn(date(year, 11, 1), self.holidays) + self.assertIn(date(year, 11, 1), vi_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.assertNotIn(date(2004, 11, 2), 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.assertNotIn(dt, self.holidays) + self.assertIn(dt, de_holidays) + self.assertIn(dt, hi_holidays) + self.assertIn(dt, il_holidays) + self.assertIn(dt, in_holidays) + self.assertIn(dt, la_holidays) + self.assertIn(dt, mt_holidays) + self.assertIn(dt, nh_holidays) + self.assertIn(dt, nj_holidays) + self.assertIn(dt, ny_holidays) + self.assertIn(dt, wv_holidays) + self.assertNotIn(date(2015, 11, 3), self.holidays) + self.assertNotIn(date(2015, 11, 3), de_holidays) + self.assertNotIn(date(2015, 11, 3), hi_holidays) + self.assertNotIn(date(2015, 11, 3), il_holidays) + self.assertIn(date(2015, 11, 3), in_holidays) + self.assertNotIn(date(2015, 11, 3), la_holidays) + self.assertNotIn(date(2015, 11, 3), mt_holidays) + self.assertNotIn(date(2015, 11, 3), nh_holidays) + self.assertNotIn(date(2015, 11, 3), nj_holidays) + self.assertIn(date(2015, 11, 3), ny_holidays) + self.assertNotIn(date(2015, 11, 3), wv_holidays) + + def test_all_souls_day(self): + gu_holidays = holidays.US(state="GU") + for year in range(1945, 2100): + self.assertNotIn(date(year, 11, 2), self.holidays) + self.assertIn(date(year, 11, 2), gu_holidays) + + def test_veterans_day(self): + for dt in [ + date(1938, 11, 11), + date(1939, 11, 11), + date(1970, 11, 11), + date(1971, 10, 25), + date(1977, 10, 24), + date(1978, 11, 11), + date(2012, 11, 11), + date(2013, 11, 11), + date(2014, 11, 11), + date(2015, 11, 11), + date(2016, 11, 11), + date(2020, 11, 11), + ]: + self.assertIn(dt, self.holidays) + self.assertNotIn(dt + relativedelta(days=-1), self.holidays) + self.assertNotIn(dt + relativedelta(days=+1), self.holidays) + self.assertNotIn("Armistice Day", holidays.US(years=[1937]).values()) + self.assertNotIn("Armistice Day", holidays.US(years=[1937]).values()) + self.assertIn("Armistice Day", holidays.US(years=[1938]).values()) + self.assertIn("Armistice Day", holidays.US(years=[1953]).values()) + self.assertIn("Veterans Day", holidays.US(years=[1954]).values()) + self.assertNotIn(date(2012, 11, 12), self.holidays) + self.assertNotIn(date(2017, 11, 10), self.holidays) + self.holidays.observed = True + self.assertIn(date(2012, 11, 12), self.holidays) + self.assertIn(date(2017, 11, 10), self.holidays) + + def test_discovery_day(self): + pr_holidays = holidays.US(state="PR") + for year in range(2010, 2021): + self.assertNotIn(date(year, 11, 19), self.holidays) + self.assertIn(date(year, 11, 19), pr_holidays) + self.assertNotIn(date(2016, 11, 18), pr_holidays) + self.assertNotIn(date(2016, 11, 20), pr_holidays) + self.assertIn(date(2017, 11, 20), pr_holidays) + + def test_thanksgiving_day(self): + ca_holidays = holidays.US(state="CA") + de_holidays = holidays.US(state="DE") + fl_holidays = holidays.US(state="FL") + in_holidays = holidays.US(state="IN") + md_holidays = holidays.US(state="MD") + nv_holidays = holidays.US(state="NV") + nh_holidays = holidays.US(state="NH") + nm_holidays = holidays.US(state="NM") + nc_holidays = holidays.US(state="NC") + ok_holidays = holidays.US(state="OK") + tx_holidays = holidays.US(state="TX") + wv_holidays = holidays.US(state="WV") + for dt in [ + date(1997, 11, 27), + date(1999, 11, 25), + date(2000, 11, 23), + date(2012, 11, 22), + date(2013, 11, 28), + date(2014, 11, 27), + date(2015, 11, 26), + date(2016, 11, 24), + date(2020, 11, 26), + ]: + self.assertIn(dt, self.holidays) + self.assertNotIn(dt + relativedelta(days=-1), self.holidays) + self.assertNotIn(dt + relativedelta(days=+1), self.holidays) + self.assertIn(dt + relativedelta(days=+1), de_holidays) + self.assertEqual( + ca_holidays.get(dt + relativedelta(days=+1)), + "Day After Thanksgiving", + ) + self.assertEqual( + de_holidays.get(dt + relativedelta(days=+1)), + "Day After Thanksgiving", + ) + self.assertEqual( + nh_holidays.get(dt + relativedelta(days=+1)), + "Day After Thanksgiving", + ) + self.assertEqual( + nc_holidays.get(dt + relativedelta(days=+1)), + "Day After Thanksgiving", + ) + self.assertEqual( + ok_holidays.get(dt + relativedelta(days=+1)), + "Day After Thanksgiving", + ) + self.assertEqual( + wv_holidays.get(dt + relativedelta(days=+1)), + "Day After Thanksgiving", + ) + self.assertIn(dt + relativedelta(days=+1), fl_holidays) + self.assertEqual( + fl_holidays.get(dt + relativedelta(days=+1)), + "Friday After Thanksgiving", + ) + self.assertIn(dt + relativedelta(days=+1), tx_holidays) + self.assertEqual( + tx_holidays.get(dt + relativedelta(days=+1)), + "Friday After Thanksgiving", + ) + self.assertEqual( + nv_holidays.get(dt + relativedelta(days=+1)), "Family Day" + ) + self.assertEqual( + nm_holidays.get(dt + relativedelta(days=+1)), "Presidents' Day" + ) + if dt.year >= 2008: + self.assertEqual( + md_holidays.get(dt + relativedelta(days=1)), + "American Indian Heritage Day", + ) + if dt.year >= 2010: + self.assertEqual( + in_holidays.get(dt + relativedelta(days=1)), + "Lincoln's Birthday", + ) + else: + self.assertNotEqual( + in_holidays.get(dt + relativedelta(days=1)), + "Lincoln's Birthday", + ) + + def test_robert_lee_birthday(self): + ga_holidays = holidays.US(state="GA") + self.assertNotIn(date(1985, 11, 25), ga_holidays) + for dt in [ + date(2007, 11, 23), + date(2008, 11, 28), + date(2010, 11, 26), + date(2013, 11, 29), + date(2014, 11, 28), + date(2015, 11, 27), + date(2018, 11, 23), + date(2019, 11, 29), + date(2020, 11, 27), + ]: + self.assertNotIn(dt, self.holidays) + self.assertIn(dt, ga_holidays) + + def test_lady_of_camarin_day(self): + gu_holidays = holidays.US(state="GU") + for year in range(1945, 2100): + self.assertNotIn(date(year, 12, 8), self.holidays) + self.assertIn(date(year, 12, 8), gu_holidays) + + def test_christmas_eve(self): + as_holidays = holidays.US(state="AS") + ks_holidays = holidays.US(state="KS") + mi_holidays = holidays.US(state="MI") + nc_holidays = holidays.US(state="NC") + tx_holidays = holidays.US(state="TX") + wi_holidays = holidays.US(state="WI") + self.holidays.observed = False + for year in range(1900, 2050): + self.assertNotIn(date(year, 12, 24), self.holidays) + self.assertIn(date(year, 12, 24), as_holidays) + if year >= 2013: + f = ks_holidays.get(date(year, 12, 24)).find("Eve") + self.assertGreater(f, 0) + f = mi_holidays.get(date(year, 12, 24)).find("Eve") + self.assertGreater(f, 0) + f = nc_holidays.get(date(year, 12, 24)).find("Eve") + self.assertGreater(f, 0) + if year >= 2012: + f = wi_holidays.get(date(year, 12, 24)).find("Eve") + self.assertGreater(f, 0) + if year >= 1981: + f = tx_holidays.get(date(year, 12, 24)).find("Eve") + self.assertGreater(f, 0) + if year < 1981: + f = ks_holidays.get(date(year, 12, 24), "").find("Eve") + self.assertLess(f, 0) + f = mi_holidays.get(date(year, 12, 24), "").find("Eve") + self.assertLess(f, 0) + f = nc_holidays.get(date(year, 12, 24), "").find("Eve") + self.assertLess(f, 0) + f = tx_holidays.get(date(year, 12, 24), "").find("Eve") + self.assertLess(f, 0) + f = wi_holidays.get(date(year, 12, 24), "").find("Eve") + self.assertLess(f, 0) + self.assertIn(date(2016, 12, 23), as_holidays) + self.assertIn(date(2016, 12, 23), ks_holidays) + self.assertIn(date(2016, 12, 23), mi_holidays) + self.assertIn(date(2016, 12, 23), nc_holidays) + self.assertIn(date(2016, 12, 23), tx_holidays) + self.assertIn(date(2016, 12, 23), wi_holidays) + self.assertIn( + "Christmas Eve (Observed)", + as_holidays.get_list(date(2017, 12, 22)), + ) + self.assertIn( + "Christmas Eve (Observed)", + ks_holidays.get_list(date(2017, 12, 22)), + ) + self.assertIn( + "Christmas Eve (Observed)", + mi_holidays.get_list(date(2017, 12, 22)), + ) + self.assertIn( + "Christmas Eve (Observed)", + nc_holidays.get_list(date(2017, 12, 22)), + ) + self.assertIn( + "Christmas Eve (Observed)", + tx_holidays.get_list(date(2017, 12, 22)), + ) + self.assertIn( + "Christmas Eve (Observed)", + wi_holidays.get_list(date(2017, 12, 22)), + ) + + def test_christmas_day(self): + for year in range(1900, 2100): + dt = date(year, 12, 25) + self.assertIn(dt, self.holidays) + self.assertNotIn(dt + relativedelta(days=-1), self.holidays) + self.assertNotIn(dt + relativedelta(days=+1), self.holidays) + self.assertNotIn(date(2010, 12, 24), self.holidays) + self.assertNotIn(date(2016, 12, 26), self.holidays) + self.holidays.observed = True + self.assertIn(date(2010, 12, 24), self.holidays) + self.assertIn(date(2016, 12, 26), self.holidays) + + def test_day_after_christmas(self): + nc_holidays = holidays.US(state="NC", observed=False) + tx_holidays = holidays.US(state="TX", observed=False) + self.assertNotIn(date(2015, 12, 28), nc_holidays) + self.assertNotIn(date(2016, 12, 27), nc_holidays) + self.assertNotIn(date(2015, 12, 28), tx_holidays) + self.assertNotIn(date(2016, 12, 27), tx_holidays) + nc_holidays.observed = True + self.assertIn( + "Day After Christmas (Observed)", + nc_holidays.get_list(date(2015, 12, 28)), + ) + self.assertIn( + "Day After Christmas (Observed)", + nc_holidays.get_list(date(2016, 12, 27)), + ) + tx_holidays.observed = True + self.assertNotIn( + "Day After Christmas (Observed)", + tx_holidays.get_list(date(2015, 12, 28)), + ) + self.assertNotIn( + "Day After Christmas (Observed)", + tx_holidays.get_list(date(2016, 12, 27)), + ) + + def test_new_years_eve(self): + ky_holidays = holidays.US(state="KY") + mi_holidays = holidays.US(state="MI") + wi_holidays = holidays.US(state="WI") + self.assertNotIn(date(2012, 12, 31), ky_holidays) + self.assertNotIn(date(2012, 12, 31), mi_holidays) + self.assertNotIn(date(2011, 12, 31), wi_holidays) + self.assertIn(date(2012, 12, 31), wi_holidays) + for dt in [date(2013, 12, 31), date(2016, 12, 30)]: + self.assertNotIn(dt, self.holidays) + self.assertIn(dt, ky_holidays) + self.assertIn(dt, mi_holidays) + self.assertIn(dt, wi_holidays) diff --git a/test/countries/test_vietnam.py b/test/countries/test_vietnam.py new file mode 100644 index 000000000..d1af55f9a --- /dev/null +++ b/test/countries/test_vietnam.py @@ -0,0 +1,110 @@ +# -*- coding: utf-8 -*- + +# python-holidays +# --------------- +# A fast, efficient Python library for generating country, province and state +# specific sets of holidays on the fly. It aims to make determining whether a +# specific date is a holiday as fast and flexible as possible. +# +# Author: ryanss (c) 2014-2017 +# dr-prodigy (c) 2017-2021 +# Website: https://github.com/dr-prodigy/python-holidays +# License: MIT (see LICENSE file) + +import unittest + +from datetime import date +from dateutil.relativedelta import relativedelta + +import holidays + + +class TestVietnam(unittest.TestCase): + def setUp(self): + self.holidays = holidays.VN() + + def test_common(self): + self.assertEqual( + self.holidays[date(2020, 1, 1)], "International New Year's Day" + ) + + def test_first_day_of_january(self): + for year in range(1979, 2050): + self.assertIn( + "International New Year's Day", self.holidays[date(year, 1, 1)] + ) + + def test_lunar_new_year(self): + lunar_new_year_list = [ + (2008, 2, 7), + (2009, 1, 26), + (2010, 2, 14), + (2011, 2, 3), + (2012, 1, 23), + (2013, 2, 10), + (2014, 1, 31), + (2015, 2, 19), + (2016, 2, 8), + (2017, 1, 28), + (2018, 2, 16), + (2019, 2, 5), + (2020, 1, 25), + (2021, 2, 12), + (2022, 2, 1), + ] + for year, month, day in lunar_new_year_list: + self.assertEqual( + self.holidays[date(year, month, day) + relativedelta(days=-1)], + "Vietnamese New Year's Eve", + ) + self.assertEqual( + self.holidays[date(year, month, day) + relativedelta(days=0)], + "Vietnamese New Year", + ) + self.assertEqual( + self.holidays[date(year, month, day) + relativedelta(days=+1)], + "The second day of Tet Holiday", + ) + self.assertEqual( + self.holidays[date(year, month, day) + relativedelta(days=+2)], + "The third day of Tet Holiday", + ) + self.assertEqual( + self.holidays[date(year, month, day) + relativedelta(days=+3)], + "The forth day of Tet Holiday", + ) + self.assertEqual( + self.holidays[date(year, month, day) + relativedelta(days=+4)], + "The fifth day of Tet Holiday", + ) + + def test_king_hung_day(self): + for year, month, day in [(2020, 4, 2), (2021, 4, 21), (2022, 4, 10)]: + self.assertEqual( + self.holidays[date(year, month, day)], + "Hung Kings Commemoration Day", + ) + + def test_liberation_day(self): + for year in range(1979, 2050): + self.assertIn( + "Liberation Day/Reunification Day", + self.holidays[date(year, 4, 30)], + ) + + def test_international_labor_day(self): + for year in range(1979, 2050): + self.assertIn( + "International Labor Day", self.holidays[date(year, 5, 1)] + ) + + def test_independence_day(self): + for year in range(1979, 2050): + self.assertIn("Independence Day", self.holidays[date(year, 9, 2)]) + + def test_years_range(self): + self.holidays = holidays.VN(years=range(1979, 2050)) + for year in range(1979, 2050): + self.assertIn( + "International New Year's Day", self.holidays[date(year, 1, 1)] + ) diff --git a/test/test_holiday_base.py b/test/test_holiday_base.py new file mode 100644 index 000000000..9211bf3c4 --- /dev/null +++ b/test/test_holiday_base.py @@ -0,0 +1,528 @@ +# -*- coding: utf-8 -*- + +# python-holidays +# --------------- +# A fast, efficient Python library for generating country, province and state +# specific sets of holidays on the fly. It aims to make determining whether a +# specific date is a holiday as fast and flexible as possible. +# +# Author: ryanss (c) 2014-2017 +# dr-prodigy (c) 2017-2021 +# Website: https://github.com/dr-prodigy/python-holidays +# License: MIT (see LICENSE file) + +import unittest + +from datetime import date, datetime, timedelta +from dateutil.relativedelta import relativedelta, MO + +import holidays + + +class TestBasics(unittest.TestCase): + def setUp(self): + self.holidays = holidays.US() + + def test_contains(self): + self.assertIn(date(2014, 1, 1), self.holidays) + self.assertNotIn(date(2014, 1, 2), self.holidays) + + def test_getitem(self): + self.assertEqual(self.holidays[date(2014, 1, 1)], "New Year's Day") + self.assertEqual(self.holidays.get(date(2014, 1, 1)), "New Year's Day") + self.assertRaises(KeyError, lambda: self.holidays[date(2014, 1, 2)]) + self.assertIsNone(self.holidays.get(date(2014, 1, 2))) + + self.assertListEqual( + self.holidays[date(2013, 12, 31) : date(2014, 1, 2)], + [date(2014, 1, 1)], + ) + self.assertListEqual( + self.holidays[date(2013, 12, 24) : date(2014, 1, 2)], + [date(2013, 12, 25), date(2014, 1, 1)], + ) + self.assertListEqual( + self.holidays[date(2013, 12, 25) : date(2014, 1, 2) : 3], + [date(2013, 12, 25)], + ) + self.assertListEqual( + self.holidays[date(2013, 12, 25) : date(2014, 1, 2) : 7], + [date(2013, 12, 25), date(2014, 1, 1)], + ) + self.assertListEqual( + self.holidays[date(2014, 1, 2) : date(2013, 12, 30)], + [date(2014, 1, 1)], + ) + self.assertListEqual( + self.holidays[date(2014, 1, 2) : date(2013, 12, 25)], + [date(2014, 1, 1)], + ) + self.assertListEqual( + self.holidays[date(2014, 1, 2) : date(2013, 12, 24)], + [date(2014, 1, 1), date(2013, 12, 25)], + ) + self.assertListEqual( + self.holidays[date(2014, 1, 1) : date(2013, 12, 24) : 3], + [date(2014, 1, 1)], + ) + self.assertListEqual( + self.holidays[date(2014, 1, 1) : date(2013, 12, 24) : 7], + [date(2014, 1, 1), date(2013, 12, 25)], + ) + self.assertListEqual( + self.holidays[date(2013, 12, 31) : date(2014, 1, 2) : -3], [] + ) + self.assertListEqual( + self.holidays[ + date(2014, 1, 1) : date(2013, 12, 24) : timedelta(days=3) + ], + [date(2014, 1, 1)], + ) + self.assertListEqual( + self.holidays[ + date(2014, 1, 1) : date(2013, 12, 24) : timedelta(days=7) + ], + [date(2014, 1, 1), date(2013, 12, 25)], + ) + self.assertListEqual( + self.holidays[ + date(2013, 12, 31) : date(2014, 1, 2) : timedelta(days=3) + ], + [], + ) + self.assertRaises( + ValueError, lambda: self.holidays[date(2014, 1, 1) :] + ) + self.assertRaises( + ValueError, lambda: self.holidays[: date(2014, 1, 1)] + ) + self.assertRaises( + TypeError, + lambda: self.holidays[date(2014, 1, 1) : date(2014, 1, 2) : ""], + ) + self.assertRaises( + ValueError, + lambda: self.holidays[date(2014, 1, 1) : date(2014, 1, 2) : 0], + ) + + def test_get(self): + self.assertEqual(self.holidays.get("2014-01-01"), "New Year's Day") + self.assertIsNone(self.holidays.get("2014-01-02")) + self.assertFalse(self.holidays.get("2014-01-02", False)) + self.assertTrue(self.holidays.get("2014-01-02", True)) + + def test_pop(self): + self.assertRaises(KeyError, lambda: self.holidays.pop("2014-01-02")) + self.assertFalse(self.holidays.pop("2014-01-02", False)) + self.assertTrue(self.holidays.pop("2014-01-02", True)) + self.assertIn(date(2014, 1, 1), self.holidays) + self.assertEqual(self.holidays.pop("2014-01-01"), "New Year's Day") + self.assertNotIn(date(2014, 1, 1), self.holidays) + self.assertIn(date(2014, 7, 4), self.holidays) + + def test_pop_named(self): + self.assertIn(date(2014, 1, 1), self.holidays) + self.holidays.pop_named("New Year's Day") + self.assertNotIn(date(2014, 1, 1), self.holidays) + self.assertRaises( + KeyError, lambda: self.holidays.pop_named("New Year's Dayz") + ) + + def test_setitem(self): + self.holidays = holidays.US(years=[2014]) + self.assertEqual(len(self.holidays), 10) + self.holidays[date(2014, 1, 3)] = "Fake Holiday" + self.assertEqual(len(self.holidays), 11) + self.assertIn(date(2014, 1, 3), self.holidays) + self.assertEqual(self.holidays.get(date(2014, 1, 3)), "Fake Holiday") + + def test_update(self): + h = holidays.HolidayBase() + h.update( + { + date(2015, 1, 1): "New Year's Day", + "2015-12-25": "Christmas Day", + } + ) + self.assertIn("2015-01-01", h) + self.assertIn(date(2015, 12, 25), h) + + def test_append(self): + h = holidays.HolidayBase() + h.update( + { + date(2015, 1, 1): "New Year's Day", + "2015-12-25": "Christmas Day", + } + ) + h.append([date(2015, 4, 1), "2015-04-03"]) + h.append(date(2015, 4, 6)) + h.append("2015-04-07") + self.assertIn("2015-01-01", h) + self.assertIn(date(2015, 12, 25), h) + self.assertIn("2015-04-01", h) + self.assertNotIn("2015-04-02", h) + self.assertIn("2015-04-03", h) + self.assertNotIn("2015-04-04", h) + self.assertNotIn("2015-04-05", h) + self.assertIn("2015-04-06", h) + self.assertIn("2015-04-07", h) + + def test_eq_ne(self): + us1 = holidays.UnitedStates() + us2 = holidays.US() + us3 = holidays.UnitedStates(years=[2014]) + us4 = holidays.US(years=[2014]) + ca1 = holidays.Canada() + ca2 = holidays.CA() + ca3 = holidays.Canada(years=[2014]) + ca4 = holidays.CA(years=[2014]) + self.assertEqual(us1, us2) + self.assertEqual(us3, us4) + self.assertEqual(ca1, ca2) + self.assertEqual(ca3, ca4) + self.assertNotEqual(us1, us3) + self.assertNotEqual(us1, ca1) + self.assertNotEqual(us3, ca3) + self.assertNotEqual(us1, us3) + + def test_add(self): + ca = holidays.CA() + us = holidays.US() + mx = holidays.MX() + na = ca + (us + mx) + self.assertNotIn("2014-07-01", us) + self.assertIn("2014-07-01", ca) + self.assertNotIn("2014-07-04", ca) + self.assertIn("2014-07-04", us) + self.assertIn("2014-07-04", ca + us) + self.assertIn("2014-07-04", us + ca) + self.assertIn("2015-07-04", ca + us) + self.assertIn("2015-07-04", us + ca) + self.assertIn("2015-07-01", ca + us) + self.assertIn("2015-07-01", us + ca) + self.assertIn("2014-07-04", na) + self.assertIn("2015-07-04", na) + self.assertIn("2015-07-01", na) + self.assertIn("2000-02-05", na) + self.assertEqual((ca + us).prov, "ON") + self.assertEqual((us + ca).prov, "ON") + ca = holidays.CA(years=[2014], expand=False) + us = holidays.US(years=[2014, 2015], expand=True) + self.assertTrue((ca + us).expand) + self.assertEqual((ca + us).years, {2014, 2015}) + self.assertEqual((us + ca).years, {2014, 2015}) + na = holidays.CA() + na += holidays.US() + na += holidays.MX() + self.assertEqual(na.country, ["CA", "US", "MX"]) + self.assertIn("2014-07-04", na) + self.assertIn("2014-07-04", na) + self.assertIn("2015-07-04", na) + self.assertIn("2015-07-04", na) + self.assertIn("2015-07-01", na) + self.assertIn("2015-07-01", na) + self.assertIn("2000-02-05", na) + self.assertEqual(na.prov, "ON") + na = holidays.CA() + holidays.US() + na += holidays.MX() + self.assertIn("2014-07-04", na) + self.assertIn("2014-07-04", na) + self.assertIn("2015-07-04", na) + self.assertIn("2015-07-04", na) + self.assertIn("2015-07-01", na) + self.assertIn("2015-07-01", na) + self.assertIn("2000-02-05", na) + self.assertEqual(na.prov, "ON") + self.assertRaises(TypeError, lambda: holidays.US() + {}) + na = ca + (us + mx) + ca + (mx + us + holidays.CA(prov="BC")) + self.assertIn("2000-02-05", na) + self.assertIn("2014-02-10", na) + self.assertIn("2014-02-17", na) + self.assertIn("2014-07-04", na) + provs = holidays.CA(prov="ON", years=[2014]) + holidays.CA( + prov="BC", years=[2015] + ) + self.assertIn("2015-02-09", provs) + self.assertIn("2015-02-16", provs) + self.assertEqual(provs.prov, ["ON", "BC"]) + a = sum(holidays.CA(prov=x) for x in holidays.CA.PROVINCES) + self.assertEqual(a.country, "CA") + self.assertEqual(a.prov, holidays.CA.PROVINCES) + self.assertIn("2015-02-09", a) + self.assertIn("2015-02-16", a) + na = holidays.CA() + holidays.US() + holidays.MX() + self.assertIn(date(1969, 12, 25), na) + self.assertEqual(na.get(date(1969, 7, 1)), "Dominion Day") + self.assertEqual(na.get(date(1983, 7, 1)), "Canada Day") + self.assertEqual( + na.get(date(1969, 12, 25)), "Christmas Day, Navidad [Christmas]" + ) + na = holidays.MX() + holidays.CA() + holidays.US() + self.assertEqual( + na.get(date(1969, 12, 25)), "Navidad [Christmas], Christmas Day" + ) + + def test_get_list(self): + westland = holidays.NZ(prov="WTL") + chathams = holidays.NZ(prov="CIT") + wild = westland + chathams + self.assertEqual( + wild[date(1969, 12, 1)], + ("Westland Anniversary Day, " + "Chatham Islands Anniversary Day"), + ) + + self.assertEqual( + wild.get_list(date(1969, 12, 1)), + ["Westland Anniversary Day", "Chatham Islands Anniversary Day"], + ) + self.assertEqual(wild.get_list(date(1969, 1, 1)), ["New Year's Day"]) + self.assertEqual( + westland.get_list(date(1969, 12, 1)), ["Westland Anniversary Day"] + ) + self.assertEqual( + westland.get_list(date(1969, 1, 1)), ["New Year's Day"] + ) + self.assertEqual( + chathams.get_list(date(1969, 12, 1)), + ["Chatham Islands Anniversary Day"], + ) + self.assertEqual( + chathams.get_list(date(1969, 1, 1)), ["New Year's Day"] + ) + ca = holidays.CA() + us = holidays.US() + mx = holidays.MX() + na = ca + us + mx + self.assertIn(date(1969, 12, 25), na) + self.assertEqual( + na.get_list(date(1969, 12, 25)), + ["Christmas Day", "Navidad [Christmas]"], + ) + self.assertEqual(na.get_list(date(1969, 7, 1)), ["Dominion Day"]) + self.assertEqual(na.get_list(date(1969, 1, 3)), []) + + def test_list_supported_countries(self): + self.assertIn("AR", holidays.list_supported_countries()) + self.assertIn("ZA", holidays.list_supported_countries()) + + def test_radd(self): + self.assertRaises(TypeError, lambda: 1 + holidays.US()) + + 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.assertIn(date(2014, 10, 13), self.holidays) + self.assertNotIn(date(2014, 10, 13), hdays) + self.assertIn(date(2014, 1, 1), hdays) + self.assertIn(date(2020, 10, 12), self.holidays) + self.assertNotIn(date(2020, 10, 12), hdays) + self.assertIn(date(2020, 1, 1), 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() + self.assertNotIn(date(2014, 7, 13), self.holidays) + self.assertIn(date(2014, 7, 13), hdays) + self.assertIn(date(2014, 1, 1), hdays) + self.assertNotIn(date(2020, 7, 13), self.holidays) + self.assertIn(date(2020, 7, 13), hdays) + self.assertIn(date(2020, 1, 1), hdays) + + class NewCountry(holidays.HolidayBase): + def _populate(self, year): + self[date(year, 1, 2)] = "New New Year's" + + hdays = NewCountry() + self.assertNotIn(date(2014, 1, 1), hdays) + self.assertIn(date(2014, 1, 2), hdays) + + class Dec31Holiday(holidays.HolidayBase): + def _populate(self, year): + self[date(year, 12, 31)] = "New Year's Eve" + + self.assertIn(date(2014, 12, 31), Dec31Holiday()) + + def test_get_named(self): + us = holidays.UnitedStates(years=[2020]) + # check for "New Year's Day" presence in get_named("new") + self.assertIn(date(2020, 1, 1), us.get_named("new")) + + # check for searching holiday in US when the observed holiday is on + # a different year than input one + us = holidays.US(years=[2022]) + us.get_named("Thanksgiving") + self.assertEqual([2022], list(us.years)) + + +class TestArgs(unittest.TestCase): + def setUp(self): + self.holidays = holidays.US() + + def test_country(self): + self.assertEqual(self.holidays.country, "US") + self.assertIn(date(2014, 7, 4), self.holidays) + self.assertNotIn(date(2014, 7, 1), self.holidays) + self.holidays = holidays.UnitedStates() + self.assertEqual(self.holidays.country, "US") + self.assertIn(date(2014, 7, 4), self.holidays) + self.assertNotIn(date(2014, 7, 1), self.holidays) + self.assertEqual(self.holidays.country, "US") + self.holidays = holidays.CA() + self.assertEqual(self.holidays.country, "CA") + self.assertEqual(self.holidays.prov, "ON") + self.assertIn(date(2014, 7, 1), self.holidays) + self.assertNotIn(date(2014, 7, 4), self.holidays) + self.holidays = holidays.CA(prov="BC") + self.assertEqual(self.holidays.country, "CA") + self.assertEqual(self.holidays.prov, "BC") + self.assertIn(date(2014, 7, 1), self.holidays) + self.assertNotIn(date(2014, 7, 4), self.holidays) + + def test_years(self): + self.assertEqual(len(self.holidays.years), 0) + self.assertNotIn(date(2014, 1, 2), self.holidays) + self.assertEqual(len(self.holidays.years), 1) + self.assertIn(2014, self.holidays.years) + self.assertNotIn(date(2013, 1, 2), self.holidays) + self.assertNotIn(date(2014, 1, 2), self.holidays) + self.assertNotIn(date(2015, 1, 2), self.holidays) + self.assertEqual(len(self.holidays.years), 3) + self.assertIn(2013, self.holidays.years) + self.assertIn(2015, self.holidays.years) + self.holidays = holidays.US(years=range(2010, 2015 + 1)) + self.assertEqual(len(self.holidays.years), 6) + self.assertNotIn(2009, self.holidays.years) + self.assertIn(2010, self.holidays.years) + self.assertIn(2015, self.holidays.years) + self.assertNotIn(2016, self.holidays.years) + self.holidays = holidays.US(years=(2013, 2015, 2015)) + self.assertEqual(len(self.holidays.years), 2) + self.assertIn(2013, self.holidays.years) + self.assertNotIn(2014, self.holidays.years) + self.assertIn(2015, self.holidays.years) + self.assertIn(date(2021, 12, 31), holidays.US(years=[2022]).keys()) + self.holidays = holidays.US(years=2015) + self.assertNotIn(2014, self.holidays.years) + self.assertIn(2015, self.holidays.years) + + def test_expand(self): + self.holidays = holidays.US(years=(2013, 2015), expand=False) + self.assertEqual(len(self.holidays.years), 2) + self.assertIn(2013, self.holidays.years) + self.assertNotIn(2014, self.holidays.years) + self.assertIn(2015, self.holidays.years) + self.assertNotIn(date(2014, 1, 1), self.holidays) + self.assertEqual(len(self.holidays.years), 2) + self.assertNotIn(2014, self.holidays.years) + + def test_observed(self): + self.holidays = holidays.US(observed=False) + self.assertIn(date(2000, 1, 1), self.holidays) + self.assertNotIn(date(1999, 12, 31), self.holidays) + self.assertIn(date(2012, 1, 1), self.holidays) + self.assertNotIn(date(2012, 1, 2), self.holidays) + self.holidays.observed = True + self.assertIn(date(2000, 1, 1), self.holidays) + self.assertIn(date(1999, 12, 31), self.holidays) + self.assertIn(date(2012, 1, 1), self.holidays) + self.assertIn(date(2012, 1, 2), self.holidays) + self.holidays.observed = False + self.assertIn(date(2000, 1, 1), self.holidays) + self.assertNotIn(date(1999, 12, 31), self.holidays) + self.assertIn(date(2012, 1, 1), self.holidays) + self.assertNotIn(date(2012, 1, 2), self.holidays) + self.holidays = holidays.US(years=[2022], observed=False) + self.assertNotIn(date(2021, 12, 31), self.holidays.keys()) + + self.holidays = holidays.CA(observed=False) + self.assertNotIn(date(1878, 7, 3), self.holidays) + self.holidays.observed = True + self.assertIn(date(2018, 7, 2), self.holidays) + + +class TestKeyTransforms(unittest.TestCase): + def setUp(self): + self.holidays = holidays.US() + + def test_dates(self): + self.assertIn(date(2014, 1, 1), self.holidays) + self.assertEqual(self.holidays[date(2014, 1, 1)], "New Year's Day") + self.holidays[date(2014, 1, 3)] = "Fake Holiday" + self.assertIn(date(2014, 1, 3), self.holidays) + self.assertEqual(self.holidays.pop(date(2014, 1, 3)), "Fake Holiday") + self.assertNotIn(date(2014, 1, 3), self.holidays) + + def test_datetimes(self): + self.assertIn(datetime(2014, 1, 1, 13, 45), self.holidays) + self.assertEqual( + self.holidays[datetime(2014, 1, 1, 13, 45)], "New Year's Day" + ) + self.holidays[datetime(2014, 1, 3, 1, 1)] = "Fake Holiday" + self.assertIn(datetime(2014, 1, 3, 2, 2), self.holidays) + self.assertEqual( + self.holidays.pop(datetime(2014, 1, 3, 4, 4)), "Fake Holiday" + ) + self.assertNotIn(datetime(2014, 1, 3, 2, 2), self.holidays) + + def test_timestamp(self): + self.assertIn(1388552400, self.holidays) + self.assertEqual(self.holidays[1388552400], "New Year's Day") + self.assertIn(1388552400.01, self.holidays) + self.assertEqual(self.holidays[1388552400.01], "New Year's Day") + self.holidays[1388725200] = "Fake Holiday" + self.assertIn(1388725201, self.holidays) + self.assertEqual(self.holidays.pop(1388725202), "Fake Holiday") + self.assertNotIn(1388725201, self.holidays) + + def test_strings(self): + self.assertIn("2014-01-01", self.holidays) + self.assertEqual(self.holidays["2014-01-01"], "New Year's Day") + self.assertIn("01/01/2014", self.holidays) + self.assertEqual(self.holidays["01/01/2014"], "New Year's Day") + self.holidays["01/03/2014"] = "Fake Holiday" + self.assertIn("01/03/2014", self.holidays) + self.assertEqual(self.holidays.pop("01/03/2014"), "Fake Holiday") + self.assertNotIn("01/03/2014", self.holidays) + + def test_exceptions(self): + self.assertRaises( + (TypeError, ValueError), lambda: "abc" in self.holidays + ) + self.assertRaises( + (TypeError, ValueError), lambda: self.holidays.get("abc123") + ) + self.assertRaises( + (TypeError, ValueError), self.holidays.__setitem__, "abc", "Test" + ) + self.assertRaises((TypeError, ValueError), lambda: {} in self.holidays) + + +class TestCountryHoliday(unittest.TestCase): + def setUp(self): + self.holidays = holidays.CountryHoliday("US") + + def test_country(self): + self.assertEqual(self.holidays.country, "US") + + def test_country_years(self): + h = holidays.CountryHoliday("US", years=[2015, 2016]) + self.assertEqual(h.years, {2015, 2016}) + + def test_country_state(self): + h = holidays.CountryHoliday("US", state="NY") + self.assertEqual(h.state, "NY") + + def test_country_province(self): + h = holidays.CountryHoliday("AU", prov="NT") + self.assertEqual(h.prov, "NT") + + def test_exceptions(self): + self.assertRaises((KeyError), lambda: holidays.CountryHoliday("XXXX")) diff --git a/tests.py b/tests.py index 16a0ce8af..e454b9f2e 100644 --- a/tests.py +++ b/tests.py @@ -11,7016 +11,7 @@ # Website: https://github.com/dr-prodigy/python-holidays # License: MIT (see LICENSE file) -import os -import sys -import unittest -import warnings -from glob import glob -from itertools import product - -from datetime import date, datetime, timedelta -from dateutil.relativedelta import relativedelta, MO -from flake8.api import legacy as flake8 - -import holidays - - -class TestFlake8(unittest.TestCase): - - def test_flake8(self): - """Test that we conform to PEP-8.""" - self.style_guide = flake8.get_style_guide(ignore=['I', 'F401', 'W504']) - self.py_files = [y for x in os.walk(os.path.abspath('holidays')) for y in glob(os.path.join(x[0], '*.py'))] - self.report = self.style_guide.check_files(self.py_files) - self.assertEqual(self.report.get_statistics('E'), []) - - -class TestBasics(unittest.TestCase): - - def setUp(self): - self.holidays = holidays.US() - - def test_contains(self): - self.assertIn(date(2014, 1, 1), self.holidays) - self.assertNotIn(date(2014, 1, 2), self.holidays) - - def test_getitem(self): - self.assertEqual(self.holidays[date(2014, 1, 1)], "New Year's Day") - self.assertEqual(self.holidays.get(date(2014, 1, 1)), "New Year's Day") - self.assertRaises(KeyError, lambda: self.holidays[date(2014, 1, 2)]) - self.assertIsNone(self.holidays.get(date(2014, 1, 2))) - - self.assertListEqual( - self.holidays[date(2013, 12, 31): date(2014, 1, 2)], - [date(2014, 1, 1)] - ) - self.assertListEqual( - self.holidays[date(2013, 12, 24): date(2014, 1, 2)], - [date(2013, 12, 25), date(2014, 1, 1)] - ) - self.assertListEqual( - self.holidays[date(2013, 12, 25): date(2014, 1, 2): 3], - [date(2013, 12, 25)] - ) - self.assertListEqual( - self.holidays[date(2013, 12, 25): date(2014, 1, 2): 7], - [date(2013, 12, 25), date(2014, 1, 1)] - ) - self.assertListEqual( - self.holidays[date(2014, 1, 2): date(2013, 12, 30)], - [date(2014, 1, 1)] - ) - self.assertListEqual( - self.holidays[date(2014, 1, 2): date(2013, 12, 25)], - [date(2014, 1, 1)] - ) - self.assertListEqual( - self.holidays[date(2014, 1, 2): date(2013, 12, 24)], - [date(2014, 1, 1), date(2013, 12, 25)] - ) - self.assertListEqual( - self.holidays[date(2014, 1, 1): date(2013, 12, 24): 3], - [date(2014, 1, 1)] - ) - self.assertListEqual( - self.holidays[date(2014, 1, 1): date(2013, 12, 24): 7], - [date(2014, 1, 1), date(2013, 12, 25)] - ) - self.assertListEqual( - self.holidays[date(2013, 12, 31): date(2014, 1, 2): -3], - [] - ) - self.assertListEqual( - self.holidays[ - date(2014, 1, 1): date(2013, 12, 24): timedelta(days=3) - ], - [date(2014, 1, 1)] - ) - self.assertListEqual( - self.holidays[ - date(2014, 1, 1): date(2013, 12, 24): timedelta(days=7) - ], - [date(2014, 1, 1), date(2013, 12, 25)] - ) - self.assertListEqual( - self.holidays[ - date(2013, 12, 31): date(2014, 1, 2): timedelta(days=3) - ], - [] - ) - self.assertRaises(ValueError, lambda: self.holidays[date(2014, 1, 1):]) - self.assertRaises(ValueError, lambda: self.holidays[:date(2014, 1, 1)]) - self.assertRaises( - TypeError, - lambda: self.holidays[date(2014, 1, 1): date(2014, 1, 2): ''] - ) - self.assertRaises( - ValueError, - lambda: self.holidays[date(2014, 1, 1): date(2014, 1, 2): 0] - ) - - def test_get(self): - self.assertEqual(self.holidays.get('2014-01-01'), "New Year's Day") - self.assertIsNone(self.holidays.get('2014-01-02')) - self.assertFalse(self.holidays.get('2014-01-02', False)) - self.assertTrue(self.holidays.get('2014-01-02', True)) - - def test_pop(self): - self.assertRaises(KeyError, lambda: self.holidays.pop('2014-01-02')) - self.assertFalse(self.holidays.pop('2014-01-02', False)) - self.assertTrue(self.holidays.pop('2014-01-02', True)) - self.assertIn(date(2014, 1, 1), self.holidays) - self.assertEqual(self.holidays.pop('2014-01-01'), "New Year's Day") - self.assertNotIn(date(2014, 1, 1), self.holidays) - self.assertIn(date(2014, 7, 4), self.holidays) - - def test_pop_named(self): - self.assertIn(date(2014, 1, 1), self.holidays) - self.holidays.pop_named("New Year's Day") - self.assertNotIn(date(2014, 1, 1), self.holidays) - self.assertRaises(KeyError, - lambda: self.holidays.pop_named("New Year's Dayz")) - - def test_setitem(self): - self.holidays = holidays.US(years=[2014]) - self.assertEqual(len(self.holidays), 10) - self.holidays[date(2014, 1, 3)] = "Fake Holiday" - self.assertEqual(len(self.holidays), 11) - self.assertIn(date(2014, 1, 3), self.holidays) - self.assertEqual(self.holidays.get(date(2014, 1, 3)), "Fake Holiday") - - def test_update(self): - h = holidays.HolidayBase() - h.update({ - date(2015, 1, 1): "New Year's Day", - '2015-12-25': "Christmas Day", - }) - self.assertIn('2015-01-01', h) - self.assertIn(date(2015, 12, 25), h) - - def test_append(self): - h = holidays.HolidayBase() - h.update({ - date(2015, 1, 1): "New Year's Day", - '2015-12-25': "Christmas Day", - }) - h.append([date(2015, 4, 1), '2015-04-03']) - h.append(date(2015, 4, 6)) - h.append('2015-04-07') - self.assertIn('2015-01-01', h) - self.assertIn(date(2015, 12, 25), h) - self.assertIn('2015-04-01', h) - self.assertNotIn('2015-04-02', h) - self.assertIn('2015-04-03', h) - self.assertNotIn('2015-04-04', h) - self.assertNotIn('2015-04-05', h) - self.assertIn('2015-04-06', h) - self.assertIn('2015-04-07', h) - - def test_eq_ne(self): - us1 = holidays.UnitedStates() - us2 = holidays.US() - us3 = holidays.UnitedStates(years=[2014]) - us4 = holidays.US(years=[2014]) - ca1 = holidays.Canada() - ca2 = holidays.CA() - ca3 = holidays.Canada(years=[2014]) - ca4 = holidays.CA(years=[2014]) - self.assertEqual(us1, us2) - self.assertEqual(us3, us4) - self.assertEqual(ca1, ca2) - self.assertEqual(ca3, ca4) - self.assertNotEqual(us1, us3) - self.assertNotEqual(us1, ca1) - self.assertNotEqual(us3, ca3) - self.assertNotEqual(us1, us3) - - def test_add(self): - ca = holidays.CA() - us = holidays.US() - mx = holidays.MX() - na = ca + (us + mx) - self.assertNotIn('2014-07-01', us) - self.assertIn('2014-07-01', ca) - self.assertNotIn('2014-07-04', ca) - self.assertIn('2014-07-04', us) - self.assertIn('2014-07-04', ca + us) - self.assertIn('2014-07-04', us + ca) - self.assertIn('2015-07-04', ca + us) - self.assertIn('2015-07-04', us + ca) - self.assertIn('2015-07-01', ca + us) - self.assertIn('2015-07-01', us + ca) - self.assertIn('2014-07-04', na) - self.assertIn('2015-07-04', na) - self.assertIn('2015-07-01', na) - self.assertIn('2000-02-05', na) - self.assertEqual((ca + us).prov, 'ON') - self.assertEqual((us + ca).prov, 'ON') - ca = holidays.CA(years=[2014], expand=False) - us = holidays.US(years=[2014, 2015], expand=True) - self.assertTrue((ca + us).expand) - self.assertEqual((ca + us).years, {2014, 2015}) - self.assertEqual((us + ca).years, {2014, 2015}) - na = holidays.CA() - na += holidays.US() - na += holidays.MX() - self.assertEqual(na.country, ['CA', 'US', 'MX']) - self.assertIn('2014-07-04', na) - self.assertIn('2014-07-04', na) - self.assertIn('2015-07-04', na) - self.assertIn('2015-07-04', na) - self.assertIn('2015-07-01', na) - self.assertIn('2015-07-01', na) - self.assertIn('2000-02-05', na) - self.assertEqual(na.prov, 'ON') - na = holidays.CA() + holidays.US() - na += holidays.MX() - self.assertIn('2014-07-04', na) - self.assertIn('2014-07-04', na) - self.assertIn('2015-07-04', na) - self.assertIn('2015-07-04', na) - self.assertIn('2015-07-01', na) - self.assertIn('2015-07-01', na) - self.assertIn('2000-02-05', na) - self.assertEqual(na.prov, 'ON') - self.assertRaises(TypeError, lambda: holidays.US() + {}) - na = ca + (us + mx) + ca + (mx + us + holidays.CA(prov='BC')) - self.assertIn('2000-02-05', na) - self.assertIn('2014-02-10', na) - self.assertIn('2014-02-17', na) - self.assertIn('2014-07-04', na) - provs = (holidays.CA(prov='ON', years=[2014]) + - holidays.CA(prov='BC', years=[2015])) - self.assertIn("2015-02-09", provs) - self.assertIn("2015-02-16", provs) - self.assertEqual(provs.prov, ['ON', 'BC']) - a = sum(holidays.CA(prov=x) for x in holidays.CA.PROVINCES) - self.assertEqual(a.country, 'CA') - self.assertEqual(a.prov, holidays.CA.PROVINCES) - self.assertIn("2015-02-09", a) - self.assertIn("2015-02-16", a) - na = holidays.CA() + holidays.US() + holidays.MX() - self.assertIn(date(1969, 12, 25), na) - self.assertEqual(na.get(date(1969, 7, 1)), "Dominion Day") - self.assertEqual(na.get(date(1983, 7, 1)), "Canada Day") - self.assertEqual(na.get(date(1969, 12, 25)), - "Christmas Day, Navidad [Christmas]") - na = holidays.MX() + holidays.CA() + holidays.US() - self.assertEqual(na.get(date(1969, 12, 25)), - "Navidad [Christmas], Christmas Day") - - def test_get_list(self): - westland = holidays.NZ(prov='WTL') - chathams = holidays.NZ(prov='CIT') - wild = westland + chathams - self.assertEqual(wild[date(1969, 12, 1)], - ("Westland Anniversary Day, " + - "Chatham Islands Anniversary Day")) - - self.assertEqual(wild.get_list(date(1969, 12, 1)), - ["Westland Anniversary Day", - "Chatham Islands Anniversary Day"]) - self.assertEqual(wild.get_list(date(1969, 1, 1)), - ["New Year's Day"]) - self.assertEqual(westland.get_list(date(1969, 12, 1)), - ["Westland Anniversary Day"]) - self.assertEqual(westland.get_list(date(1969, 1, 1)), - ["New Year's Day"]) - self.assertEqual(chathams.get_list(date(1969, 12, 1)), - ["Chatham Islands Anniversary Day"]) - self.assertEqual(chathams.get_list(date(1969, 1, 1)), - ["New Year's Day"]) - ca = holidays.CA() - us = holidays.US() - mx = holidays.MX() - na = ca + us + mx - self.assertIn(date(1969, 12, 25), na) - self.assertEqual(na.get_list(date(1969, 12, 25)), - ["Christmas Day", "Navidad [Christmas]"]) - self.assertEqual(na.get_list(date(1969, 7, 1)), ["Dominion Day"]) - self.assertEqual(na.get_list(date(1969, 1, 3)), []) - - def test_list_supported_countries(self): - self.assertIn("AR", holidays.list_supported_countries()) - self.assertIn("ZA", holidays.list_supported_countries()) - - def test_radd(self): - self.assertRaises(TypeError, lambda: 1 + holidays.US()) - - 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.assertIn(date(2014, 10, 13), self.holidays) - self.assertNotIn(date(2014, 10, 13), hdays) - self.assertIn(date(2014, 1, 1), hdays) - self.assertIn(date(2020, 10, 12), self.holidays) - self.assertNotIn(date(2020, 10, 12), hdays) - self.assertIn(date(2020, 1, 1), 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() - self.assertNotIn(date(2014, 7, 13), self.holidays) - self.assertIn(date(2014, 7, 13), hdays) - self.assertIn(date(2014, 1, 1), hdays) - self.assertNotIn(date(2020, 7, 13), self.holidays) - self.assertIn(date(2020, 7, 13), hdays) - self.assertIn(date(2020, 1, 1), hdays) - - class NewCountry(holidays.HolidayBase): - def _populate(self, year): - self[date(year, 1, 2)] = "New New Year's" - - hdays = NewCountry() - self.assertNotIn(date(2014, 1, 1), hdays) - self.assertIn(date(2014, 1, 2), hdays) - - class Dec31Holiday(holidays.HolidayBase): - def _populate(self, year): - self[date(year, 12, 31)] = "New Year's Eve" - - self.assertIn(date(2014, 12, 31), Dec31Holiday()) - - def test_get_named(self): - us = holidays.UnitedStates(years=[2020]) - # check for "New Year's Day" presence in get_named("new") - self.assertIn(date(2020, 1, 1), us.get_named('new')) - - # check for searching holiday in US when the observed holiday is on a different year than input one - us = holidays.US(years=[2022]) - us.get_named("Thanksgiving") - self.assertEqual([2022], list(us.years)) - - -class TestArgs(unittest.TestCase): - - def setUp(self): - self.holidays = holidays.US() - - def test_country(self): - self.assertEqual(self.holidays.country, 'US') - self.assertIn(date(2014, 7, 4), self.holidays) - self.assertNotIn(date(2014, 7, 1), self.holidays) - self.holidays = holidays.UnitedStates() - self.assertEqual(self.holidays.country, 'US') - self.assertIn(date(2014, 7, 4), self.holidays) - self.assertNotIn(date(2014, 7, 1), self.holidays) - self.assertEqual(self.holidays.country, 'US') - self.holidays = holidays.CA() - self.assertEqual(self.holidays.country, 'CA') - self.assertEqual(self.holidays.prov, 'ON') - self.assertIn(date(2014, 7, 1), self.holidays) - self.assertNotIn(date(2014, 7, 4), self.holidays) - self.holidays = holidays.CA(prov='BC') - self.assertEqual(self.holidays.country, 'CA') - self.assertEqual(self.holidays.prov, 'BC') - self.assertIn(date(2014, 7, 1), self.holidays) - self.assertNotIn(date(2014, 7, 4), self.holidays) - - def test_years(self): - self.assertEqual(len(self.holidays.years), 0) - self.assertNotIn(date(2014, 1, 2), self.holidays) - self.assertEqual(len(self.holidays.years), 1) - self.assertIn(2014, self.holidays.years) - self.assertNotIn(date(2013, 1, 2), self.holidays) - self.assertNotIn(date(2014, 1, 2), self.holidays) - self.assertNotIn(date(2015, 1, 2), self.holidays) - self.assertEqual(len(self.holidays.years), 3) - self.assertIn(2013, self.holidays.years) - self.assertIn(2015, self.holidays.years) - self.holidays = holidays.US(years=range(2010, 2015 + 1)) - self.assertEqual(len(self.holidays.years), 6) - self.assertNotIn(2009, self.holidays.years) - self.assertIn(2010, self.holidays.years) - self.assertIn(2015, self.holidays.years) - self.assertNotIn(2016, self.holidays.years) - self.holidays = holidays.US(years=(2013, 2015, 2015)) - self.assertEqual(len(self.holidays.years), 2) - self.assertIn(2013, self.holidays.years) - self.assertNotIn(2014, self.holidays.years) - self.assertIn(2015, self.holidays.years) - self.assertIn(date(2021, 12, 31), holidays.US(years=[2022]).keys()) - self.holidays = holidays.US(years=2015) - self.assertNotIn(2014, self.holidays.years) - self.assertIn(2015, self.holidays.years) - - def test_expand(self): - self.holidays = holidays.US(years=(2013, 2015), expand=False) - self.assertEqual(len(self.holidays.years), 2) - self.assertIn(2013, self.holidays.years) - self.assertNotIn(2014, self.holidays.years) - self.assertIn(2015, self.holidays.years) - self.assertNotIn(date(2014, 1, 1), self.holidays) - self.assertEqual(len(self.holidays.years), 2) - self.assertNotIn(2014, self.holidays.years) - - def test_observed(self): - self.holidays = holidays.US(observed=False) - self.assertIn(date(2000, 1, 1), self.holidays) - self.assertNotIn(date(1999, 12, 31), self.holidays) - self.assertIn(date(2012, 1, 1), self.holidays) - self.assertNotIn(date(2012, 1, 2), self.holidays) - self.holidays.observed = True - self.assertIn(date(2000, 1, 1), self.holidays) - self.assertIn(date(1999, 12, 31), self.holidays) - self.assertIn(date(2012, 1, 1), self.holidays) - self.assertIn(date(2012, 1, 2), self.holidays) - self.holidays.observed = False - self.assertIn(date(2000, 1, 1), self.holidays) - self.assertNotIn(date(1999, 12, 31), self.holidays) - self.assertIn(date(2012, 1, 1), self.holidays) - self.assertNotIn(date(2012, 1, 2), self.holidays) - self.holidays = holidays.US(years=[2022], observed=False) - self.assertNotIn(date(2021, 12, 31), self.holidays.keys()) - - self.holidays = holidays.CA(observed=False) - self.assertNotIn(date(1878, 7, 3), self.holidays) - self.holidays.observed = True - self.assertIn(date(2018, 7, 2), self.holidays) - - -class TestKeyTransforms(unittest.TestCase): - - def setUp(self): - self.holidays = holidays.US() - - def test_dates(self): - self.assertIn(date(2014, 1, 1), self.holidays) - self.assertEqual(self.holidays[date(2014, 1, 1)], "New Year's Day") - self.holidays[date(2014, 1, 3)] = "Fake Holiday" - self.assertIn(date(2014, 1, 3), self.holidays) - self.assertEqual(self.holidays.pop(date(2014, 1, 3)), "Fake Holiday") - self.assertNotIn(date(2014, 1, 3), self.holidays) - - def test_datetimes(self): - self.assertIn(datetime(2014, 1, 1, 13, 45), self.holidays) - self.assertEqual(self.holidays[datetime(2014, 1, 1, 13, 45)], - "New Year's Day") - self.holidays[datetime(2014, 1, 3, 1, 1)] = "Fake Holiday" - self.assertIn(datetime(2014, 1, 3, 2, 2), self.holidays) - self.assertEqual(self.holidays.pop(datetime(2014, 1, 3, 4, 4)), - "Fake Holiday") - self.assertNotIn(datetime(2014, 1, 3, 2, 2), self.holidays) - - def test_timestamp(self): - self.assertIn(1388552400, self.holidays) - self.assertEqual(self.holidays[1388552400], "New Year's Day") - self.assertIn(1388552400.01, self.holidays) - self.assertEqual(self.holidays[1388552400.01], "New Year's Day") - self.holidays[1388725200] = "Fake Holiday" - self.assertIn(1388725201, self.holidays) - self.assertEqual(self.holidays.pop(1388725202), "Fake Holiday") - self.assertNotIn(1388725201, self.holidays) - - def test_strings(self): - self.assertIn("2014-01-01", self.holidays) - self.assertEqual(self.holidays["2014-01-01"], "New Year's Day") - self.assertIn("01/01/2014", self.holidays) - self.assertEqual(self.holidays["01/01/2014"], "New Year's Day") - self.holidays["01/03/2014"] = "Fake Holiday" - self.assertIn("01/03/2014", self.holidays) - self.assertEqual(self.holidays.pop("01/03/2014"), "Fake Holiday") - self.assertNotIn("01/03/2014", self.holidays) - - def test_exceptions(self): - self.assertRaises( - (TypeError, ValueError), lambda: "abc" in self.holidays) - self.assertRaises( - (TypeError, ValueError), lambda: self.holidays.get("abc123")) - self.assertRaises( - (TypeError, ValueError), self.holidays.__setitem__, "abc", "Test") - self.assertRaises( - (TypeError, ValueError), lambda: {} in self.holidays) - - -class TestCountryHoliday(unittest.TestCase): - - def setUp(self): - self.holidays = holidays.CountryHoliday('US') - - def test_country(self): - self.assertEqual(self.holidays.country, 'US') - - def test_country_years(self): - h = holidays.CountryHoliday('US', years=[2015, 2016]) - self.assertEqual(h.years, {2015, 2016}) - - def test_country_state(self): - h = holidays.CountryHoliday('US', state='NY') - self.assertEqual(h.state, 'NY') - - def test_country_province(self): - h = holidays.CountryHoliday('AU', prov='NT') - self.assertEqual(h.prov, 'NT') - - def test_exceptions(self): - self.assertRaises((KeyError), lambda: holidays.CountryHoliday('XXXX')) - - -class TestAruba(unittest.TestCase): - - def setUp(self): - self.holidays = holidays.AW() - - def test_2017(self): - self.assertIn(date(2017, 1, 1), self.holidays) - self.assertIn(date(2017, 1, 25), self.holidays) - self.assertIn(date(2017, 3, 18), self.holidays) - self.assertIn(date(2017, 2, 27), self.holidays) - self.assertIn(date(2017, 4, 14), self.holidays) - self.assertIn(date(2017, 4, 17), self.holidays) - self.assertIn(date(2017, 4, 27), self.holidays) - self.assertIn(date(2017, 5, 1), self.holidays) - self.assertIn(date(2017, 5, 25), self.holidays) - self.assertIn(date(2017, 12, 25), self.holidays) - self.assertIn(date(2017, 12, 26), self.holidays) - - def test_new_years(self): - self.assertIn(date(2017, 1, 1), self.holidays) - - def test_betico_day(self): - self.assertIn(date(2017, 1, 25), self.holidays) - - def test_carnaval_monday(self): - self.assertIn(date(2017, 2, 27), self.holidays) - - def test_anthem_and_flag_day(self): - self.assertIn(date(2017, 3, 18), self.holidays) - - def test_good_friday(self): - self.assertIn(date(2017, 4, 14), self.holidays) - - def test_easter_monday(self): - self.assertIn(date(2017, 4, 17), self.holidays) - - def test_labour_day(self): - self.assertIn(date(2017, 5, 1), self.holidays) - - def test_queens_day_between_1891_and_1948(self): - # Between 1891 and 1948 Queens Day was celebrated on 8-31 - self.holidays = holidays.AW(years=[1901]) - self.assertIn(date(1901, 8, 31), self.holidays) - - def test_queens_day_between_1891_and_1948_substituted_later(self): - # Between 1891 and 1948 Queens Day was celebrated on 9-1 - # (one day later) when Queens Day falls on a Sunday - self.holidays = holidays.AW(years=[1947]) - self.assertIn(date(1947, 9, 1), self.holidays) - - def test_queens_day_between_1949_and_2013(self): - self.holidays = holidays.AW(years=[1965]) - self.assertIn(date(1965, 4, 30), self.holidays) - - def test_queens_day_between_1949_and_1980_substituted_later(self): - self.holidays = holidays.AW(years=[1967]) - self.assertIn(date(1967, 5, 1), self.holidays) - - def test_queens_day_between_1980_and_2013_substituted_earlier(self): - self.holidays = holidays.AW(years=[2006]) - self.assertIn(date(2006, 4, 29), self.holidays) - - def test_kings_day_after_2014(self): - self.holidays = holidays.AW(years=[2013]) - self.assertNotIn(date(2013, 4, 27), self.holidays) - - self.holidays = holidays.AW(years=[2017]) - self.assertIn(date(2017, 4, 27), self.holidays) - - def test_kings_day_after_2014_substituted_earlier(self): - self.holidays = holidays.AW(years=[2188]) - self.assertIn(date(2188, 4, 26), self.holidays) - - def test_ascension_day(self): - self.holidays = holidays.AW(years=2017) - self.assertIn(date(2017, 5, 25), self.holidays) - - def test_christmas(self): - self.holidays = holidays.AW(years=2017) - self.assertIn(date(2017, 12, 25), self.holidays) - - def test_second_christmas(self): - self.holidays = holidays.AW(years=2017) - self.assertIn(date(2017, 12, 26), self.holidays) - - -class TestBulgaria(unittest.TestCase): - - def setUp(self): - self.holidays = holidays.Bulgaria() - - def test_before_1990(self): - self.assertEqual(len(holidays.Bulgaria(years=[1989])), 0) - - def test_new_years_day(self): - for year in range(1990, 2020): - self.assertIn(date(year, 1, 1), self.holidays) - - def test_liberation_day(self): - for year in range(1990, 2020): - self.assertIn(date(year, 3, 3), self.holidays) - - def test_labour_day(self): - for year in range(1990, 2020): - self.assertIn(date(year, 5, 1), self.holidays) - - def test_saint_georges_day(self): - for year in range(1990, 2020): - self.assertIn(date(year, 5, 6), self.holidays) - - def test_twenty_fourth_of_may(self): - for year in range(1990, 2020): - self.assertIn(date(year, 5, 24), self.holidays) - - def test_unification_day(self): - for year in range(1990, 2020): - self.assertIn(date(year, 9, 6), self.holidays) - - def test_independence_day(self): - for year in range(1990, 2020): - self.assertIn(date(year, 9, 22), self.holidays) - - def test_national_awakening_day(self): - for year in range(1990, 2020): - self.assertIn(date(year, 11, 1), self.holidays) - - def test_christmas(self): - for year in range(1990, 2020): - self.assertIn(date(year, 12, 24), self.holidays) - self.assertIn(date(year, 12, 25), self.holidays) - self.assertIn(date(year, 12, 26), self.holidays) - - def test_easter(self): - for year, month, day in [ - (2000, 4, 30), (2001, 4, 15), (2002, 5, 5), (2003, 4, 27), - (2004, 4, 11), (2005, 5, 1), (2006, 4, 23), (2007, 4, 8), - (2008, 4, 27), (2009, 4, 19), (2010, 4, 4), (2011, 4, 24), - (2012, 4, 15), (2013, 5, 5), (2014, 4, 20), (2015, 4, 12), - (2016, 5, 1), (2017, 4, 16), (2018, 4, 8), (2019, 4, 28), - (2020, 4, 19), (2021, 5, 2), (2022, 4, 24)]: - easter = date(year, month, day) - easter_saturday = easter - timedelta(days=1) - easter_friday = easter - timedelta(days=2) - for holiday in [easter_friday, easter_saturday, easter]: - self.assertIn(holiday, self.holidays) - - -class TestCA(unittest.TestCase): - - def setUp(self): - self.holidays = holidays.CA(observed=False) - - def test_new_years(self): - self.assertNotIn(date(2010, 12, 31), self.holidays) - self.assertNotIn(date(2017, 1, 2), self.holidays) - self.holidays.observed = True - self.assertIn(date(2010, 12, 31), self.holidays) - self.assertIn(date(2017, 1, 2), self.holidays) - self.holidays.observed = False - for year in range(1900, 2100): - dt = date(year, 1, 1) - self.assertIn(dt, self.holidays) - self.assertNotIn(dt + relativedelta(days=-1), self.holidays) - self.assertNotIn(dt + relativedelta(days=+1), self.holidays) - - def test_islander_day(self): - pei_holidays = holidays.CA(prov="PE") - for dt in [date(2009, 2, 9), date(2010, 2, 15), date(2011, 2, 21), - date(2012, 2, 20), date(2013, 2, 18), date(2014, 2, 17), - date(2015, 2, 16), date(2016, 2, 15), date(2020, 2, 17)]: - if dt.year >= 2010: - self.assertNotEqual(self.holidays[dt], "Islander Day") - elif dt.year == 2009: - self.assertNotIn(dt, self.holidays) - self.assertIn(dt, pei_holidays) - self.assertNotIn(dt + relativedelta(days=-1), pei_holidays) - self.assertNotIn(dt + relativedelta(days=+1), pei_holidays) - - def test_family_day(self): - ab_holidays = holidays.CA(prov="AB") - bc_holidays = holidays.CA(prov="BC") - mb_holidays = holidays.CA(prov="MB") - sk_holidays = holidays.CA(prov="SK") - nb_holidays = holidays.CA(prov="NB") - for dt in [date(1990, 2, 19), date(1999, 2, 15), date(2000, 2, 21), - date(2006, 2, 20)]: - self.assertNotIn(dt, self.holidays) - self.assertIn(dt, ab_holidays) - self.assertNotIn(dt, bc_holidays) - self.assertNotIn(dt, mb_holidays) - self.assertNotIn(dt, sk_holidays) - dt = date(2007, 2, 19) - self.assertNotIn(dt, self.holidays) - self.assertIn(dt, ab_holidays) - self.assertNotIn(dt, bc_holidays) - self.assertNotIn(dt, mb_holidays) - self.assertIn(dt, sk_holidays) - for dt in [date(2008, 2, 18), date(2012, 2, 20), date(2014, 2, 17), - date(2018, 2, 19)]: - self.assertIn(dt, self.holidays) - self.assertIn(dt, ab_holidays) - self.assertNotIn(dt, bc_holidays) - self.assertIn(dt, mb_holidays) - self.assertIn(dt, sk_holidays) - for dt in [date(2018, 2, 19)]: - self.assertIn(dt, nb_holidays) - for dt in [date(2019, 2, 18), date(2020, 2, 17)]: - self.assertIn(dt, self.holidays) - self.assertIn(dt, ab_holidays) - self.assertIn(dt, bc_holidays) - self.assertIn(dt, mb_holidays) - self.assertIn(dt, sk_holidays) - for dt in [date(2013, 2, 11), date(2016, 2, 8)]: - self.assertNotIn(dt, self.holidays) - self.assertNotIn(dt, ab_holidays) - self.assertIn(dt, bc_holidays) - self.assertNotIn(dt, mb_holidays) - self.assertNotIn(dt, sk_holidays) - self.assertEqual(mb_holidays[date(2014, 2, 17)], "Louis Riel Day") - - def test_st_patricks_day(self): - nl_holidays = holidays.CA(prov="NL", observed=False) - for dt in [date(1900, 3, 19), date(1999, 3, 15), date(2000, 3, 20), - date(2012, 3, 19), date(2013, 3, 18), date(2014, 3, 17), - date(2015, 3, 16), date(2016, 3, 14), date(2020, 3, 16)]: - self.assertNotIn(dt, self.holidays) - self.assertIn(dt, nl_holidays) - self.assertNotIn(dt + relativedelta(days=-1), nl_holidays) - self.assertNotIn(dt + relativedelta(days=+1), nl_holidays) - - def test_good_friday(self): - qc_holidays = holidays.CA(prov="QC") - 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.assertIn(dt, self.holidays) - self.assertNotIn(dt + relativedelta(days=-1), self.holidays) - self.assertNotIn(dt + relativedelta(days=+1), self.holidays) - self.assertNotIn(dt, qc_holidays) - - def test_easter_monday(self): - qc_holidays = holidays.CA(prov="QC") - for dt in [date(1900, 4, 16), date(1901, 4, 8), date(1902, 3, 31), - date(1999, 4, 5), date(2000, 4, 24), date(2010, 4, 5), - date(2018, 4, 2), date(2019, 4, 22), date(2020, 4, 13)]: - self.assertNotIn(dt, self.holidays) - self.assertIn(dt, qc_holidays) - self.assertNotIn(dt + relativedelta(days=-1), qc_holidays) - self.assertNotIn(dt + relativedelta(days=+1), qc_holidays) - - def test_st_georges_day(self): - nl_holidays = holidays.CA(prov="NL") - for dt in [date(1990, 4, 23), date(1999, 4, 26), date(2000, 4, 24), - date(2010, 4, 19), date(2016, 4, 25), date(2020, 4, 20)]: - self.assertNotIn(dt, self.holidays) - self.assertIn(dt, nl_holidays) - self.assertNotIn(dt + relativedelta(days=-1), nl_holidays) - self.assertNotIn(dt + relativedelta(days=+1), nl_holidays) - - def test_victoria_day(self): - for dt in [date(1953, 5, 18), date(1999, 5, 24), date(2000, 5, 22), - date(2010, 5, 24), date(2015, 5, 18), date(2020, 5, 18)]: - self.assertIn(dt, self.holidays) - self.assertNotIn(dt + relativedelta(days=-1), self.holidays) - self.assertNotIn(dt + relativedelta(days=+1), self.holidays) - - def test_national_aboriginal_day(self): - nt_holidays = holidays.CA(prov="NT") - self.assertNotIn(date(1995, 6, 21), nt_holidays) - for year in range(1996, 2100): - dt = date(year, 6, 21) - self.assertNotIn(dt, self.holidays) - self.assertIn(dt, nt_holidays) - self.assertNotIn(dt + relativedelta(days=-1), nt_holidays) - self.assertNotIn(dt + relativedelta(days=+1), nt_holidays) - - def test_st_jean_baptiste_day(self): - qc_holidays = holidays.CA(prov="QC", observed=False) - self.assertNotIn(date(1924, 6, 24), qc_holidays) - for year in range(1925, 2100): - dt = date(year, 6, 24) - self.assertNotIn(dt, self.holidays) - self.assertIn(dt, qc_holidays) - self.assertNotIn(dt + relativedelta(days=-1), qc_holidays) - self.assertNotIn(dt + relativedelta(days=+1), qc_holidays) - self.assertNotIn(date(2001, 6, 25), qc_holidays) - qc_holidays.observed = True - self.assertIn(date(2001, 6, 25), qc_holidays) - - def test_discovery_day(self): - nl_holidays = holidays.CA(prov="NL") - yt_holidays = holidays.CA(prov="YT") - for dt in [date(1997, 6, 23), date(1999, 6, 21), date(2000, 6, 26), - date(2010, 6, 21), date(2016, 6, 27), date(2020, 6, 22)]: - self.assertNotIn(dt, self.holidays) - self.assertIn(dt, nl_holidays) - self.assertNotIn(dt, yt_holidays) - for dt in [date(1912, 8, 19), date(1999, 8, 16), date(2000, 8, 21), - date(2006, 8, 21), date(2016, 8, 15), date(2020, 8, 17)]: - self.assertNotIn(dt, self.holidays) - self.assertNotIn(dt, nl_holidays) - self.assertIn(dt, yt_holidays) - - def test_canada_day(self): - for year in range(1900, 2100): - dt = date(year, 7, 1) - self.assertIn(dt, self.holidays) - self.assertNotIn(dt + relativedelta(days=-1), self.holidays) - self.assertNotIn(dt + relativedelta(days=+1), self.holidays) - self.assertNotIn(date(2006, 7, 3), self.holidays) - self.assertNotIn(date(2007, 7, 2), self.holidays) - self.holidays.observed = True - self.assertIn(date(2006, 7, 3), self.holidays) - self.assertIn(date(2007, 7, 2), self.holidays) - - def test_nunavut_day(self): - nu_holidays = holidays.CA(prov="NU", observed=False) - self.assertNotIn(date(1999, 7, 9), nu_holidays) - self.assertNotIn(date(2000, 7, 9), nu_holidays) - self.assertIn(date(2000, 4, 1), nu_holidays) - for year in range(2001, 2100): - dt = date(year, 7, 9) - self.assertNotIn(dt, self.holidays) - self.assertIn(dt, nu_holidays) - self.assertNotIn(dt + relativedelta(days=-1), nu_holidays) - self.assertNotIn(dt + relativedelta(days=+1), nu_holidays) - self.assertNotIn(date(2017, 7, 10), nu_holidays) - nu_holidays.observed = True - self.assertIn(date(2017, 7, 10), nu_holidays) - - def test_civic_holiday(self): - bc_holidays = holidays.CA(prov="BC") - for dt in [date(1900, 8, 6), date(1955, 8, 1), date(1973, 8, 6)]: - self.assertIn(dt, self.holidays) - self.assertNotIn(dt, bc_holidays) - for dt in [date(1974, 8, 5), date(1999, 8, 2), date(2000, 8, 7), - date(2010, 8, 2), date(2015, 8, 3), date(2020, 8, 3)]: - self.assertIn(dt, self.holidays) - self.assertIn(dt, bc_holidays) - - def test_labour_day(self): - self.assertNotIn(date(1893, 9, 4), self.holidays) - for dt in [date(1894, 9, 3), date(1900, 9, 3), date(1999, 9, 6), - date(2000, 9, 4), date(2014, 9, 1), date(2015, 9, 7)]: - self.assertIn(dt, self.holidays) - self.assertNotIn(dt + relativedelta(days=-1), self.holidays) - self.assertNotIn(dt + relativedelta(days=+1), self.holidays) - - def test_thanksgiving(self): - ns_holidays = holidays.CA(prov="NB") - for dt in [date(1931, 10, 12), date(1990, 10, 8), date(1999, 10, 11), - date(2000, 10, 9), date(2013, 10, 14), date(2020, 10, 12)]: - self.assertIn(dt, self.holidays) - self.assertNotIn(dt + relativedelta(days=-1), self.holidays) - self.assertNotIn(dt + relativedelta(days=+1), self.holidays) - self.assertNotIn(dt, ns_holidays) - - def test_remembrance_day(self): - ab_holidays = holidays.CA(prov="AB", observed=False) - nl_holidays = holidays.CA(prov="NL", observed=False) - self.assertNotIn(date(1930, 11, 11), ab_holidays) - self.assertNotIn(date(1930, 11, 11), nl_holidays) - for year in range(1931, 2100): - dt = date(year, 11, 11) - self.assertNotIn(dt, self.holidays) - self.assertIn(dt, ab_holidays) - self.assertIn(dt, nl_holidays) - self.assertNotIn(dt + relativedelta(days=-1), nl_holidays) - self.assertNotIn(dt + relativedelta(days=+1), nl_holidays) - self.assertNotIn(date(2007, 11, 12), ab_holidays) - self.assertNotIn(date(2007, 11, 12), nl_holidays) - ab_holidays.observed = True - nl_holidays.observed = True - self.assertNotIn(date(2007, 11, 12), ab_holidays) - self.assertIn(date(2007, 11, 12), nl_holidays) - - def test_christmas_day(self): - for year in range(1900, 2100): - dt = date(year, 12, 25) - self.assertIn(dt, self.holidays) - self.assertNotIn(dt + relativedelta(days=-1), self.holidays) - self.assertNotIn(date(2010, 12, 24), self.holidays) - self.assertNotEqual(self.holidays[date(2011, 12, 26)], - "Christmas Day (Observed)") - self.holidays.observed = True - self.assertIn(date(2010, 12, 24), self.holidays) - self.assertEqual(self.holidays[date(2011, 12, 26)], - "Christmas Day (Observed)") - - def test_boxing_day(self): - for year in range(1900, 2100): - dt = date(year, 12, 26) - self.assertIn(dt, self.holidays) - self.assertNotIn(dt + relativedelta(days=+1), self.holidays) - self.assertNotIn(date(2009, 12, 28), self.holidays) - self.assertNotIn(date(2010, 12, 27), self.holidays) - self.holidays.observed = True - self.assertIn(date(2009, 12, 28), self.holidays) - self.assertIn(date(2010, 12, 27), self.holidays) - - -class TestCO(unittest.TestCase): - - def setUp(self): - self.holidays = holidays.CO(observed=True) - - def test_2016(self): - # http://www.officeholidays.com/countries/colombia/ - self.assertIn(date(2016, 1, 1), self.holidays) - self.assertIn(date(2016, 1, 11), self.holidays) - self.assertIn(date(2016, 3, 21), self.holidays) - self.assertIn(date(2016, 3, 24), self.holidays) - self.assertIn(date(2016, 3, 25), self.holidays) - self.assertIn(date(2016, 5, 1), self.holidays) - self.assertIn(date(2016, 5, 9), self.holidays) - self.assertIn(date(2016, 5, 30), self.holidays) - self.assertIn(date(2016, 6, 6), self.holidays) - self.assertIn(date(2016, 7, 4), self.holidays) - self.assertIn(date(2016, 7, 20), self.holidays) - self.assertIn(date(2016, 8, 7), self.holidays) - self.assertIn(date(2016, 8, 15), self.holidays) - self.assertIn(date(2016, 10, 17), self.holidays) - self.assertIn(date(2016, 11, 7), self.holidays) - self.assertIn(date(2016, 11, 14), self.holidays) - self.assertIn(date(2016, 12, 8), self.holidays) - self.assertIn(date(2016, 12, 25), self.holidays) - - def test_others(self): - # holidays falling on weekend - self.assertNotIn(date(2017, 1, 1), self.holidays) - self.assertNotIn(date(2014, 7, 20), self.holidays) - self.assertNotIn(date(2018, 8, 12), self.holidays) - - self.assertIn(date(2014, 1, 6), self.holidays) - self.assertIn(date(2012, 3, 19), self.holidays) - self.assertIn(date(2015, 6, 29), self.holidays) - self.assertIn(date(2010, 8, 16), self.holidays) - self.assertIn(date(2015, 10, 12), self.holidays) - self.assertIn(date(2010, 11, 1), self.holidays) - self.assertIn(date(2013, 11, 11), self.holidays) - self.holidays.observed = False - self.assertIn(date(2016, 5, 5), self.holidays) - self.assertIn(date(2016, 5, 26), self.holidays) - - -class TestMX(unittest.TestCase): - - def setUp(self): - self.holidays = holidays.MX(observed=False) - - def test_new_years(self): - self.assertNotIn(date(2010, 12, 31), self.holidays) - self.assertNotIn(date(2017, 1, 2), self.holidays) - self.holidays.observed = True - self.assertIn(date(2010, 12, 31), self.holidays) - self.assertIn(date(2017, 1, 2), self.holidays) - self.holidays.observed = False - for year in range(1900, 2100): - dt = date(year, 1, 1) - self.assertIn(dt, self.holidays) - self.assertNotIn(dt + relativedelta(days=-1), self.holidays) - self.assertNotIn(dt + relativedelta(days=+1), self.holidays) - - def test_constitution_day(self): - for dt in [date(2005, 2, 5), date(2006, 2, 5), date(2007, 2, 5), - date(2009, 2, 5), - date(2010, 2, 5), - date(2015, 2, 5), - date(2016, 2, 5), - date(2020, 2, 5), - date(2021, 2, 5), - date(2022, 2, 5)]: - self.assertIn(dt, self.holidays) - self.assertNotIn(dt + relativedelta(days=-1), self.holidays) - self.assertNotIn(dt + relativedelta(days=+1), self.holidays) - self.holidays.observed = True - for dt in [date(2005, 2, 5), date(2006, 2, 5), date(2007, 2, 5), - date(2009, 2, 5), date(2009, 2, 2), - date(2010, 2, 5), date(2010, 2, 1), - date(2015, 2, 5), date(2015, 2, 2), - date(2016, 2, 5), date(2016, 2, 1), - date(2020, 2, 5), date(2020, 2, 3), - date(2021, 2, 5), date(2021, 2, 1), - date(2022, 2, 5), date(2022, 2, 7)]: - self.assertIn(dt, self.holidays) - self.holidays.observed = False - - def test_benito_juarez(self): - for dt in [date(2005, 3, 21), date(2006, 3, 21), date(2007, 3, 21), - date(2008, 3, 21), - date(2009, 3, 21), - date(2010, 3, 21), - date(2015, 3, 21), - date(2016, 3, 21), - date(2020, 3, 21), - date(2021, 3, 21), - date(2022, 3, 21), - date(2024, 3, 21)]: - self.assertIn(dt, self.holidays) - self.assertNotIn(dt + relativedelta(days=-1), self.holidays) - self.assertNotIn(dt + relativedelta(days=+1), self.holidays) - self.holidays.observed = True - for dt in [date(2005, 3, 21), date(2006, 3, 21), - date(2007, 3, 21), date(2007, 3, 19), - date(2008, 3, 21), date(2008, 3, 17), - date(2009, 3, 21), date(2009, 3, 16), - date(2010, 3, 21), date(2010, 3, 15), - date(2015, 3, 21), date(2015, 3, 16), - date(2016, 3, 21), - date(2020, 3, 21), date(2020, 3, 16), - date(2021, 3, 21), date(2021, 3, 15), - date(2022, 3, 21), - date(2024, 3, 21), date(2024, 3, 18)]: - self.assertIn(dt, self.holidays) - self.holidays.observed = False - - def test_labor_day(self): - self.assertNotIn(date(2010, 4, 30), self.holidays) - self.assertNotIn(date(2011, 5, 2), self.holidays) - self.assertNotIn(date(2022, 5, 2), self.holidays) - self.holidays.observed = True - self.assertIn(date(2010, 4, 30), self.holidays) - self.assertIn(date(2011, 5, 2), self.holidays) - self.assertIn(date(2022, 5, 2), self.holidays) - self.holidays.observed = False - self.assertNotIn(date(1922, 5, 1), self.holidays) - for year in range(1923, 2100): - dt = date(year, 5, 1) - self.assertIn(dt, self.holidays) - self.assertNotIn(dt + relativedelta(days=-1), self.holidays) - self.assertNotIn(dt + relativedelta(days=+1), self.holidays) - - def test_independence_day(self): - self.assertNotIn(date(2006, 9, 15), self.holidays) - self.assertNotIn(date(2007, 9, 17), self.holidays) - self.holidays.observed = True - self.assertIn(date(2006, 9, 15), self.holidays) - self.assertIn(date(2007, 9, 17), self.holidays) - self.holidays.observed = False - for year in range(1900, 2100): - dt = date(year, 9, 16) - self.assertIn(dt, self.holidays) - self.assertNotIn(dt + relativedelta(days=-1), self.holidays) - self.assertNotIn(dt + relativedelta(days=+1), self.holidays) - - def test_revolution_day(self): - for dt in [date(2005, 11, 20), date(2006, 11, 20), date(2007, 11, 20), - date(2008, 11, 20), date(2009, 11, 20), date(2010, 11, 20), - date(2015, 11, 20), date(2016, 11, 20), date(2020, 11, 20), - date(2021, 11, 20), date(2022, 11, 20), date(2023, 11, 20)]: - self.assertIn(dt, self.holidays) - self.assertNotIn(dt + relativedelta(days=-1), self.holidays) - self.assertNotIn(dt + relativedelta(days=+1), self.holidays) - self.holidays.observed = True - for dt in [date(2005, 11, 20), date(2006, 11, 20), date(2007, 11, 19), - date(2008, 11, 17), date(2009, 11, 16), date(2010, 11, 15), - date(2015, 11, 16), date(2016, 11, 21), date(2020, 11, 16)]: - self.assertIn(dt, self.holidays) - self.holidays.observed = False - - def test_change_of_government(self): - self.assertNotIn(date(2012, 11, 30), self.holidays) - self.assertNotIn(date(2024, 12, 2), self.holidays) - self.holidays.observed = True - self.assertIn(date(2012, 11, 30), self.holidays) - self.assertIn(date(2024, 12, 2), self.holidays) - self.holidays.observed = False - for year in range(1950, 2100): - dt = date(year, 12, 1) - if (year >= 1970) and ((2096 - year) % 6) == 0: - self.assertIn(dt, self.holidays) - self.assertNotIn(dt + relativedelta(days=-1), self.holidays) - self.assertNotIn(dt + relativedelta(days=+1), self.holidays) - else: - self.assertNotIn(dt, self.holidays) - - def test_christmas(self): - for year in range(1900, 2100): - dt = date(year, 12, 25) - self.assertIn(dt, self.holidays) - self.assertNotIn(dt + relativedelta(days=-1), self.holidays) - self.assertNotIn(dt + relativedelta(days=+1), self.holidays) - self.assertNotIn(date(2010, 12, 24), self.holidays) - self.assertNotIn(date(2016, 12, 26), self.holidays) - self.holidays.observed = True - self.assertIn(date(2010, 12, 24), self.holidays) - self.assertIn(date(2016, 12, 26), self.holidays) - - -class TestNetherlands(unittest.TestCase): - - def setUp(self): - self.holidays = holidays.NL() - - def test_2017(self): - # http://www.iamsterdam.com/en/plan-your-trip/practical-info/public-holidays - self.assertIn(date(2017, 1, 1), self.holidays) - self.assertIn(date(2017, 4, 16), self.holidays) - self.assertIn(date(2017, 4, 17), self.holidays) - self.assertIn(date(2017, 4, 27), self.holidays) - self.assertIn(date(2017, 5, 25), self.holidays) - self.assertIn(date(2017, 6, 4), self.holidays) - self.assertIn(date(2017, 6, 5), self.holidays) - self.assertIn(date(2017, 12, 25), self.holidays) - self.assertIn(date(2017, 12, 26), self.holidays) - - def test_new_years(self): - self.assertIn(date(2017, 1, 1), self.holidays) - - def test_easter(self): - self.assertIn(date(2017, 4, 16), self.holidays) - - def test_easter_monday(self): - self.assertIn(date(2017, 4, 17), self.holidays) - - def test_queens_day_between_1891_and_1948(self): - # Between 1891 and 1948 Queens Day was celebrated on 8-31 - self.holidays = holidays.NL(years=[1901]) - self.assertIn(date(1901, 8, 31), self.holidays) - - def test_queens_day_between_1891_and_1948_substituted_later(self): - # Between 1891 and 1948 Queens Day was celebrated on 9-1 - # (one day later) when Queens Day falls on a Sunday - self.holidays = holidays.NL(years=[1947]) - self.assertIn(date(1947, 9, 1), self.holidays) - - def test_queens_day_between_1949_and_2013(self): - self.holidays = holidays.NL(years=[1965]) - self.assertIn(date(1965, 4, 30), self.holidays) - - def test_queens_day_between_1949_and_1980_substituted_later(self): - self.holidays = holidays.NL(years=[1967]) - self.assertIn(date(1967, 5, 1), self.holidays) - - def test_queens_day_between_1980_and_2013_substituted_earlier(self): - self.holidays = holidays.NL(years=[2006]) - self.assertIn(date(2006, 4, 29), self.holidays) - - def test_kings_day_after_2014(self): - self.holidays = holidays.NL(years=[2013]) - self.assertNotIn(date(2013, 4, 27), self.holidays) - - self.holidays = holidays.NL(years=[2017]) - self.assertIn(date(2017, 4, 27), self.holidays) - - def test_kings_day_after_2014_substituted_earlier(self): - self.holidays = holidays.NL(years=[2188]) - self.assertIn(date(2188, 4, 26), self.holidays) - - def test_liberation_day(self): - self.holidays = holidays.NL(years=1900) - self.assertNotIn(date(1900, 5, 5), self.holidays) - - def test_liberation_day_after_1990_non_lustrum_year(self): - self.holidays = holidays.NL(years=2017) - self.assertNotIn(date(2017, 5, 5), self.holidays) - - def test_liberation_day_after_1990_in_lustrum_year(self): - self.holidays = holidays.NL(years=2020) - self.assertIn(date(2020, 5, 5), self.holidays) - - def test_ascension_day(self): - self.holidays = holidays.NL(years=2017) - self.assertIn(date(2017, 5, 25), self.holidays) - - def test_whit_sunday(self): - self.holidays = holidays.NL(years=2017) - self.assertIn(date(2017, 6, 4), self.holidays) - - def test_whit_monday(self): - self.holidays = holidays.NL(years=2017) - self.assertIn(date(2017, 6, 5), self.holidays) - - def test_first_christmas(self): - self.holidays = holidays.NL(years=2017) - self.assertIn(date(2017, 12, 25), self.holidays) - - def test_second_christmas(self): - self.holidays = holidays.NL(years=2017) - self.assertIn(date(2017, 12, 26), self.holidays) - - -class TestUS(unittest.TestCase): - - def setUp(self): - self.holidays = holidays.US(observed=False) - - def test_new_years(self): - self.assertNotIn(date(2010, 12, 31), self.holidays) - self.assertNotIn(date(2017, 1, 2), self.holidays) - self.holidays.observed = True - self.assertIn(date(2010, 12, 31), self.holidays) - self.assertIn(date(2017, 1, 2), self.holidays) - self.holidays.observed = False - for year in range(1900, 2100): - dt = date(year, 1, 1) - self.assertIn(dt, self.holidays) - self.assertNotIn(dt + relativedelta(days=-1), self.holidays) - self.assertNotIn(dt + relativedelta(days=+1), self.holidays) - - def test_epiphany(self): - pr_holidays = holidays.US(state='PR') - for year in range(2010, 2021): - self.assertNotIn(date(year, 1, 6), self.holidays) - self.assertIn(date(year, 1, 6), pr_holidays) - - def test_three_kings_day(self): - vi_holidays = holidays.US(state='VI') - for year in range(2010, 2021): - self.assertNotIn(date(year, 1, 6), self.holidays) - self.assertIn(date(year, 1, 6), vi_holidays) - - def test_lee_jackson_day(self): - va_holidays = holidays.US(state='VA') - self.assertNotIn(date(1888, 1, 19), va_holidays) - self.assertNotIn(date(1983, 1, 19), va_holidays) - self.assertNotIn("Lee Jackson Day", - va_holidays.get_list(date(2000, 1, 17))) - for dt in [date(1889, 1, 19), date(1982, 1, 19), date(1983, 1, 17), - date(1999, 1, 18), date(2000, 1, 14), date(2001, 1, 12), - date(2013, 1, 18), date(2014, 1, 17), date(2018, 1, 12)]: - self.assertNotIn("Lee Jackson Day", self.holidays.get_list(dt)) - self.assertIn(dt, va_holidays) - self.assertIn("Lee Jackson Day", va_holidays.get_list(dt)) - - def test_inauguration_day(self): - name = "Inauguration Day" - dc_holidays = holidays.US(state='DC') - la_holidays = holidays.US(state='LA') - md_holidays = holidays.US(state='MD') - va_holidays = holidays.US(state='VA') - for year in (1789, 1793, 1877, 1929, 1933): - self.assertNotIn(name, self.holidays.get_list(date(year, 3, 4))) - self.assertIn(name, dc_holidays.get_list(date(year, 3, 4))) - self.assertIn(name, la_holidays.get_list(date(year, 3, 4))) - self.assertIn(name, md_holidays.get_list(date(year, 3, 4))) - self.assertIn(name, va_holidays.get_list(date(year, 3, 4))) - for year in (1937, 1941, 1957, 2013, 2017): - self.assertNotIn(name, self.holidays.get_list(date(year, 1, 20))) - self.assertIn(name, dc_holidays.get_list(date(year, 1, 20))) - self.assertIn(name, la_holidays.get_list(date(year, 1, 20))) - self.assertIn(name, md_holidays.get_list(date(year, 1, 20))) - self.assertIn(name, va_holidays.get_list(date(year, 1, 20))) - for year in (1785, 1788, 2010, 2011, 2012, 2014, 2015, 2016): - self.assertNotIn(name, dc_holidays.get_list(date(year, 3, 4))) - self.assertNotIn(name, la_holidays.get_list(date(year, 3, 4))) - self.assertNotIn(name, md_holidays.get_list(date(year, 3, 4))) - self.assertNotIn(name, va_holidays.get_list(date(year, 3, 4))) - self.assertNotIn(name, dc_holidays.get_list(date(year, 1, 20))) - self.assertNotIn(name, la_holidays.get_list(date(year, 1, 20))) - self.assertNotIn(name, md_holidays.get_list(date(year, 1, 20))) - self.assertNotIn(name, va_holidays.get_list(date(year, 1, 20))) - - def test_martin_luther(self): - for dt in [date(1986, 1, 20), date(1999, 1, 18), date(2000, 1, 17), - date(2012, 1, 16), date(2013, 1, 21), date(2014, 1, 20), - date(2015, 1, 19), date(2016, 1, 18), date(2020, 1, 20)]: - self.assertIn(dt, self.holidays) - self.assertNotIn(dt + relativedelta(days=-1), self.holidays) - self.assertNotIn(dt + relativedelta(days=+1), self.holidays) - self.assertNotIn("Martin Luther King Jr. Day", - holidays.US(years=[1985]).values()) - self.assertIn("Martin Luther King Jr. Day", - holidays.US(years=[1986]).values()) - self.assertEqual(holidays.US(state='AL').get('2015-01-19'), - "Robert E. Lee/Martin Luther King Birthday") - self.assertEqual(holidays.US(state='AR').get('2015-01-19'), - ("Dr. Martin Luther King Jr. " - "and Robert E. Lee's Birthdays")) - self.assertEqual(holidays.US(state='MS').get('2015-01-19'), - ("Dr. Martin Luther King Jr. " - "and Robert E. Lee's Birthdays")) - self.assertEqual(holidays.US(state='AZ').get('2015-01-19'), - "Dr. Martin Luther King Jr./Civil Rights Day") - self.assertEqual(holidays.US(state='NH').get('2015-01-19'), - "Dr. Martin Luther King Jr./Civil Rights Day") - self.assertEqual(holidays.US(state='ID').get('2015-01-19'), - "Martin Luther King Jr. - Idaho Human Rights Day") - self.assertNotEqual(holidays.US(state='ID').get('2000-01-17'), - "Martin Luther King Jr. - Idaho Human Rights Day") - self.assertEqual(holidays.US(state='GA').get('2011-01-17'), - "Robert E. Lee's Birthday") - - def test_lincolns_birthday(self): - ca_holidays = holidays.US(state='CA') - ct_holidays = holidays.US(state='CT') - il_holidays = holidays.US(state='IL') - ia_holidays = holidays.US(state='IA') - nj_holidays = holidays.US(state='NJ') - ny_holidays = holidays.US(state='NY') - for year in range(1971, 2010): - self.assertNotIn(date(year, 2, 12), self.holidays) - self.assertIn(date(year, 2, 12), ca_holidays) - self.assertIn(date(year, 2, 12), ct_holidays) - self.assertIn(date(year, 2, 12), il_holidays) - self.assertIn(date(year, 2, 12), ia_holidays) - self.assertIn(date(year, 2, 12), nj_holidays) - self.assertIn(date(year, 2, 12), ny_holidays) - if date(year, 2, 12).weekday() == 5: - self.assertNotIn(date(year, 2, 11), self.holidays) - self.assertIn(date(year, 2, 11), ca_holidays) - self.assertIn(date(year, 2, 11), ct_holidays) - self.assertIn(date(year, 2, 11), il_holidays) - self.assertIn(date(year, 2, 11), ia_holidays) - self.assertIn(date(year, 2, 11), nj_holidays) - self.assertIn(date(year, 2, 11), ny_holidays) - else: - self.assertNotIn(date(year, 2, 11), ca_holidays) - self.assertNotIn(date(year, 2, 11), ct_holidays) - self.assertNotIn(date(year, 2, 11), il_holidays) - self.assertNotIn(date(year, 2, 11), ia_holidays) - self.assertNotIn(date(year, 2, 11), nj_holidays) - self.assertNotIn(date(year, 2, 11), ny_holidays) - if date(year, 2, 12).weekday() == 6: - self.assertNotIn(date(year, 2, 13), self.holidays) - self.assertIn(date(year, 2, 13), ca_holidays) - self.assertIn(date(year, 2, 13), ct_holidays) - self.assertIn(date(year, 2, 13), il_holidays) - self.assertIn(date(year, 2, 13), ia_holidays) - self.assertIn(date(year, 2, 13), nj_holidays) - self.assertIn(date(year, 2, 13), ny_holidays) - else: - self.assertNotIn(date(year, 2, 13), ca_holidays) - self.assertNotIn(date(year, 2, 13), ct_holidays) - self.assertNotIn(date(year, 2, 13), il_holidays) - self.assertNotIn(date(year, 2, 13), ia_holidays) - self.assertNotIn(date(year, 2, 13), nj_holidays) - self.assertNotIn(date(year, 2, 13), ny_holidays) - for year in range(2010, 2050): - self.assertNotIn(date(year, 2, 12), self.holidays) - self.assertNotIn(date(year, 2, 12), ca_holidays) - self.assertIn(date(year, 2, 12), ct_holidays) - self.assertIn(date(year, 2, 12), il_holidays) - self.assertIn(date(year, 2, 12), ia_holidays) - self.assertIn(date(year, 2, 12), nj_holidays) - self.assertIn(date(year, 2, 12), ny_holidays) - if date(year, 2, 12).weekday() == 5: - self.assertNotIn(date(year, 2, 11), self.holidays) - self.assertNotIn(date(year, 2, 11), ca_holidays) - self.assertIn(date(year, 2, 11), ct_holidays) - self.assertIn(date(year, 2, 11), il_holidays) - self.assertIn(date(year, 2, 11), ia_holidays) - self.assertIn(date(year, 2, 11), nj_holidays) - self.assertIn(date(year, 2, 11), ny_holidays) - else: - self.assertNotIn(date(year, 2, 11), ca_holidays) - self.assertNotIn(date(year, 2, 11), ct_holidays) - self.assertNotIn(date(year, 2, 11), il_holidays) - self.assertNotIn(date(year, 2, 11), ia_holidays) - self.assertNotIn(date(year, 2, 11), nj_holidays) - self.assertNotIn(date(year, 2, 11), ny_holidays) - if date(year, 2, 12).weekday() == 6: - self.assertNotIn(date(year, 2, 13), self.holidays) - self.assertNotIn(date(year, 2, 13), ca_holidays) - self.assertIn(date(year, 2, 13), ct_holidays) - self.assertIn(date(year, 2, 13), il_holidays) - self.assertIn(date(year, 2, 13), ia_holidays) - self.assertIn(date(year, 2, 13), nj_holidays) - self.assertIn(date(year, 2, 13), ny_holidays) - else: - self.assertNotIn(date(year, 2, 13), ca_holidays) - self.assertNotIn(date(year, 2, 13), ct_holidays) - self.assertNotIn(date(year, 2, 13), il_holidays) - self.assertNotIn(date(year, 2, 13), ia_holidays) - self.assertNotIn(date(year, 2, 13), nj_holidays) - self.assertNotIn(date(year, 2, 13), ny_holidays) - - def test_susan_b_anthony_day(self): - ca_holidays = holidays.US(state='CA') - fl_holidays = holidays.US(state='FL') - ny_holidays = holidays.US(state='NY') - wi_holidays = holidays.US(state='WI') - self.assertNotIn(date(1975, 2, 15), wi_holidays) - self.assertNotIn(date(2000, 2, 15), ca_holidays) - self.assertNotIn(date(2000, 2, 15), fl_holidays) - self.assertNotIn(date(2000, 2, 15), ny_holidays) - self.assertIn(date(2000, 2, 15), wi_holidays) - self.assertIn(date(2004, 2, 15), ny_holidays) - self.assertNotIn(date(2010, 2, 15), fl_holidays) - self.assertIn(date(2010, 2, 15), ny_holidays) - self.assertNotIn(date(2013, 2, 15), self.holidays) - self.assertNotIn(date(2013, 2, 15), ca_holidays) - self.assertIn(date(2013, 2, 15), fl_holidays) - self.assertIn(date(2013, 2, 15), ny_holidays) - self.assertNotIn(date(2014, 2, 15), self.holidays) - self.assertIn(date(2014, 2, 15), ca_holidays) - self.assertIn(date(2014, 2, 15), fl_holidays) - self.assertIn(date(2014, 2, 15), ny_holidays) - self.assertIn(date(2014, 2, 15), wi_holidays) - - def test_washingtons_birthday(self): - de_holidays = holidays.US(state='DE') - fl_holidays = holidays.US(state='FL') - ga_holidays = holidays.US(state='GA') - nm_holidays = holidays.US(state='NM') - for dt in [date(1969, 2, 22), date(1970, 2, 22), date(1971, 2, 15), - date(1997, 2, 17), date(1999, 2, 15), date(2000, 2, 21), - date(2012, 2, 20), date(2013, 2, 18), date(2014, 2, 17), - date(2015, 2, 16), date(2016, 2, 15), date(2020, 2, 17)]: - self.assertIn(dt, self.holidays) - self.assertNotIn(dt + relativedelta(days=-1), self.holidays) - self.assertNotIn(dt + relativedelta(days=+1), self.holidays) - self.assertNotIn(dt, de_holidays) - self.assertNotEqual(fl_holidays.get(dt), "Washington's Birthday") - self.assertNotIn(dt, ga_holidays) - self.assertNotIn(dt, nm_holidays) - for dt in [date(2013, 12, 24), date(2014, 12, 26), date(2015, 12, 24)]: - self.assertIn(dt, ga_holidays) - self.assertIn("Washington's Birthday", ga_holidays.get_list(dt)) - self.assertEqual(holidays.US(state='AL').get('2015-02-16'), - "George Washington/Thomas Jefferson Birthday") - self.assertEqual(holidays.US(state='AR').get('2015-02-16'), - ("George Washington's Birthday " - "and Daisy Gatson Bates Day")) - self.assertEqual(holidays.US(state='PR').get('2015-02-16'), - "Presidents' Day") - self.assertEqual(holidays.US(state='VI').get('2015-02-16'), - "Presidents' Day") - - def test_mardi_gras(self): - la_holidays = holidays.US(state='LA') - self.assertNotIn(date(1856, 2, 5), la_holidays) - for dt in [date(1857, 2, 24), date(2008, 2, 5), date(2011, 3, 8), - date(2012, 2, 21), date(2014, 3, 4), date(2018, 2, 13)]: - self.assertNotIn(dt, self.holidays) - self.assertIn(dt, la_holidays) - - def test_guam_discovery_day(self): - gu_holidays = holidays.US(state='GU') - self.assertNotIn(date(1969, 3, 1), gu_holidays) - for dt in [date(1970, 3, 2), date(1971, 3, 1), date(1977, 3, 7), - date(2014, 3, 3), date(2015, 3, 2), date(2016, 3, 7)]: - self.assertNotIn(dt, self.holidays) - self.assertIn(dt, gu_holidays) - self.assertEqual(gu_holidays.get(dt), "Guam Discovery Day") - - def test_casimir_pulaski_day(self): - il_holidays = holidays.US(state='IL') - self.assertNotIn(date(1977, 3, 7), il_holidays) - for dt in [date(1978, 3, 6), date(1982, 3, 1), date(1983, 3, 7), - date(2014, 3, 3), date(2015, 3, 2), date(2016, 3, 7)]: - self.assertNotIn(dt, self.holidays) - self.assertIn(dt, il_holidays) - self.assertEqual(il_holidays.get(dt), "Casimir Pulaski Day") - - def test_texas_independence_day(self): - tx_holidays = holidays.US(state='TX') - self.assertNotIn(date(1873, 3, 2), tx_holidays) - for year in range(1874, 2050): - self.assertNotIn(date(year, 3, 2), self.holidays) - self.assertIn(date(year, 3, 2), tx_holidays) - - def test_town_meeting_day(self): - vt_holidays = holidays.US(state='VT') - self.assertNotIn(date(1799, 3, 5), vt_holidays) - for dt in [date(1800, 3, 4), date(1803, 3, 1), date(1804, 3, 6), - date(2011, 3, 1), date(2015, 3, 3), date(2017, 3, 7)]: - self.assertNotIn(dt, self.holidays) - self.assertIn(dt, vt_holidays) - - def test_evacuation_day(self): - ma_holidays = holidays.US(state='MA') - self.assertNotIn(date(1900, 3, 17), ma_holidays) - for year in range(1901, 2050): - self.assertNotIn(date(year, 3, 17), self.holidays) - self.assertIn(date(year, 3, 17), ma_holidays) - self.assertNotIn(date(1995, 3, 20), ma_holidays) - for dt in [date(2012, 3, 19), date(2013, 3, 18), date(2018, 3, 19)]: - self.assertIn(dt, ma_holidays) - ma_holidays.observed = False - for dt in [date(2012, 3, 19), date(2013, 3, 18), date(2018, 3, 19)]: - self.assertNotIn(dt, ma_holidays) - - def test_emancipation_day_in_puerto_rico(self): - pr_holidays = holidays.US(state='PR') - for year in range(2010, 2021): - self.assertNotIn(date(year, 3, 22), self.holidays) - self.assertIn(date(year, 3, 22), pr_holidays) - self.assertNotIn(date(2014, 3, 21), pr_holidays) - self.assertNotIn(date(2014, 3, 23), pr_holidays) - self.assertIn(date(2015, 3, 23), pr_holidays) - - def test_prince_jonah_kuhio_kalanianaole_day(self): - hi_holidays = holidays.US(state='HI') - self.assertNotIn(date(1948, 3, 26), hi_holidays) - for year in range(1949, 2050): - self.assertNotIn(date(year, 3, 26), self.holidays) - self.assertIn(date(year, 3, 26), hi_holidays) - for dt in [date(1949, 3, 25), date(2016, 3, 25), date(2017, 3, 27)]: - self.assertNotIn(dt, self.holidays) - self.assertIn(dt, hi_holidays) - self.assertEqual(hi_holidays.get(dt), - "Prince Jonah Kuhio Kalanianaole Day (Observed)") - hi_holidays.observed = False - for dt in [date(1949, 3, 25), date(2016, 3, 25), date(2017, 3, 27)]: - self.assertNotIn(dt, hi_holidays) - - def test_stewards_day(self): - ak_holidays = holidays.US(state='AK') - self.assertNotIn(date(1917, 3, 30), ak_holidays) - for dt in [date(1918, 3, 30), date(1954, 3, 30), date(1955, 3, 28), - date(2002, 3, 25), date(2014, 3, 31), date(2018, 3, 26)]: - self.assertNotIn(dt, self.holidays) - self.assertIn(dt, ak_holidays) - - def test_cesar_chavez_day(self): - ca_holidays = holidays.US(state='CA') - tx_holidays = holidays.US(state='TX') - for year in range(1995, 2000): - self.assertNotIn(date(year, 3, 31), self.holidays) - self.assertIn(date(year, 3, 31), ca_holidays) - for year in range(2000, 2020): - self.assertNotIn(date(year, 3, 31), self.holidays) - self.assertIn(date(year, 3, 31), ca_holidays) - self.assertIn(date(year, 3, 31), tx_holidays) - for year in (1996, 2002, 2013, 2019): - self.assertNotIn(date(year, 4, 1), self.holidays) - self.assertIn(date(year, 4, 1), ca_holidays) - self.assertNotIn(date(year, 4, 1), tx_holidays) - - def test_transfer_day(self): - vi_holidays = holidays.US(state='VI') - for year in range(2010, 2021): - self.assertNotIn(date(year, 3, 31), self.holidays) - self.assertIn(date(year, 3, 31), vi_holidays) - - def test_emancipation_day(self): - dc_holidays = holidays.US(state='DC') - self.assertNotIn(date(2004, 4, 16), dc_holidays) - for year in range(2005, 2020): - self.assertNotIn(date(year, 4, 16), self.holidays) - self.assertIn(date(year, 4, 16), dc_holidays) - self.assertIn(date(2005, 4, 15), dc_holidays) - self.assertIn(date(2006, 4, 17), dc_holidays) - dc_holidays.observed = False - self.assertNotIn(date(2005, 4, 15), dc_holidays) - self.assertNotIn(date(2006, 4, 17), dc_holidays) - - def test_patriots_day(self): - me_holidays = holidays.US(state='ME') - ma_holidays = holidays.US(state='MA') - self.assertNotIn(date(1983, 4, 19), me_holidays) - self.assertNotIn(date(1983, 4, 19), ma_holidays) - for year in range(1894, 1969): - self.assertNotIn(date(year, 4, 19), self.holidays) - self.assertIn(date(year, 4, 19), me_holidays) - self.assertIn(date(year, 4, 19), ma_holidays) - for dt in [date(1969, 4, 21), date(1974, 4, 15), date(1975, 4, 21), - date(2015, 4, 20), date(2016, 4, 18), date(2019, 4, 15)]: - self.assertNotIn(dt, self.holidays) - self.assertIn(dt, me_holidays) - self.assertIn(dt, ma_holidays) - - def test_holy_thursday(self): - vi_holidays = holidays.US(state='VI') - for dt in [date(2010, 4, 1), date(2011, 4, 21), date(2013, 3, 28), - date(2014, 4, 17), date(2015, 4, 2), date(2016, 3, 24)]: - self.assertNotIn(dt, self.holidays) - self.assertIn(dt, 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.assertNotIn(dt, self.holidays) - self.assertIn(dt, ct_holidays) - self.assertIn(dt, de_holidays) - self.assertIn(dt, gu_holidays) - self.assertIn(dt, in_holidays) - self.assertIn(dt, ky_holidays) - self.assertIn(dt, la_holidays) - self.assertIn(dt, nj_holidays) - self.assertIn(dt, nc_holidays) - self.assertIn(dt, tn_holidays) - self.assertIn(dt, tx_holidays) - self.assertIn(dt, vi_holidays) - - def test_easter_monday(self): - vi_holidays = holidays.US(state='VI') - for dt in [date(1900, 4, 16), date(1901, 4, 8), date(1902, 3, 31), - date(1999, 4, 5), date(2010, 4, 5), - date(2018, 4, 2), date(2019, 4, 22), date(2020, 4, 13)]: - self.assertNotIn(dt, self.holidays) - self.assertIn(dt, vi_holidays) - - def test_confederate_memorial_day(self): - al_holidays = holidays.US(state='AL') - ga_holidays = holidays.US(state='GA') - ms_holidays = holidays.US(state='MS') - sc_holidays = holidays.US(state='SC') - tx_holidays = holidays.US(state='TX') - self.assertNotIn(date(1865, 4, 24), self.holidays) - self.assertNotIn(date(1865, 4, 24), al_holidays) - for dt in [date(1866, 4, 23), date(1878, 4, 22), date(1884, 4, 28), - date(2014, 4, 28), date(2015, 4, 27), date(2019, 4, 22)]: - self.assertNotIn(dt, self.holidays) - self.assertIn(dt, al_holidays) - self.assertIn(dt, ga_holidays) - self.assertIn(dt, ms_holidays) - self.assertIn(dt, sc_holidays) - self.assertNotIn(date(1930, 1, 19), tx_holidays) - self.assertNotIn(date(1931, 1, 19), self.holidays) - self.assertIn(date(1931, 1, 19), tx_holidays) - self.assertIn(date(2020, 4, 10), ga_holidays) - - def test_san_jacinto_day(self): - tx_holidays = holidays.US(state='TX') - self.assertNotIn(date(1874, 4, 21), tx_holidays) - for year in (1875, 2050): - self.assertNotIn(date(year, 4, 21), self.holidays) - self.assertIn(date(year, 4, 21), tx_holidays) - - def test_arbor_day(self): - ne_holidays = holidays.US(state='NE') - for dt in [date(1875, 4, 22), date(1988, 4, 22), date(1989, 4, 28), - date(2009, 4, 24), date(2010, 4, 30), date(2014, 4, 25)]: - self.assertNotIn(dt, self.holidays) - self.assertIn(dt, ne_holidays) - - def test_primary_election_day(self): - in_holidays = holidays.US(state='IN') - self.assertNotIn(date(2004, 5, 4), in_holidays) - for dt in [date(2006, 5, 2), date(2008, 5, 6), date(2010, 5, 4), - date(2012, 5, 8), date(2014, 5, 6), date(2015, 5, 5), - date(2016, 5, 3)]: - self.assertNotIn(dt, self.holidays) - self.assertIn(dt, in_holidays) - - def test_truman_day(self): - mo_holidays = holidays.US(state='MO', observed=False) - self.assertNotIn(date(1948, 5, 8), self.holidays) - self.assertNotIn(date(1948, 5, 8), mo_holidays) - for year in range(1949, 2100): - dt = date(year, 5, 8) - self.assertNotIn(dt, self.holidays) - self.assertIn(dt, mo_holidays) - self.assertNotIn(dt + relativedelta(days=-1), mo_holidays) - self.assertNotIn(dt + relativedelta(days=+1), mo_holidays) - self.assertNotIn(date(2004, 5, 7), mo_holidays) - self.assertNotIn(date(2005, 5, 10), mo_holidays) - mo_holidays.observed = True - self.assertIn(date(2004, 5, 7), mo_holidays) - self.assertIn(date(2005, 5, 10), mo_holidays) - - def test_memorial_day(self): - for dt in [date(1969, 5, 30), date(1970, 5, 30), date(1971, 5, 31), - date(1997, 5, 26), date(1999, 5, 31), date(2000, 5, 29), - date(2012, 5, 28), date(2013, 5, 27), date(2014, 5, 26), - date(2015, 5, 25), date(2016, 5, 30), date(2020, 5, 25)]: - self.assertIn(dt, self.holidays) - self.assertNotIn(dt + relativedelta(days=-1), self.holidays) - self.assertNotIn(dt + relativedelta(days=+1), self.holidays) - - def test_jefferson_davis_birthday(self): - al_holidays = holidays.US(state='AL') - self.assertNotIn(date(1889, 6, 3), self.holidays) - self.assertNotIn(date(1889, 6, 3), 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.assertNotIn(dt, self.holidays) - self.assertIn(dt, al_holidays) - - def test_kamehameha_day(self): - hi_holidays = holidays.US(state='HI') - self.assertNotIn(date(1871, 6, 11), hi_holidays) - for year in range(1872, 2050): - self.assertNotIn(date(year, 6, 11), self.holidays) - self.assertIn(date(year, 6, 11), hi_holidays) - self.assertNotIn(date(2006, 6, 12), hi_holidays) - for dt in [date(2011, 6, 10), date(2016, 6, 10), date(2017, 6, 12)]: - self.assertIn(dt, hi_holidays) - self.assertEqual(hi_holidays.get(dt), "Kamehameha Day (Observed)") - hi_holidays.observed = False - for dt in [date(2011, 6, 10), date(2016, 6, 10), date(2017, 6, 12)]: - self.assertNotIn(dt, hi_holidays) - - def test_emancipation_day_in_texas(self): - tx_holidays = holidays.US(state='TX') - self.assertNotIn(date(1979, 6, 19), tx_holidays) - for year in (1980, 2050): - self.assertNotIn(date(year, 6, 19), self.holidays) - self.assertIn(date(year, 6, 19), tx_holidays) - - def test_west_virginia_day(self): - wv_holidays = holidays.US(state='WV') - self.assertNotIn(date(1926, 6, 20), wv_holidays) - for year in (1927, 2050): - self.assertNotIn(date(year, 6, 20), self.holidays) - self.assertIn(date(year, 6, 20), wv_holidays) - self.assertIn(date(2015, 6, 19), wv_holidays) - self.assertIn(date(2010, 6, 21), wv_holidays) - wv_holidays.observed = False - self.assertNotIn(date(2015, 6, 19), wv_holidays) - self.assertNotIn(date(2010, 6, 21), wv_holidays) - - def test_emancipation_day_in_virgin_islands(self): - vi_holidays = holidays.US(state='VI') - for year in (2010, 2021): - self.assertNotIn(date(year, 7, 3), self.holidays) - self.assertIn(date(year, 7, 3), vi_holidays) - - def test_independence_day(self): - for year in range(1900, 2100): - dt = date(year, 7, 4) - self.assertIn(dt, self.holidays) - self.assertNotIn(dt + relativedelta(days=-1), self.holidays) - self.assertNotIn(dt + relativedelta(days=+1), self.holidays) - self.assertNotIn(date(2010, 7, 5), self.holidays) - self.assertNotIn(date(2020, 7, 3), self.holidays) - self.holidays.observed = True - self.assertIn(date(2010, 7, 5), self.holidays) - self.assertIn(date(2020, 7, 3), self.holidays) - - def test_liberation_day_guam(self): - gu_holidays = holidays.US(state='GU') - self.assertNotIn(date(1944, 7, 21), gu_holidays) - for year in range(1945, 2100): - self.assertNotIn(date(year, 7, 21), self.holidays) - self.assertIn(date(year, 7, 21), gu_holidays) - - def test_pioneer_day(self): - ut_holidays = holidays.US(state='UT') - self.assertNotIn(date(1848, 7, 24), ut_holidays) - for year in (1849, 2050): - self.assertNotIn(date(year, 7, 24), self.holidays) - self.assertIn(date(year, 7, 24), ut_holidays) - self.assertIn('2010-07-23', ut_holidays) - self.assertIn('2011-07-25', ut_holidays) - ut_holidays.observed = False - self.assertNotIn('2010-07-23', ut_holidays) - self.assertNotIn('2011-07-25', ut_holidays) - - def test_constitution_day(self): - pr_holidays = holidays.US(state='PR') - for year in range(2010, 2021): - self.assertNotIn(date(year, 7, 25), self.holidays) - self.assertIn(date(year, 7, 25), pr_holidays) - self.assertNotIn(date(2015, 7, 24), pr_holidays) - self.assertNotIn(date(2015, 7, 26), pr_holidays) - self.assertIn(date(2021, 7, 26), pr_holidays) - - def test_victory_day(self): - ri_holidays = holidays.US(state='RI') - self.assertNotIn(date(1947, 8, 11), ri_holidays) - for dt in [date(1948, 8, 9), date(1995, 8, 14), date(2005, 8, 8), - date(2015, 8, 10), date(2016, 8, 8), date(2017, 8, 14)]: - self.assertNotIn(dt, self.holidays) - self.assertIn(dt, ri_holidays) - - def test_statehood_day(self): - hi_holidays = holidays.US(state='HI') - self.assertNotIn(date(1958, 8, 15), hi_holidays) - for dt in [date(1959, 8, 21), date(1969, 8, 15), date(1999, 8, 20), - date(2014, 8, 15), date(2015, 8, 21), date(2016, 8, 19)]: - self.assertNotIn(dt, self.holidays) - self.assertIn(dt, hi_holidays) - - def test_bennington_battle_day(self): - vt_holidays = holidays.US(state='VT') - self.assertNotIn(date(1777, 8, 16), vt_holidays) - for year in range(1778, 2050): - self.assertNotIn(date(year, 8, 16), self.holidays) - self.assertIn(date(year, 8, 16), vt_holidays) - vt_holidays.observed = False - self.assertNotIn("Bennington Battle Day (Observed)", - vt_holidays.get_list(date(1997, 8, 15))) - vt_holidays.observed = True - self.assertIn("Bennington Battle Day (Observed)", - vt_holidays.get_list(date(1997, 8, 15))) - self.assertNotIn("Bennington Battle Day (Observed)", - vt_holidays.get_list(date(1997, 8, 17))) - self.assertIn("Bennington Battle Day (Observed)", - vt_holidays.get_list(date(1998, 8, 17))) - self.assertNotIn("Bennington Battle Day (Observed)", - vt_holidays.get_list(date(1999, 8, 15))) - self.assertNotIn("Bennington Battle Day (Observed)", - vt_holidays.get_list(date(1999, 8, 17))) - - def test_lyndon_baines_johnson_day(self): - tx_holidays = holidays.US(state='TX') - self.assertNotIn(date(1972, 8, 27), tx_holidays) - for year in (1973, 2050): - self.assertNotIn(date(year, 8, 27), self.holidays) - self.assertIn(date(year, 8, 27), tx_holidays) - - def test_labor_day(self): - for dt in [date(1997, 9, 1), date(1999, 9, 6), date(2000, 9, 4), - date(2012, 9, 3), date(2013, 9, 2), date(2014, 9, 1), - date(2015, 9, 7), date(2016, 9, 5), date(2020, 9, 7)]: - self.assertIn(dt, self.holidays) - self.assertNotIn(dt + relativedelta(days=-1), self.holidays) - self.assertNotIn(dt + relativedelta(days=+1), self.holidays) - - def test_columbus_day(self): - ak_holidays = holidays.US(state='AK') - de_holidays = holidays.US(state='DE') - fl_holidays = holidays.US(state='FL') - hi_holidays = holidays.US(state='HI') - sd_holidays = holidays.US(state='SD') - vi_holidays = holidays.US(state='VI') - for dt in [date(1937, 10, 12), date(1969, 10, 12), date(1970, 10, 12), - date(1999, 10, 11), date(2000, 10, 9), date(2001, 10, 8), - date(2013, 10, 14), date(2018, 10, 8), date(2019, 10, 14)]: - self.assertIn(dt, self.holidays) - self.assertNotIn(dt, ak_holidays) - self.assertNotIn(dt, de_holidays) - self.assertNotIn(dt, fl_holidays) - self.assertNotIn(dt, hi_holidays) - self.assertNotIn(dt + relativedelta(days=-1), self.holidays) - self.assertNotIn(dt + relativedelta(days=+1), self.holidays) - self.assertEqual(sd_holidays.get(dt), "Native American Day") - self.assertEqual(vi_holidays.get(dt), - "Columbus Day and Puerto Rico Friendship Day") - self.assertNotIn(date(1936, 10, 12), self.holidays) - - def test_alaska_day(self): - ak_holidays = holidays.US(state='AK', observed=False) - self.assertNotIn(date(1866, 10, 18), ak_holidays) - for year in range(1867, 2050): - self.assertIn(date(year, 10, 18), ak_holidays) - self.assertNotIn(date(year, 10, 17), ak_holidays) - self.assertNotIn(date(year, 10, 19), ak_holidays) - self.assertNotIn(date(year, 10, 18), self.holidays) - ak_holidays.observed = True - self.assertIn(date(2014, 10, 17), ak_holidays) - self.assertIn(date(2015, 10, 19), ak_holidays) - - def test_nevada_day(self): - nv_holidays = holidays.US(state='NV') - self.assertNotIn(date(1932, 10, 31), 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.assertNotIn(dt, self.holidays) - self.assertIn(dt, nv_holidays) - self.assertIn("Nevada Day (Observed)", - nv_holidays.get_list(date(1998, 10, 30))) - self.assertIn("Nevada Day (Observed)", - nv_holidays.get_list(date(1999, 11, 1))) - nv_holidays.observed = False - self.assertNotIn("Nevada Day (Observed)", - nv_holidays.get_list(date(1998, 10, 30))) - self.assertNotIn("Nevada Day (Observed)", - nv_holidays.get_list(date(1999, 11, 1))) - - def test_liberty_day(self): - vi_holidays = holidays.US(state='VI') - for year in range(2010, 2021): - self.assertNotIn(date(year, 11, 1), self.holidays) - self.assertIn(date(year, 11, 1), vi_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.assertNotIn(date(2004, 11, 2), 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.assertNotIn(dt, self.holidays) - self.assertIn(dt, de_holidays) - self.assertIn(dt, hi_holidays) - self.assertIn(dt, il_holidays) - self.assertIn(dt, in_holidays) - self.assertIn(dt, la_holidays) - self.assertIn(dt, mt_holidays) - self.assertIn(dt, nh_holidays) - self.assertIn(dt, nj_holidays) - self.assertIn(dt, ny_holidays) - self.assertIn(dt, wv_holidays) - self.assertNotIn(date(2015, 11, 3), self.holidays) - self.assertNotIn(date(2015, 11, 3), de_holidays) - self.assertNotIn(date(2015, 11, 3), hi_holidays) - self.assertNotIn(date(2015, 11, 3), il_holidays) - self.assertIn(date(2015, 11, 3), in_holidays) - self.assertNotIn(date(2015, 11, 3), la_holidays) - self.assertNotIn(date(2015, 11, 3), mt_holidays) - self.assertNotIn(date(2015, 11, 3), nh_holidays) - self.assertNotIn(date(2015, 11, 3), nj_holidays) - self.assertIn(date(2015, 11, 3), ny_holidays) - self.assertNotIn(date(2015, 11, 3), wv_holidays) - - def test_all_souls_day(self): - gu_holidays = holidays.US(state='GU') - for year in range(1945, 2100): - self.assertNotIn(date(year, 11, 2), self.holidays) - self.assertIn(date(year, 11, 2), gu_holidays) - - def test_veterans_day(self): - for dt in [date(1938, 11, 11), date(1939, 11, 11), date(1970, 11, 11), - date(1971, 10, 25), date(1977, 10, 24), date(1978, 11, 11), - date(2012, 11, 11), date(2013, 11, 11), date(2014, 11, 11), - date(2015, 11, 11), date(2016, 11, 11), date(2020, 11, 11)]: - self.assertIn(dt, self.holidays) - self.assertNotIn(dt + relativedelta(days=-1), self.holidays) - self.assertNotIn(dt + relativedelta(days=+1), self.holidays) - self.assertNotIn("Armistice Day", holidays.US(years=[1937]).values()) - self.assertNotIn("Armistice Day", holidays.US(years=[1937]).values()) - self.assertIn("Armistice Day", holidays.US(years=[1938]).values()) - self.assertIn("Armistice Day", holidays.US(years=[1953]).values()) - self.assertIn("Veterans Day", holidays.US(years=[1954]).values()) - self.assertNotIn(date(2012, 11, 12), self.holidays) - self.assertNotIn(date(2017, 11, 10), self.holidays) - self.holidays.observed = True - self.assertIn(date(2012, 11, 12), self.holidays) - self.assertIn(date(2017, 11, 10), self.holidays) - - def test_discovery_day(self): - pr_holidays = holidays.US(state='PR') - for year in range(2010, 2021): - self.assertNotIn(date(year, 11, 19), self.holidays) - self.assertIn(date(year, 11, 19), pr_holidays) - self.assertNotIn(date(2016, 11, 18), pr_holidays) - self.assertNotIn(date(2016, 11, 20), pr_holidays) - self.assertIn(date(2017, 11, 20), pr_holidays) - - def test_thanksgiving_day(self): - ca_holidays = holidays.US(state='CA') - de_holidays = holidays.US(state='DE') - fl_holidays = holidays.US(state='FL') - in_holidays = holidays.US(state='IN') - md_holidays = holidays.US(state='MD') - nv_holidays = holidays.US(state='NV') - nh_holidays = holidays.US(state='NH') - nm_holidays = holidays.US(state='NM') - nc_holidays = holidays.US(state='NC') - ok_holidays = holidays.US(state='OK') - tx_holidays = holidays.US(state='TX') - wv_holidays = holidays.US(state='WV') - for dt in [date(1997, 11, 27), date(1999, 11, 25), date(2000, 11, 23), - date(2012, 11, 22), date(2013, 11, 28), date(2014, 11, 27), - date(2015, 11, 26), date(2016, 11, 24), date(2020, 11, 26)]: - self.assertIn(dt, self.holidays) - self.assertNotIn(dt + relativedelta(days=-1), self.holidays) - self.assertNotIn(dt + relativedelta(days=+1), self.holidays) - self.assertIn(dt + relativedelta(days=+1), de_holidays) - self.assertEqual(ca_holidays.get(dt + relativedelta(days=+1)), - "Day After Thanksgiving") - self.assertEqual(de_holidays.get(dt + relativedelta(days=+1)), - "Day After Thanksgiving") - self.assertEqual(nh_holidays.get(dt + relativedelta(days=+1)), - "Day After Thanksgiving") - self.assertEqual(nc_holidays.get(dt + relativedelta(days=+1)), - "Day After Thanksgiving") - self.assertEqual(ok_holidays.get(dt + relativedelta(days=+1)), - "Day After Thanksgiving") - self.assertEqual(wv_holidays.get(dt + relativedelta(days=+1)), - "Day After Thanksgiving") - self.assertIn(dt + relativedelta(days=+1), fl_holidays) - self.assertEqual(fl_holidays.get(dt + relativedelta(days=+1)), - "Friday After Thanksgiving") - self.assertIn(dt + relativedelta(days=+1), tx_holidays) - self.assertEqual(tx_holidays.get(dt + relativedelta(days=+1)), - "Friday After Thanksgiving") - self.assertEqual(nv_holidays.get(dt + relativedelta(days=+1)), - "Family Day") - self.assertEqual(nm_holidays.get(dt + relativedelta(days=+1)), - "Presidents' Day") - if dt.year >= 2008: - self.assertEqual(md_holidays.get(dt + relativedelta(days=1)), - "American Indian Heritage Day") - if dt.year >= 2010: - self.assertEqual(in_holidays.get(dt + relativedelta(days=1)), - "Lincoln's Birthday") - else: - self.assertNotEqual( - in_holidays.get(dt + relativedelta(days=1)), - "Lincoln's Birthday") - - def test_robert_lee_birthday(self): - ga_holidays = holidays.US(state='GA') - self.assertNotIn(date(1985, 11, 25), ga_holidays) - for dt in [date(2007, 11, 23), date(2008, 11, 28), date(2010, 11, 26), - date(2013, 11, 29), date(2014, 11, 28), date(2015, 11, 27), - date(2018, 11, 23), date(2019, 11, 29), date(2020, 11, 27)]: - self.assertNotIn(dt, self.holidays) - self.assertIn(dt, ga_holidays) - - def test_lady_of_camarin_day(self): - gu_holidays = holidays.US(state='GU') - for year in range(1945, 2100): - self.assertNotIn(date(year, 12, 8), self.holidays) - self.assertIn(date(year, 12, 8), gu_holidays) - - def test_christmas_eve(self): - as_holidays = holidays.US(state='AS') - ks_holidays = holidays.US(state='KS') - mi_holidays = holidays.US(state='MI') - nc_holidays = holidays.US(state='NC') - tx_holidays = holidays.US(state='TX') - wi_holidays = holidays.US(state='WI') - self.holidays.observed = False - for year in range(1900, 2050): - self.assertNotIn(date(year, 12, 24), self.holidays) - self.assertIn(date(year, 12, 24), as_holidays) - if year >= 2013: - f = ks_holidays.get(date(year, 12, 24)).find("Eve") - self.assertGreater(f, 0) - f = mi_holidays.get(date(year, 12, 24)).find("Eve") - self.assertGreater(f, 0) - f = nc_holidays.get(date(year, 12, 24)).find("Eve") - self.assertGreater(f, 0) - if year >= 2012: - f = wi_holidays.get(date(year, 12, 24)).find("Eve") - self.assertGreater(f, 0) - if year >= 1981: - f = tx_holidays.get(date(year, 12, 24)).find("Eve") - self.assertGreater(f, 0) - if year < 1981: - f = ks_holidays.get(date(year, 12, 24), "").find("Eve") - self.assertLess(f, 0) - f = mi_holidays.get(date(year, 12, 24), "").find("Eve") - self.assertLess(f, 0) - f = nc_holidays.get(date(year, 12, 24), "").find("Eve") - self.assertLess(f, 0) - f = tx_holidays.get(date(year, 12, 24), "").find("Eve") - self.assertLess(f, 0) - f = wi_holidays.get(date(year, 12, 24), "").find("Eve") - self.assertLess(f, 0) - self.assertIn(date(2016, 12, 23), as_holidays) - self.assertIn(date(2016, 12, 23), ks_holidays) - self.assertIn(date(2016, 12, 23), mi_holidays) - self.assertIn(date(2016, 12, 23), nc_holidays) - self.assertIn(date(2016, 12, 23), tx_holidays) - self.assertIn(date(2016, 12, 23), wi_holidays) - self.assertIn("Christmas Eve (Observed)", - as_holidays.get_list(date(2017, 12, 22))) - self.assertIn("Christmas Eve (Observed)", - ks_holidays.get_list(date(2017, 12, 22))) - self.assertIn("Christmas Eve (Observed)", - mi_holidays.get_list(date(2017, 12, 22))) - self.assertIn("Christmas Eve (Observed)", - nc_holidays.get_list(date(2017, 12, 22))) - self.assertIn("Christmas Eve (Observed)", - tx_holidays.get_list(date(2017, 12, 22))) - self.assertIn("Christmas Eve (Observed)", - wi_holidays.get_list(date(2017, 12, 22))) - - def test_christmas_day(self): - for year in range(1900, 2100): - dt = date(year, 12, 25) - self.assertIn(dt, self.holidays) - self.assertNotIn(dt + relativedelta(days=-1), self.holidays) - self.assertNotIn(dt + relativedelta(days=+1), self.holidays) - self.assertNotIn(date(2010, 12, 24), self.holidays) - self.assertNotIn(date(2016, 12, 26), self.holidays) - self.holidays.observed = True - self.assertIn(date(2010, 12, 24), self.holidays) - self.assertIn(date(2016, 12, 26), self.holidays) - - def test_day_after_christmas(self): - nc_holidays = holidays.US(state='NC', observed=False) - tx_holidays = holidays.US(state='TX', observed=False) - self.assertNotIn(date(2015, 12, 28), nc_holidays) - self.assertNotIn(date(2016, 12, 27), nc_holidays) - self.assertNotIn(date(2015, 12, 28), tx_holidays) - self.assertNotIn(date(2016, 12, 27), tx_holidays) - nc_holidays.observed = True - self.assertIn("Day After Christmas (Observed)", - nc_holidays.get_list(date(2015, 12, 28))) - self.assertIn("Day After Christmas (Observed)", - nc_holidays.get_list(date(2016, 12, 27))) - tx_holidays.observed = True - self.assertNotIn("Day After Christmas (Observed)", - tx_holidays.get_list(date(2015, 12, 28))) - self.assertNotIn("Day After Christmas (Observed)", - tx_holidays.get_list(date(2016, 12, 27))) - - def test_new_years_eve(self): - ky_holidays = holidays.US(state='KY') - mi_holidays = holidays.US(state='MI') - wi_holidays = holidays.US(state='WI') - self.assertNotIn(date(2012, 12, 31), ky_holidays) - self.assertNotIn(date(2012, 12, 31), mi_holidays) - self.assertNotIn(date(2011, 12, 31), wi_holidays) - self.assertIn(date(2012, 12, 31), wi_holidays) - for dt in [date(2013, 12, 31), date(2016, 12, 30)]: - self.assertNotIn(dt, self.holidays) - self.assertIn(dt, ky_holidays) - self.assertIn(dt, mi_holidays) - self.assertIn(dt, wi_holidays) - - -class TestNZ(unittest.TestCase): - - def setUp(self): - self.holidays = holidays.NZ(observed=True) - - def test_new_years(self): - for year in range(1900, 2100): - dt = date(year, 1, 1) - self.assertIn(dt, self.holidays) - for year, day in enumerate([1, 1, 1, 1, 3, # 2001-05 - 3, 1, 1, 1, 1, # 2006-10 - 3, 3, 1, 1, 1, # 2011-15 - 1, 3, 1, 1, 1, 1], # 2016-21 - 2001): - dt = date(year, 1, day) - self.assertIn(dt, self.holidays) - self.assertEqual(self.holidays[dt][:10], "New Year's") - self.assertNotIn("1893-01-01", self.holidays) - self.assertIn("1894-01-01", self.holidays) - - def test_day_after_new_years(self): - for year in range(1900, 2100): - dt = date(year, 1, 2) - self.assertIn(dt, self.holidays) - for year, day in enumerate([2, 2, 2, 2, 2, # 2001-05 - 2, 2, 2, 2, 4, # 2006-10 - 4, 2, 2, 2, 2, # 2011-15 - 4, 2, 2, 2, 2, 4], # 2016-21 - 2001): - dt = date(year, 1, day) - self.assertIn(dt, self.holidays) - self.assertEqual(self.holidays[dt][:10], "Day after ") - self.assertNotIn(date(2016, 1, 3), self.holidays) - - def test_waitangi_day(self): - ntl_holidays = holidays.NZ(prov='Northland') - for year, day in enumerate([3, 8, 7, 6, 5], 1964): - dt = date(year, 2, day) - self.assertIn(dt, ntl_holidays, dt) - self.assertEqual(ntl_holidays[dt][:8], "Waitangi") - for year in range(1900, 1974): - dt = date(year, 2, 6) - self.assertNotIn(dt, self.holidays) - for year in range(1974, 2100): - dt = date(year, 2, 6) - self.assertIn(dt, self.holidays) - for year, day in enumerate([6, 6, 6, 6, 6, # 2001-05 - 6, 6, 6, 6, 6, # 2006-10 - 6, 6, 6, 6, 6, # 2011-15 - 8, 6, 6, 6, 6, 8], # 2016-21 - 2001): - dt = date(year, 2, day) - self.assertIn(dt, self.holidays) - self.assertEqual(self.holidays[dt][:8], "Waitangi") - self.assertNotIn(date(2005, 2, 7), self.holidays) - self.assertNotIn(date(2010, 2, 8), self.holidays) - self.assertNotIn(date(2011, 2, 7), self.holidays) - - def test_good_friday(self): - 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.assertIn(dt, self.holidays) - self.assertNotIn(dt + relativedelta(days=-1), self.holidays) - self.assertNotIn(dt + relativedelta(days=+1), self.holidays) - - def test_easter_monday(self): - for dt in [date(1900, 4, 16), date(1901, 4, 8), date(1902, 3, 31), - date(1999, 4, 5), date(2010, 4, 5), - date(2018, 4, 2), date(2019, 4, 22), date(2020, 4, 13)]: - self.assertIn(dt, self.holidays) - self.assertNotIn(dt + relativedelta(days=-1), self.holidays) - self.assertNotIn(dt + relativedelta(days=+1), self.holidays) - - def test_anzac_day(self): - for year in range(1900, 1921): - dt = date(year, 4, 25) - self.assertNotIn(dt, self.holidays) - for year in range(1921, 2100): - dt = date(year, 4, 25) - self.assertIn(dt, self.holidays) - for year, day in enumerate([25, 25, 25, 25, 25, # 2001-05 - 25, 25, 25, 25, 25, # 2006-10 - 25, 25, 25, 25, 27, # 2011-15 - 25, 25, 25, 25, 27, 26], # 2016-21 - 2001): - dt = date(year, 4, day) - self.assertIn(dt, self.holidays, dt) - self.assertEqual(self.holidays[dt][:5], "Anzac") - self.assertNotIn(date(2009, 4, 27), self.holidays) - self.assertNotIn(date(2010, 4, 26), self.holidays) - - def test_sovereigns_birthday(self): - self.assertIn(date(1909, 11, 9), self.holidays) - self.assertIn(date(1936, 6, 23), self.holidays) - self.assertIn(date(1937, 6, 9), self.holidays) - self.assertIn(date(1940, 6, 3), self.holidays) - self.assertIn(date(1952, 6, 2), self.holidays) - for year in range(1912, 1936): - dt = date(year, 6, 3) - self.assertIn(dt, self.holidays) - self.assertEqual(self.holidays[dt], "King's Birthday") - for year, day in enumerate([4, 3, 2, 7, 6, # 2001-05 - 5, 4, 2, 1, 7, # 2006-10 - 6, 4, 3, 2, 1, # 2011-15 - 6, 5, 4, 3, 1, 7], # 2016-21 - 2001): - dt = date(year, 6, day) - self.assertIn(dt, self.holidays, dt) - self.assertEqual(self.holidays[dt], "Queen's Birthday") - - def test_labour_day(self): - for year, day in enumerate([22, 28, 27, 25, 24, # 2001-05 - 23, 22, 27, 26, 25, # 2006-10 - 24, 22, 28, 27, 26, # 2011-15 - 24, 23, 22, 28, 26, 25], # 2016-21 - 2001): - dt = date(year, 10, day) - self.assertIn(dt, self.holidays, dt) - self.assertEqual(self.holidays[dt], "Labour Day") - - def test_christmas_day(self): - self.holidays.observed = False - for year in range(1900, 2100): - dt = date(year, 12, 25) - self.assertIn(dt, self.holidays) - self.assertNotIn(dt + relativedelta(days=-1), self.holidays) - self.assertNotIn(date(2010, 12, 24), self.holidays) - self.assertNotEqual(self.holidays[date(2011, 12, 26)], - "Christmas Day (Observed)") - self.holidays.observed = True - self.assertEqual(self.holidays[date(2011, 12, 27)], - "Christmas Day (Observed)") - for year, day in enumerate([25, 25, 25, 27, 27, # 2001-05 - 25, 25, 25, 25, 27, # 2006-10 - 27, 25, 25, 25, 25, # 2011-15 - 27, 25, 25, 25, 25, 25], # 2016-21 - 2001): - dt = date(year, 12, day) - self.assertIn(dt, self.holidays, dt) - self.assertEqual(self.holidays[dt][:9], "Christmas") - - def test_boxing_day(self): - self.holidays.observed = False - for year in range(1900, 2100): - dt = date(year, 12, 26) - self.assertIn(dt, self.holidays) - self.assertNotIn(dt + relativedelta(days=+1), self.holidays) - self.assertNotIn(date(2009, 12, 28), self.holidays) - self.assertNotIn(date(2010, 12, 27), self.holidays) - self.holidays.observed = True - self.assertIn(date(2009, 12, 28), self.holidays) - self.assertIn(date(2010, 12, 27), self.holidays) - for year, day in enumerate([26, 26, 26, 28, 26, # 2001-05 - 26, 26, 26, 28, 28, # 2006-10 - 26, 26, 26, 26, 28, # 2011-15 - 26, 26, 26, 26, 28, 28], # 2016-21 - 2001): - dt = date(year, 12, day) - self.assertIn(dt, self.holidays, dt) - self.assertEqual(self.holidays[dt][:6], "Boxing") - - def test_auckland_anniversary_day(self): - auk_holidays = holidays.NZ(prov='Auckland') - for year, day in enumerate([29, 28, 27, 26, 31, # 2001-05 - 30, 29, 28, 26, 1, # 2006-10 - 31, 30, 28, 27, 26, # 2011-15 - 1, 30, 29, 28, 27, 1], # 2016-21 - 2001): - dt = date(year, 2 if day < 9 else 1, day) - self.assertIn(dt, auk_holidays, dt) - self.assertEqual(auk_holidays[dt], - "Auckland Anniversary Day") - - def test_taranaki_anniversary_day(self): - tki_holidays = holidays.NZ(prov='Taranaki') - for year, day in enumerate([12, 11, 10, 8, 14, # 2001-05 - 13, 12, 10, 9, 8, # 2006-10 - 14, 12, 11, 10, 9, # 2011-15 - 14, 13, 12, 11, 9, 8], # 2016-21 - 2001): - dt = date(year, 3, day) - self.assertIn(dt, tki_holidays, dt) - self.assertEqual(tki_holidays[dt], - "Taranaki Anniversary Day") - - def test_hawkes_bay_anniversary_day(self): - hkb_holidays = holidays.NZ(prov="Hawke's Bay") - for year, day in enumerate([19, 25, 24, 22, 21, # 2001-05 - 20, 19, 24, 23, 22, # 2006-10 - 21, 19, 25, 24, 23, # 2011-15 - 21, 20, 19, 25, 23, 22], # 2016-21 - 2001): - dt = date(year, 10, day) - self.assertIn(dt, hkb_holidays, dt) - self.assertEqual(hkb_holidays[dt], - "Hawke's Bay Anniversary Day") - - def test_wellington_anniversary_day(self): - wgn_holidays = holidays.NZ(prov='Wellington') - for year, day in enumerate([22, 21, 20, 19, 24, # 2001-05 - 23, 22, 21, 19, 25, # 2006-10 - 24, 23, 21, 20, 19, # 2011-15 - 25, 23, 22, 21, 20, 25], # 2016-21 - 2001): - dt = date(year, 1, day) - self.assertIn(dt, wgn_holidays, dt) - self.assertEqual(wgn_holidays[dt], - "Wellington Anniversary Day", dt) - - def test_marlborough_anniversary_day(self): - mbh_holidays = holidays.NZ(prov='Marlborough') - for year, day in enumerate([29, 4, 3, 1, 31, # 2001-05 - 30, 29, 3, 2, 1, # 2006-10 - 31, 29, 4, 3, 2, # 2011-15 - 31, 30, 29, 4, 2, 1], # 2016-21 - 2001): - dt = date(year, 11 if day < 9 else 10, day) - self.assertIn(dt, mbh_holidays, dt) - self.assertEqual(mbh_holidays[dt], - "Marlborough Anniversary Day", dt) - - def test_nelson_anniversary_day(self): - nsn_holidays = holidays.NZ(prov='Nelson') - for year, day in enumerate([29, 4, 3, 2, 31, # 2001-05 - 30, 29, 4, 2, 1, # 2006-10 - 31, 30, 4, 3, 2, # 2011-15 - 1, 30, 29, 4, 3, 1], # 2016-21 - 2001): - dt = date(year, 2 if day < 9 else 1, day) - self.assertIn(dt, nsn_holidays, dt) - self.assertEqual(nsn_holidays[dt], - "Nelson Anniversary Day", dt) - - def test_canterbury_anniversary_day(self): - can_holidays = holidays.NZ(prov='Canterbury') - for year, day in enumerate([16, 15, 14, 12, 11, # 2001-05 - 17, 16, 14, 13, 12, # 2006-10 - 11, 16, 15, 14, 13, # 2011-15 - 11, 17, 16, 15, 13, 12], # 2016-21 - 2001): - dt = date(year, 11, day) - self.assertIn(dt, can_holidays, dt) - self.assertEqual(can_holidays[dt], - "Canterbury Anniversary Day", dt) - - def test_south_canterbury_anniversary_day(self): - stc_holidays = holidays.NZ(prov='South Canterbury') - for year, day in enumerate([24, 23, 22, 27, 26, # 2001-05 - 25, 24, 22, 28, 27, # 2006-10 - 26, 24, 23, 22, 28, # 2011-15 - 26, 25, 24, 23, 28, 27], # 2016-21 - 2001): - dt = date(year, 9, day) - self.assertIn(dt, stc_holidays, dt) - self.assertEqual(stc_holidays[dt], - "South Canterbury Anniversary Day", dt) - - def test_westland_anniversary_day(self): - wtc_holidays = holidays.NZ(prov='Westland') - for year, day in enumerate([3, 2, 1, 29, 5, # 2001-05 - 4, 3, 1, 30, 29, # 2006-10 - 28, 3, 2, 1, 30, # 2011-15 - 28, 4, 3, 2, 30, 29], # 2016-21 - 2001): - dt = date(year, 12 if day < 9 else 11, day) - self.assertIn(dt, wtc_holidays, dt) - self.assertEqual(wtc_holidays[dt], - "Westland Anniversary Day", dt) - - def test_otago_anniversary_day(self): - ota_holidays = holidays.NZ(prov='Otago') - for year, day in enumerate([26, 25, 24, 22, 21, # 2001-05 - 20, 26, 25, 23, 22, # 2006-10 - 21, 26, 25, 24, 23, # 2011-15 - 21, 20, 26, 25, 23, 22], # 2016-21 - 2001): - dt = date(year, 3, day) - self.assertIn(dt, ota_holidays, dt) - self.assertEqual(ota_holidays[dt], - "Otago Anniversary Day", dt) - - def test_southland_anniversary_day(self): - stl_holidays = holidays.NZ(prov='Southland') - for year, day in enumerate([15, 14, 20, 19, 17, # 2001-05 - 16, 15, 14, 19, 18, 17], # 2006-11 - 2001): - dt = date(year, 1, day) - self.assertIn(dt, stl_holidays, dt) - self.assertEqual(stl_holidays[dt], - "Southland Anniversary Day", dt) - for year, (month, day) in enumerate([(4, 10), (4, 2), (4, 22), - (4, 7), (3, 29), (4, 18), - (4, 3), (4, 23), (4, 14), - (4, 6)], 2012): - dt = date(year, month, day) - self.assertIn(dt, stl_holidays, dt) - self.assertEqual(stl_holidays[dt], - "Southland Anniversary Day", dt) - - def test_chatham_islands_anniversary_day(self): - cit_holidays = holidays.NZ(prov='Chatham Islands') - for year, day in enumerate([3, 2, 1, 29, 28, # 2001-05 - 27, 3, 1, 30, 29, # 2006-10 - 28, 3, 2, 1, 30, # 2011-15 - 28, 27, 3, 2, 30, 29], # 2016-21 - 2001): - dt = date(year, 12 if day < 9 else 11, day) - self.assertIn(dt, cit_holidays, dt) - self.assertEqual(cit_holidays[dt], - "Chatham Islands Anniversary Day", dt) - - def test_all_holidays_present(self): - nz_1969 = sum(holidays.NZ(years=[1969], prov=p) - for p in holidays.NZ.PROVINCES) - holidays_in_1969 = sum((nz_1969.get_list(key) for key in nz_1969), []) - nz_2015 = sum(holidays.NZ(years=[2015], prov=p) - for p in holidays.NZ.PROVINCES) - holidays_in_2015 = sum((nz_2015.get_list(key) for key in nz_2015), []) - nz_1974 = sum(holidays.NZ(years=[1974], prov=p) - for p in holidays.NZ.PROVINCES) - holidays_in_1974 = sum((nz_1974.get_list(key) for key in nz_1974), []) - all_holidays = ["New Year's Day", - "Day after New Year's Day", - "Waitangi Day", - "Good Friday", - "Easter Monday", - "Anzac Day", - "Queen's Birthday", - "Labour Day", - "Christmas Day", - "Boxing Day", - "Auckland Anniversary Day", - "Taranaki Anniversary Day", - "Hawke's Bay Anniversary Day", - "Wellington Anniversary Day", - "Marlborough Anniversary Day", - "Nelson Anniversary Day", - "Canterbury Anniversary Day", - "South Canterbury Anniversary Day", - "Westland Anniversary Day", - "Otago Anniversary Day", - "Southland Anniversary Day", - "Chatham Islands Anniversary Day", - "Queen's Birthday", - "Labour Day", - "Christmas Day", - "Boxing Day"] - for holiday in all_holidays: - self.assertIn(holiday, holidays_in_1969, holiday) - self.assertIn(holiday, holidays_in_2015, holiday) - all_holidays.remove("Waitangi Day") - all_holidays.insert(2, "New Zealand Day") - for holiday in all_holidays: - self.assertIn(holiday, holidays_in_1974, holiday) - self.assertNotIn("Waitangi Day", holidays_in_1974) - - -class TestAU(unittest.TestCase): - - def setUp(self): - self.holidays = holidays.AU(observed=True) - self.state_hols = {state: holidays.AU(observed=True, prov=state) - for state in holidays.AU.PROVINCES} - - def test_new_years(self): - for year in range(1900, 2100): - dt = date(year, 1, 1) - self.assertIn(dt, self.holidays) - for year, day in enumerate([3, 2, 1, 1, 1, # 2011-15 - 1, 2, 1, 1, 1, 1], # 2016-21 - 2011): - dt = date(year, 1, day) - for state, hols in self.state_hols.items(): - self.assertIn(dt, hols, (state, dt)) - self.assertEqual(hols[dt][:10], "New Year's", state) - - def test_australia_day(self): - for year, day in enumerate([26, 26, 28, 27, 26, # 2011-15 - 26, 26, 26, 28, 27, 26], # 2016-21 - 2011): - jan26 = date(year, 1, 26) - dt = date(year, 1, day) - self.assertIn(jan26, self.holidays, dt) - self.assertEqual(self.holidays[jan26], "Australia Day") - self.assertIn(dt, self.holidays, dt) - self.assertEqual(self.holidays[dt][:10], "Australia ") - for state in holidays.AU.PROVINCES: - self.assertIn(jan26, self.state_hols[state], (state, dt)) - self.assertEqual(self.state_hols[state][jan26], - "Australia Day") - self.assertIn(dt, self.state_hols[state], (state, dt)) - self.assertEqual(self.state_hols[state][dt][:10], "Australia ") - self.assertNotIn(date(2016, 1, 27), self.holidays) - self.assertNotIn(date(1887, 1, 26), self.holidays) - self.assertNotIn(date(1934, 1, 26), self.state_hols['SA']) - for dt in [date(1889, 1, 26), date(1936, 1, 26), date(1945, 1, 26)]: - self.assertIn(dt, self.state_hols['NSW'], dt) - self.assertEqual(self.state_hols['NSW'][dt], "Anniversary Day") - - def test_good_friday(self): - 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.assertIn(dt, self.holidays) - self.assertEqual(self.holidays[dt], "Good Friday") - - def test_easter_saturday(self): - for dt in [date(1900, 4, 14), date(1901, 4, 6), date(1902, 3, 29), - date(1999, 4, 3), date(2000, 4, 22), date(2010, 4, 3), - date(2018, 3, 31), date(2019, 4, 20), date(2020, 4, 11)]: - for state in ['ACT', 'NSW', 'NT', 'QLD', 'SA', 'VIC']: - self.assertIn(dt, self.state_hols[state], (state, dt)) - self.assertEqual(self.state_hols[state][dt], "Easter Saturday") - for state in ['TAS', 'WA']: - self.assertNotIn(dt, self.state_hols[state], (state, dt)) - - def test_easter_sunday(self): - for dt in [date(1900, 4, 15), date(1901, 4, 7), date(1902, 3, 30), - date(1999, 4, 4), date(2010, 4, 4), - date(2018, 4, 1), date(2019, 4, 21), date(2020, 4, 12)]: - for state in ['NSW', 'ACT', 'QLD', 'VIC']: - self.assertIn(dt, self.state_hols[state], (state, dt)) - self.assertEqual(self.state_hols[state][dt], "Easter Sunday") - for state in ['NT', 'SA', 'TAS', 'WA']: - self.assertNotIn(dt, self.state_hols[state], (state, dt)) - - def test_easter_monday(self): - for dt in [date(1900, 4, 16), date(1901, 4, 8), date(1902, 3, 31), - date(1999, 4, 5), date(2010, 4, 5), - date(2018, 4, 2), date(2019, 4, 22), date(2020, 4, 13)]: - self.assertIn(dt, self.holidays) - self.assertEqual(self.holidays[dt], "Easter Monday") - self.assertNotIn(dt + relativedelta(days=+1), self.holidays) - - def test_bank_holiday(self): - for dt in [date(1912, 8, 5), date(1913, 8, 4), - date(1999, 8, 2), date(2018, 8, 6), date(2020, 8, 3)]: - self.assertIn(dt, self.state_hols['NSW'], dt) - self.assertEqual(self.state_hols['NSW'][dt], "Bank Holiday") - - def test_labour_day(self): - for year, day in enumerate([7, 5, 4, 3, 2, 7, 6, ], 2011): - dt = date(year, 3, day) - self.assertIn(dt, self.state_hols['WA'], dt) - self.assertEqual(self.state_hols['WA'][dt], "Labour Day") - for year, day in enumerate([10, 9, 14], 2014): - dt = date(year, 3, day) - self.assertNotIn(dt, self.holidays, dt) - self.assertIn(dt, self.state_hols['VIC'], dt) - self.assertEqual(self.state_hols['VIC'][dt], "Labour Day") - - def test_anzac_day(self): - for year in range(1900, 1921): - dt = date(year, 4, 25) - self.assertNotIn(dt, self.holidays) - for year in range(1921, 2100): - dt = date(year, 4, 25) - self.assertIn(dt, self.holidays) - for dt in [date(2015, 4, 27), date(2020, 4, 27)]: - self.assertNotIn(dt, self.holidays, dt) - for state in ['NT', 'WA']: - self.assertIn(dt, self.state_hols[state], (state, dt)) - self.assertEqual(self.state_hols[state][dt][:5], "Anzac") - for state in ['ACT', 'QLD', 'SA', 'NSW', 'TAS', 'VIC']: - self.assertNotIn(dt, self.state_hols[state], (state, dt)) - dt = date(2021, 4, 26) - for state in ['ACT', 'NT', 'QLD', 'SA', 'WA']: - self.assertIn(dt, self.state_hols[state], (state, dt)) - self.assertEqual(self.state_hols[state][dt][:5], "Anzac") - for state in ['NSW', 'TAS', 'VIC']: - self.assertNotIn(dt, self.state_hols[state], (state, dt)) - - def test_western_australia_day(self): - for year, day in enumerate([4, 3, 2], 2012): - dt = date(year, 6, day) - self.assertIn(dt, self.state_hols['WA'], dt) - self.assertEqual(self.state_hols['WA'][dt], "Foundation Day") - for year, day in enumerate([1, 6, 5], 2015): - dt = date(year, 6, day) - self.assertIn(dt, self.state_hols['WA'], dt) - self.assertEqual(self.state_hols['WA'][dt], - "Western Australia Day") - - def test_adelaide_cup(self): - for dt in [date(2015, 3, 9), date(2016, 3, 14), date(2017, 3, 13)]: - self.assertIn(dt, self.state_hols['SA'], dt) - self.assertEqual(self.state_hols['SA'][dt], "Adelaide Cup") - - def test_queens_birthday(self): - # Western Australia - for dt in [date(2012, 10, 1), date(2013, 9, 30), date(2014, 9, 29), - date(2015, 9, 28), date(2016, 9, 26), date(2017, 9, 25)]: - self.assertIn(dt, self.state_hols['WA'], dt) - self.assertEqual(self.state_hols['WA'][dt], "Queen's Birthday") - # Other states except Queensland - other_states = [ - date(2010, 6, 14), date(2011, 6, 13), date(2012, 6, 11), - date(2013, 6, 10), date(2014, 6, 9), date(2015, 6, 8), - date(2016, 6, 13), date(2017, 6, 12), date(2018, 6, 11)] - for dt in other_states: - self.assertIn(dt, self.state_hols['NSW'], dt) - self.assertIn(dt, self.state_hols['VIC'], dt) - self.assertIn(dt, self.state_hols['ACT'], dt) - # Queensland - qld_dates = other_states[:-3] - qld_dates.remove(date(2012, 6, 11)) - qld_dates.extend([date(2012, 10, 1), date(2016, 10, 3), - date(2017, 10, 2), date(2018, 10, 1)]) - for dt in qld_dates: - self.assertIn(dt, self.state_hols['QLD'], dt) - self.assertEqual(self.state_hols['QLD'][dt], "Queen's Birthday") - self.assertIn(date(2012, 6, 11), self.state_hols['QLD']) - - def test_picnic_day(self): - for dt in [date(2015, 8, 3), date(2016, 8, 1)]: - self.assertIn(dt, self.state_hols['NT'], dt) - self.assertEqual(self.state_hols['NT'][dt], "Picnic Day") - - def test_family_and_community_day(self): - for dt in [date(2007, 11, 6), date(2008, 11, 4), date(2009, 11, 3), - date(2010, 9, 26), date(2011, 10, 10), date(2012, 10, 8), - date(2013, 9, 30), date(2014, 9, 29), date(2015, 9, 28), - date(2016, 9, 26), date(2017, 9, 25)]: - self.assertIn(dt, self.state_hols['ACT'], dt) - self.assertEqual(self.state_hols['ACT'][dt], - "Family & Community Day") - - def test_reconciliation_day(self): - for dt in [date(2018, 5, 28), date(2019, 5, 27), date(2020, 6, 1)]: - self.assertIn(dt, self.state_hols['ACT'], dt) - self.assertEqual(self.state_hols['ACT'][dt], "Reconciliation Day") - - def test_grand_final_day(self): - dt = date(2019, 9, 27) - dt_2020 = date(2020, 10, 23) - dt_2020_old = date(2020, 9, 25) - self.assertIn(dt, self.state_hols['VIC'], dt) - self.assertEqual(self.state_hols['VIC'][dt], "Grand Final Day") - self.assertIn(dt_2020, self.state_hols['VIC'], dt_2020) - self.assertEqual(self.state_hols['VIC'][dt_2020], "Grand Final Day") - self.assertNotIn(dt_2020_old, self.state_hols['VIC'], dt_2020_old) - - def test_melbourne_cup(self): - for dt in [date(2014, 11, 4), date(2015, 11, 3), date(2016, 11, 1)]: - self.assertIn(dt, self.state_hols['VIC'], dt) - self.assertEqual(self.state_hols['VIC'][dt], "Melbourne Cup") - - def test_royal_queensland_show(self): - for year, day in enumerate([15, 14, 14, 11, 10, 16], 2018): - dt = date(year, 8, day) - self.assertIn(dt, self.state_hols['QLD'], dt) - self.assertEqual(self.state_hols['QLD'][dt], - "The Royal Queensland Show") - - def test_christmas_day(self): - self.holidays.observed = False - for year in range(1900, 2100): - dt = date(year, 12, 25) - self.assertIn(dt, self.holidays) - self.assertNotIn(dt + relativedelta(days=-1), self.holidays) - self.assertNotIn(date(2010, 12, 24), self.holidays) - self.assertNotEqual(self.holidays[date(2011, 12, 26)], - "Christmas Day (Observed)") - self.holidays.observed = True - self.assertEqual(self.holidays[date(2011, 12, 27)], - "Christmas Day (Observed)") - for year, day in enumerate([25, 25, 25, 27, 27, # 2001-05 - 25, 25, 25, 25, 27, # 2006-10 - 27, 25, 25, 25, 25, # 2011-15 - 27, 25, 25, 25, 25, 25], # 2016-21 - 2001): - dt = date(year, 12, day) - self.assertIn(dt, self.holidays, dt) - self.assertEqual(self.holidays[dt][:9], "Christmas") - - def test_boxing_day(self): - self.holidays.observed = False - for year in range(1900, 2100): - dt = date(year, 12, 26) - self.assertIn(dt, self.holidays) - self.assertNotIn(dt + relativedelta(days=+1), self.holidays) - self.assertNotIn(date(2009, 12, 28), self.holidays) - self.assertNotIn(date(2010, 12, 27), self.holidays) - self.holidays.observed = True - self.assertIn(date(2009, 12, 28), self.holidays) - self.assertIn(date(2010, 12, 27), self.holidays) - for year, day in enumerate([26, 26, 26, 28, 26, # 2001-05 - 26, 26, 26, 28, 28, # 2006-10 - 26, 26, 26, 26, 28, # 2011-15 - 26, 26, 26, 26, 28, 28], # 2016-21 - 2001): - dt = date(year, 12, day) - self.assertIn(dt, self.holidays, dt) - self.assertEqual(self.holidays[dt][:6], "Boxing") - - def test_all_holidays(self): - au = sum(holidays.AU(years=[1957, 2012, 2015], prov=p) - for p in holidays.AU.PROVINCES) - holidays_found = sum((au.get_list(key) for key in au), []) - all_holidays = ["New Year's Day", - "Australia Day", - "Adelaide Cup", - "Canberra Day", - "Good Friday", - "Easter Saturday", - "Easter Sunday", - "Easter Monday", - "Anzac Day", - "Queen's Birthday", - "Western Australia Day", - "Family & Community Day", - "Labour Day", - "Eight Hours Day", - "May Day", - "Picnic Day", - "Melbourne Cup", - "Christmas Day", - "Proclamation Day", - "Boxing Day"] - for holiday in all_holidays: - self.assertIn(holiday, holidays_found, holiday) - - -class TestDE(unittest.TestCase): - - def setUp(self): - self.holidays = holidays.DE() - self.prov_hols = {prov: holidays.DE(prov=prov) - for prov in holidays.DE.PROVINCES} - - def test_no_data_before_1990(self): - de_1989 = sum(holidays.DE(years=[1989], prov=p) - for p in holidays.DE.PROVINCES) - self.assertEqual(len(de_1989), 0) - - def test_all_holidays_present(self): - de_2015 = sum(holidays.DE(years=[2015], prov=p) - for p in holidays.DE.PROVINCES) - in_2015 = sum((de_2015.get_list(key) for key in de_2015), []) - all_de = ["Neujahr", - "Heilige Drei Könige", - "Karfreitag", - "Ostersonntag", - "Ostermontag", - "Erster Mai", - "Christi Himmelfahrt", - "Pfingstsonntag", - "Pfingstmontag", - "Fronleichnam", - "Mariä Himmelfahrt", - "Tag der Deutschen Einheit", - "Reformationstag", - "Allerheiligen", - "Buß- und Bettag", - "Erster Weihnachtstag", - "Zweiter Weihnachtstag"] - - for holiday in all_de: - self.assertIn(holiday, in_2015, "missing: {}".format(holiday)) - for holiday in in_2015: - self.assertIn(holiday, all_de, "extra: {}".format(holiday)) - - def test_fixed_holidays(self): - fixed_days_whole_country = ( - (1, 1), # Neujahr - (5, 1), # Maifeiertag - (10, 3), # Tag der Deutschen Einheit - (12, 25), # Erster Weihnachtstag - (12, 26), # Zweiter Weihnachtstag - ) - - for y, (m, d) in product(range(1991, 2050), fixed_days_whole_country): - self.assertIn(date(y, m, d), self.holidays) - - def test_tag_der_deutschen_einheit_in_1990(self): - self.assertIn(date(1990, 10, 3), self.holidays) - - def test_heilige_drei_koenige(self): - provinces_that_have = {'BW', 'BY', 'BYP', 'ST'} - provinces_that_dont = set(holidays.DE.PROVINCES) - provinces_that_have - - for province, year in product(provinces_that_have, range(1991, 2050)): - self.assertIn(date(year, 1, 6), self.prov_hols[province]) - for province, year in product(provinces_that_dont, range(1991, 2050)): - self.assertNotIn(date(year, 1, 6), self.prov_hols[province]) - - def test_karfreitag(self): - known_good = [(2014, 4, 18), (2015, 4, 3), (2016, 3, 25), - (2017, 4, 14), (2018, 3, 30), (2019, 4, 19), - (2020, 4, 10), (2021, 4, 2), (2022, 4, 15), - (2023, 4, 7), (2024, 3, 29)] - - for province, (y, m, d) in product(holidays.DE.PROVINCES, known_good): - self.assertIn(date(y, m, d), self.prov_hols[province]) - - def test_ostersonntag(self): - known_good = [(2014, 4, 20), (2015, 4, 5), (2016, 3, 27), - (2017, 4, 16), (2018, 4, 1), (2019, 4, 21), - (2020, 4, 12), (2021, 4, 4), (2022, 4, 17), - (2023, 4, 9), (2024, 3, 31)] - provinces_that_have = {"BB"} - provinces_that_dont = set(holidays.DE.PROVINCES) - provinces_that_have - - for province, (y, m, d) in product(provinces_that_have, known_good): - self.assertIn(date(y, m, d), self.prov_hols[province]) - for province, (y, m, d) in product(provinces_that_dont, known_good): - self.assertNotIn(date(y, m, d), self.prov_hols[province]) - - def test_ostermontag(self): - known_good = [(2014, 4, 21), (2015, 4, 6), (2016, 3, 28), - (2017, 4, 17), (2018, 4, 2), (2019, 4, 22), - (2020, 4, 13), (2021, 4, 5), (2022, 4, 18), - (2023, 4, 10), (2024, 4, 1)] - - for province, (y, m, d) in product(holidays.DE.PROVINCES, known_good): - self.assertIn(date(y, m, d), self.prov_hols[province]) - - def test_75_jahrestag_beendigung_zweiter_weltkrieg(self): - known_good = [(2020, 5, 8)] - provinces_that_have = {"BE"} - provinces_that_dont = set(holidays.DE.PROVINCES) - provinces_that_have - - for province, (y, m, d) in product(provinces_that_have, known_good): - self.assertIn(date(y, m, d), self.prov_hols[province]) - for province, (y, m, d) in product(provinces_that_dont, known_good): - self.assertNotIn(date(y, m, d), self.prov_hols[province]) - - def test_christi_himmelfahrt(self): - known_good = [(2014, 5, 29), (2015, 5, 14), (2016, 5, 5), - (2017, 5, 25), (2018, 5, 10), (2019, 5, 30), - (2020, 5, 21), (2021, 5, 13), (2022, 5, 26), - (2023, 5, 18), (2024, 5, 9)] - - for province, (y, m, d) in product(holidays.DE.PROVINCES, known_good): - self.assertIn(date(y, m, d), self.prov_hols[province]) - - def test_weltkindertag(self): - known_good = [(2019, 9, 20), (2021, 9, 20)] - - provinces_that_have = {"TH"} - provinces_that_dont = set(holidays.DE.PROVINCES) - provinces_that_have - for province, (y, m, d) in product(provinces_that_have, known_good): - self.assertIn(date(y, m, d), self.prov_hols[province]) - for province, (y, m, d) in product(provinces_that_dont, known_good): - self.assertNotIn(date(y, m, d), self.prov_hols[province]) - - def test_frauentag(self): - known_good = [(2019, 3, 8), ] - - provinces_that_have = {"BE"} - provinces_that_dont = set(holidays.DE.PROVINCES) - provinces_that_have - for province, (y, m, d) in product(provinces_that_have, known_good): - self.assertIn(date(y, m, d), self.prov_hols[province]) - for province, (y, m, d) in product(provinces_that_dont, known_good): - self.assertNotIn(date(y, m, d), self.prov_hols[province]) - - def test_pfingstsonntag(self): - known_good = [(2014, 6, 8), (2015, 5, 24), (2016, 5, 15), - (2017, 6, 4), (2018, 5, 20), (2019, 6, 9), - (2020, 5, 31), (2021, 5, 23), (2022, 6, 5), - (2023, 5, 28), (2024, 5, 19)] - provinces_that_have = {"BB"} - provinces_that_dont = set(holidays.DE.PROVINCES) - provinces_that_have - - for province, (y, m, d) in product(provinces_that_have, known_good): - self.assertIn(date(y, m, d), self.prov_hols[province]) - for province, (y, m, d) in product(provinces_that_dont, known_good): - self.assertNotIn(date(y, m, d), self.prov_hols[province]) - - def test_pfingstmontag(self): - known_good = [(2014, 6, 9), (2015, 5, 25), (2016, 5, 16), - (2017, 6, 5), (2018, 5, 21), (2019, 6, 10), - (2020, 6, 1), (2021, 5, 24), (2022, 6, 6), - (2023, 5, 29), (2024, 5, 20)] - - for province, (y, m, d) in product(holidays.DE.PROVINCES, known_good): - self.assertIn(date(y, m, d), self.prov_hols[province]) - - def test_fronleichnam(self): - known_good = [(2014, 6, 19), (2015, 6, 4), (2016, 5, 26), - (2017, 6, 15), (2018, 5, 31), (2019, 6, 20), - (2020, 6, 11), (2021, 6, 3), (2022, 6, 16), - (2023, 6, 8), (2024, 5, 30)] - provinces_that_have = {'BW', 'BY', 'BYP', 'HE', 'NW', 'RP', 'SL'} - provinces_that_dont = set(holidays.DE.PROVINCES) - provinces_that_have - - for province, (y, m, d) in product(provinces_that_have, known_good): - self.assertIn(date(y, m, d), self.prov_hols[province]) - for province, (y, m, d) in product(provinces_that_dont, known_good): - self.assertNotIn(date(y, m, d), self.prov_hols[province]) - - def test_mariae_himmelfahrt(self): - provinces_that_have = {'BY', 'SL'} - provinces_that_dont = set(holidays.DE.PROVINCES) - provinces_that_have - - for province, year in product(provinces_that_have, range(1991, 2050)): - self.assertIn(date(year, 8, 15), self.prov_hols[province]) - for province, year in product(provinces_that_dont, range(1991, 2050)): - self.assertNotIn(date(year, 8, 15), self.prov_hols[province]) - - def test_reformationstag(self): - prov_that_have = {'BB', 'MV', 'SN', 'ST', 'TH'} - prov_yes_since_2018 = prov_that_have.union({'HB', 'HH', 'NI', 'SH'}) - prov_that_dont = set(holidays.DE.PROVINCES) - prov_that_have - prov_not_since_2018 = set(holidays.DE.PROVINCES) - prov_yes_since_2018 - - for province, year in product(prov_that_have, range(1991, 2050)): - # in 2017 all states got the reformationstag for that year - if year == 2017: - continue - self.assertIn(date(year, 10, 31), self.prov_hols[province]) - # additional provinces got this holiday 2018 - for province, year in product(prov_yes_since_2018, range(2018, 2050)): - self.assertIn(date(year, 10, 31), self.prov_hols[province]) - for province, year in product(prov_that_dont, range(1991, 2017)): - self.assertNotIn(date(year, 10, 31), self.prov_hols[province]) - for province, year in product(prov_not_since_2018, range(2018, 2050)): - self.assertNotIn(date(year, 10, 31), self.prov_hols[province]) - # check the 2017 case where all states have the reformationstag - for province in holidays.DE.PROVINCES: - self.assertIn(date(2017, 10, 31), self.prov_hols[province]) - - def test_allerheiligen(self): - provinces_that_have = {'BW', 'BY', 'BYP', 'NW', 'RP', 'SL'} - provinces_that_dont = set(holidays.DE.PROVINCES) - provinces_that_have - - for province, year in product(provinces_that_have, range(1991, 2050)): - self.assertIn(date(year, 11, 1), self.prov_hols[province]) - for province, year in product(provinces_that_dont, range(1991, 2050)): - self.assertNotIn(date(year, 11, 1), self.prov_hols[province]) - - def test_buss_und_bettag(self): - known_good = [(2014, 11, 19), (2015, 11, 18), (2016, 11, 16), - (2017, 11, 22), (2018, 11, 21), (2019, 11, 20), - (2020, 11, 18), (2021, 11, 17), (2022, 11, 16), - (2023, 11, 22), (2024, 11, 20)] - provinces_that_have = {'SN'} - provinces_that_dont = set(holidays.DE.PROVINCES) - provinces_that_have - - for province, (y, m, d) in product(provinces_that_have, known_good): - self.assertIn(date(y, m, d), self.prov_hols[province]) - for province, (y, m, d) in product(provinces_that_dont, known_good): - self.assertNotIn(date(y, m, d), self.prov_hols[province]) - - def test_internationaler_frauentag(self): - prov_that_have = {'BE'} - prov_that_dont = set(holidays.DE.PROVINCES) - prov_that_have - - for province, year in product( - holidays.DE.PROVINCES, range(1991, 2018)): - self.assertNotIn(date(year, 3, 8), self.prov_hols[province]) - for province, year in product(prov_that_have, range(2019, 2050)): - self.assertIn(date(year, 3, 8), self.prov_hols[province]) - for province, year in product(prov_that_dont, range(2019, 2050)): - self.assertNotIn(date(year, 3, 8), self.prov_hols[province]) - - -class TestAT(unittest.TestCase): - - def setUp(self): - self.holidays = holidays.AT() - - def test_new_years(self): - for year in range(1900, 2100): - dt = date(year, 1, 1) - self.assertIn(dt, self.holidays) - self.assertNotIn(dt + relativedelta(days=-1), self.holidays) - self.assertNotIn(dt + relativedelta(days=+1), self.holidays) - - def test_christmas(self): - for year in range(1900, 2100): - dt = date(year, 12, 25) - self.assertIn(dt, self.holidays) - self.assertIn(dt + relativedelta(days=+1), self.holidays) - self.assertNotIn(dt + relativedelta(days=-1), self.holidays) - self.assertNotIn(dt + relativedelta(days=+2), self.holidays) - - def test_easter_monday(self): - for dt in [date(1900, 4, 16), date(1901, 4, 8), date(1902, 3, 31), - date(1999, 4, 5), date(2000, 4, 24), date(2010, 4, 5), - date(2018, 4, 2), date(2019, 4, 22), date(2020, 4, 13)]: - self.assertIn(dt, self.holidays) - self.assertNotIn(dt + relativedelta(days=-1), self.holidays) - self.assertNotIn(dt + relativedelta(days=+1), self.holidays) - - def test_national_day(self): - for year in range(1919, 1934): - dt = date(year, 11, 12) - self.assertIn(dt, self.holidays) - self.assertNotIn(dt + relativedelta(days=-1), self.holidays) - self.assertNotIn(dt + relativedelta(days=+1), self.holidays) - for year in range(1967, 2100): - dt = date(year, 10, 26) - self.assertIn(dt, self.holidays) - self.assertNotIn(dt + relativedelta(days=-1), self.holidays) - self.assertNotIn(dt + relativedelta(days=+1), self.holidays) - - def test_all_holidays_present(self): - at_2015 = holidays.AT(years=[2015]) - all_holidays = ["Neujahr", - "Heilige Drei Könige", - "Ostermontag", - "Staatsfeiertag", - "Christi Himmelfahrt", - "Pfingstmontag", - "Fronleichnam", - "Mariä Himmelfahrt", - "Nationalfeiertag", - "Allerheiligen", - "Mariä Empfängnis", - "Christtag", - "Stefanitag"] - for holiday in all_holidays: - self.assertIn(holiday, at_2015.values()) - - -class TestDK(unittest.TestCase): - - def setUp(self): - self.holidays = holidays.DK() - - def test_2016(self): - # http://www.officeholidays.com/countries/denmark/2016.php - self.assertIn(date(2016, 1, 1), self.holidays) - self.assertIn(date(2016, 3, 24), self.holidays) - self.assertIn(date(2016, 3, 25), self.holidays) - self.assertIn(date(2016, 3, 28), self.holidays) - self.assertIn(date(2016, 4, 22), self.holidays) - self.assertIn(date(2016, 5, 5), self.holidays) - self.assertIn(date(2016, 5, 16), self.holidays) - self.assertIn(date(2016, 12, 25), self.holidays) - - -class TestUK(unittest.TestCase): - - def setUp(self): - self.holidays = holidays.England() - self.holidays = holidays.Wales() - self.holidays = holidays.Scotland() - self.holidays = holidays.IsleOfMan() - self.holidays = holidays.NorthernIreland() - self.holidays = holidays.UK() - - def test_new_years(self): - for year in range(1974, 2100): - dt = date(year, 1, 1) - self.assertIn(dt, self.holidays) - if year == 2000: - self.assertIn(dt + relativedelta(days=-1), self.holidays) - else: - self.assertNotIn(dt + relativedelta(days=-1), self.holidays) - - def test_good_friday(self): - 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.assertIn(dt, self.holidays) - self.assertNotIn(dt + relativedelta(days=-1), self.holidays) - self.assertNotIn(dt + relativedelta(days=+1), self.holidays) - - def test_easter_monday(self): - for dt in [date(1900, 4, 16), date(1901, 4, 8), date(1902, 3, 31), - date(1999, 4, 5), date(2000, 4, 24), date(2010, 4, 5), - date(2018, 4, 2), date(2019, 4, 22), date(2020, 4, 13)]: - self.assertIn(dt, self.holidays) - self.assertNotIn(dt + relativedelta(days=-1), self.holidays) - self.assertNotIn(dt + relativedelta(days=+1), self.holidays) - - def test_royal_weddings(self): - for dt in [date(1981, 7, 29), date(2011, 4, 29)]: - self.assertIn(dt, self.holidays) - self.assertNotIn(dt + relativedelta(years=-1), self.holidays) - self.assertNotIn(dt + relativedelta(years=+1), self.holidays) - - def test_queens_jubilees(self): - for dt in [date(1977, 6, 7), date(2002, 6, 3), date(2012, 6, 5), date(2022, 6, 3)]: - self.assertIn(dt, self.holidays) - self.assertNotIn(dt + relativedelta(years=-1), self.holidays) - self.assertNotIn(dt + relativedelta(years=+1), self.holidays) - - def test_may_day(self): - for dt in [date(1978, 5, 1), date(1979, 5, 7), date(1980, 5, 5), - date(1999, 5, 3), date(2000, 5, 1), date(2010, 5, 3), - date(2018, 5, 7), date(2019, 5, 6), date(2020, 5, 8)]: - self.assertIn(dt, self.holidays) - self.assertNotIn(dt + relativedelta(days=-1), self.holidays) - self.assertNotIn(dt + relativedelta(days=+1), self.holidays) - self.assertNotIn(date(2020, 5, 4), self.holidays) - - def test_spring_bank_holiday(self): - for dt in [date(1978, 5, 29), date(1979, 5, 28), date(1980, 5, 26), - date(1999, 5, 31), date(2000, 5, 29), date(2010, 5, 31), - date(2018, 5, 28), date(2019, 5, 27), date(2020, 5, 25)]: - self.assertIn(dt, self.holidays) - self.assertNotIn(dt + relativedelta(days=-1), self.holidays) - self.assertNotIn(dt + relativedelta(days=+1), self.holidays) - - def test_christmas_day(self): - self.holidays.observed = False - for year in range(1900, 2100): - dt = date(year, 12, 25) - self.assertIn(dt, self.holidays) - self.assertNotIn(dt + relativedelta(days=-1), self.holidays) - self.assertNotIn(date(2010, 12, 24), self.holidays) - self.assertNotEqual(self.holidays[date(2011, 12, 26)], - "Christmas Day (Observed)") - self.holidays.observed = True - self.assertEqual(self.holidays[date(2011, 12, 27)], - "Christmas Day (Observed)") - for year, day in enumerate([25, 25, 25, 27, 27, # 2001-05 - 25, 25, 25, 25, 27, # 2006-10 - 27, 25, 25, 25, 25, # 2011-15 - 27, 25, 25, 25, 25, 25], # 2016-21 - 2001): - dt = date(year, 12, day) - self.assertIn(dt, self.holidays, dt) - self.assertEqual(self.holidays[dt][:9], "Christmas") - - def test_boxing_day(self): - self.holidays.observed = False - - for year in range(1900, 2100): - dt = date(year, 12, 26) - self.assertIn(dt, self.holidays) - self.assertNotIn(dt + relativedelta(days=+1), self.holidays) - self.assertNotIn(date(2009, 12, 28), self.holidays) - self.assertNotIn(date(2010, 12, 27), self.holidays) - self.holidays.observed = True - self.assertIn(date(2004, 12, 28), self.holidays) - self.assertIn(date(2010, 12, 28), self.holidays) - for year, day in enumerate([26, 26, 26, 28, 26, - 26, 26, 26, 28, 28, - 26, 26, 26, 26, 26, - 26, 26, 26, 26, 26, 28], - 2001): - dt = date(year, 12, day) - self.assertIn(dt, self.holidays, dt) - self.assertEqual(self.holidays[dt][:6], "Boxing") - - def test_all_holidays_present(self): - uk_2015 = holidays.UK(years=[2015]) - all_holidays = ["New Year's Day", - "Good Friday", - "Easter Monday [England, Wales, Northern Ireland]", - "May Day", - "Spring Bank Holiday", - "Christmas Day", - "Boxing Day"] - for holiday in all_holidays: - self.assertIn(holiday, uk_2015.values()) - - -class TestScotland(unittest.TestCase): - - def setUp(self): - self.holidays = holidays.Scotland() - - def test_2017(self): - self.assertIn('2017-01-01', self.holidays) - self.assertIn('2017-01-02', self.holidays) - self.assertIn('2017-01-03', self.holidays) - self.assertIn('2017-04-14', self.holidays) - self.assertIn('2017-05-01', self.holidays) - self.assertIn('2017-05-29', self.holidays) - self.assertIn('2017-08-07', self.holidays) - self.assertIn('2017-11-30', self.holidays) - self.assertIn('2017-12-25', self.holidays) - self.assertIn('2017-12-26', self.holidays) - - -class TestIsleOfMan(unittest.TestCase): - - def setUp(self): - self.holidays = holidays.IsleOfMan() - - def test_2018(self): - self.assertIn('2018-06-01', self.holidays) - self.assertIn('2018-07-05', self.holidays) - - -class TestIreland(unittest.TestCase): - - def setUp(self): - self.holidays = holidays.Ireland() - - def test_2020(self): - self.assertIn('2020-01-01', self.holidays) # New Year's Day - self.assertIn('2020-03-17', self.holidays) # St. Patrick's Day - self.assertIn('2020-04-13', self.holidays) # Easter Monday - self.assertIn('2020-05-04', self.holidays) # May Day in IE - self.assertNotIn('2020-05-08', self.holidays) # May Day in UK not IE - self.assertIn('2020-06-01', self.holidays) # June Bank Holiday - self.assertIn('2020-08-03', self.holidays) # Summer Bank Holiday - self.assertIn('2020-10-26', self.holidays) # October Bank Holiday - self.assertIn('2020-12-25', self.holidays) # Christmas Day - self.assertIn('2020-12-26', self.holidays) # Boxing Day - self.assertIn('2020-12-28', self.holidays) # Boxing Day (Observed) - - def test_may_day(self): - # Specific Ireland "May Day" - for dt in [date(1978, 5, 1), date(1979, 5, 7), date(1980, 5, 5), - date(1995, 5, 8), date(1999, 5, 3), date(2000, 5, 1), - date(2010, 5, 3), date(2018, 5, 7), date(2019, 5, 6), - date(2020, 5, 4)]: - self.assertIn(dt, self.holidays) - self.assertNotIn(dt + relativedelta(days=-1), self.holidays) - self.assertNotIn(dt + relativedelta(days=+1), self.holidays) - - def test_st_stephens_day(self): - # St. Stephen's Day - self.holidays.observed = False - - for year in range(1900, 2100): - dt = date(year, 12, 26) - self.assertIn(dt, self.holidays) - self.assertNotIn(dt + relativedelta(days=+1), self.holidays) - self.assertNotIn(date(2009, 12, 28), self.holidays) - self.assertNotIn(date(2010, 12, 27), self.holidays) - self.holidays.observed = True - self.assertIn(date(2004, 12, 28), self.holidays) - self.assertIn(date(2010, 12, 28), self.holidays) - for year, day in enumerate([26, 26, 26, 28, 26, - 26, 26, 26, 28, 28, - 26, 26, 26, 26, 26, - 26, 26, 26, 26, 26, 28], - 2001): - dt = date(year, 12, day) - self.assertIn(dt, self.holidays, dt) - self.assertIn( - self.holidays[dt], - ["St. Stephen's Day", "St. Stephen's Day (Observed)"] - ) - - -class TestES(unittest.TestCase): - - def setUp(self): - self.holidays = holidays.ES(observed=False) - self.holidays_observed = holidays.ES() - self.prov_holidays = {prov: holidays.ES(observed=False, prov=prov) - for prov in holidays.ES.PROVINCES} - - def test_fixed_holidays(self): - fixed_days_whole_country = ( - (1, 1), - (1, 6), - (5, 1), - (8, 15), - (10, 12), - (11, 1), - (12, 6), - (12, 8), - (12, 25), - ) - for y, (m, d) in product(range(1950, 2050), fixed_days_whole_country): - self.assertIn(date(y, m, d), self.holidays) - - def test_fixed_holidays_observed(self): - fixed_days_whole_country = ( - (1, 1), - (1, 6), - (5, 1), - (8, 15), - (10, 12), - (11, 2), - (12, 7), - (12, 8), - (12, 25), - ) - for (m, d) in fixed_days_whole_country: - self.assertIn(date(2020, m, d), self.holidays_observed) - - def test_variable_days_in_2016(self): - for prov, prov_holidays in self.prov_holidays.items(): - self.assertEqual( - date(2016, 3, 24) in prov_holidays, - prov not in ['CT', 'VC']) - self.assertEqual( - date(2016, 3, 25) in prov_holidays, - prov not in ['CT', 'VC']) - self.assertEqual( - date(2016, 3, 28) in prov_holidays, - prov in ['CT', 'PV', 'NC', 'VC', 'IB', 'CM']) - - def test_province_specific_days(self): - province_days = { - (2, 28): ['AN'], - (3, 1): ['IB'], - (4, 23): ['AR', 'CL'], - (5, 30): ['CN'], - (5, 31): ['CM'], - (5, 2): ['MD'], - (6, 9): ['MC', 'RI'], - (7, 25): ['GA'], - (7, 28): ['CB'], - (9, 8): ['AS', 'EX'], - (9, 11): ['CT'], - (9, 27): ['NC'], - (10, 9): ['VC'], - (10, 25): ['PV'], - } - for prov, prov_holidays in self.prov_holidays.items(): - for year in range(2010, 2025): - self.assertEqual( - date(year, 12, 26) in prov_holidays, - prov in ['CT', 'IB']) - if year < 2015: - self.assertEqual( - date(year, 3, 19) in prov_holidays, - prov in ['AR', 'CL', 'CM', 'EX', 'GA', 'MD', 'ML', - 'MC', 'NC', 'PV', 'VC']) - elif year == 2015: - self.assertEqual( - date(year, 3, 19) in prov_holidays, - prov in ['CM', 'MD', 'ML', 'MC', 'NC', 'PV', 'VC']) - elif year == 2016: - self.assertEqual( - date(year, 3, 19) in prov_holidays, - prov in ['ML', 'MC', 'PV', 'VC']) - elif year == 2017: - self.assertEqual( - date(year, 3, 19) in prov_holidays, - prov in ['PV']) - elif 2018 <= year <= 2019: - self.assertEqual( - date(year, 3, 19) in prov_holidays, - prov in ['GA', 'MC', 'NC', 'PV', 'VC']) - elif year == 2020: - self.assertEqual( - date(year, 3, 19) in prov_holidays, - prov in ['CM', 'GA', 'MC', 'NC', 'PV', 'VC']) - self.assertEqual( - date(year, 6, 24) in prov_holidays, - prov in ['CT', 'GA', 'VC']) - for fest_day, fest_prov in province_days.items(): - self.assertEqual( - date(year, *fest_day) in prov_holidays, - prov in fest_prov) - - -class TestTAR(unittest.TestCase): - - def setUp(self): - self.holidays = holidays.TAR() - - def test_new_years(self): - for year in range(1974, 2100): - dt = date(year, 1, 1) - self.assertIn(dt, self.holidays) - self.assertNotIn(dt + relativedelta(days=-1), self.holidays) - - def test_good_friday(self): - 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.assertIn(dt, self.holidays) - self.assertNotIn(dt + relativedelta(days=-1), self.holidays) - self.assertNotIn(dt + relativedelta(days=+1), self.holidays) - - def test_easter_monday(self): - for dt in [date(1900, 4, 16), date(1901, 4, 8), date(1902, 3, 31), - date(1999, 4, 5), date(2000, 4, 24), date(2010, 4, 5), - date(2018, 4, 2), date(2019, 4, 22), date(2020, 4, 13)]: - self.assertIn(dt, self.holidays) - self.assertNotIn(dt + relativedelta(days=-1), self.holidays) - self.assertNotIn(dt + relativedelta(days=+1), self.holidays) - - def test_labour_day(self): - for year in range(1900, 2100): - dt = date(year, 5, 1) - self.assertIn(dt, self.holidays) - self.assertNotIn(dt + relativedelta(days=-1), self.holidays) - self.assertNotIn(dt + relativedelta(days=+1), self.holidays) - - def test_christmas_day(self): - for year in range(1900, 2100): - dt = date(year, 12, 25) - self.assertIn(dt, self.holidays) - self.assertNotIn(dt + relativedelta(days=-1), self.holidays) - - def test_26_december_day(self): - for year in range(1900, 2100): - dt = date(year, 12, 26) - self.assertIn(dt, self.holidays) - self.assertNotIn(dt + relativedelta(days=+1), self.holidays) - - def test_all_holidays_present(self): - tar_2015 = holidays.TAR(years=[2015]) - all_holidays = ["New Year's Day", - "Good Friday", - "Easter Monday", - "1 May (Labour Day)", - "Christmas Day", - "26 December"] - for holiday in all_holidays: - self.assertIn(holiday, tar_2015.values()) - - -class TestECB(unittest.TestCase): - - def setUp(self): - self.holidays_ecb = holidays.ECB() - self.holidays_tar = holidays.TAR() - - def test_new_years(self): - for year in range(1974, 2100): - self.holidays_ecb._populate(year) - self.holidays_tar._populate(year) - for holiday in self.holidays_tar: - self.assertIn(holiday, self.holidays_ecb) - - -class TestCZ(unittest.TestCase): - - def setUp(self): - self.holidays = holidays.CZ() - - def test_2017(self): - # http://www.officeholidays.com/countries/czech_republic/2017.php - self.assertIn(date(2017, 1, 1), self.holidays) - self.assertIn(date(2017, 4, 14), self.holidays) - self.assertIn(date(2017, 4, 17), self.holidays) - self.assertIn(date(2017, 5, 1), self.holidays) - self.assertIn(date(2017, 5, 8), self.holidays) - self.assertIn(date(2017, 7, 5), self.holidays) - self.assertIn(date(2017, 7, 6), self.holidays) - self.assertIn(date(2017, 9, 28), self.holidays) - self.assertIn(date(2017, 10, 28), self.holidays) - self.assertIn(date(2017, 11, 17), self.holidays) - self.assertIn(date(2017, 12, 24), self.holidays) - self.assertIn(date(2017, 12, 25), self.holidays) - self.assertIn(date(2017, 12, 26), self.holidays) - - def test_others(self): - self.assertIn(date(1991, 5, 9), self.holidays) - - def test_czech_deprecated(self): - with warnings.catch_warnings(record=True) as w: - warnings.simplefilter("always") - czech = holidays.Czech() - self.assertIsInstance(czech, holidays.Czechia) - self.assertEqual(1, len(w)) - self.assertTrue(issubclass(w[-1].category, DeprecationWarning)) - - -class TestSK(unittest.TestCase): - - def setUp(self): - self.holidays = holidays.SK() - - def test_2018(self): - # https://www.officeholidays.com/countries/slovakia/2018.php - self.assertIn(date(2018, 1, 1), self.holidays) - self.assertIn(date(2018, 1, 6), self.holidays) - self.assertIn(date(2018, 3, 30), self.holidays) - self.assertIn(date(2018, 5, 1), self.holidays) - self.assertIn(date(2018, 5, 8), self.holidays) - self.assertIn(date(2018, 4, 2), self.holidays) - self.assertIn(date(2018, 7, 5), self.holidays) - self.assertIn(date(2018, 8, 29), self.holidays) - self.assertIn(date(2018, 9, 1), self.holidays) - self.assertIn(date(2018, 9, 15), self.holidays) - self.assertIn(date(2018, 10, 30), self.holidays) - self.assertIn(date(2018, 11, 1), self.holidays) - self.assertIn(date(2018, 11, 17), self.holidays) - self.assertIn(date(2018, 12, 24), self.holidays) - self.assertIn(date(2018, 12, 25), self.holidays) - self.assertIn(date(2018, 12, 26), self.holidays) - - def test_slovak_deprecated(self): - with warnings.catch_warnings(record=True) as w: - warnings.simplefilter("always") - slovakia = holidays.Slovak() - self.assertIsInstance(slovakia, holidays.Slovakia) - self.assertEqual(1, len(w)) - self.assertTrue(issubclass(w[-1].category, DeprecationWarning)) - - -class TestPL(unittest.TestCase): - - def setUp(self): - self.holidays = holidays.PL() - - def test_2017(self): - # http://www.officeholidays.com/countries/poland/2017.php - self.assertIn(date(2017, 1, 1), self.holidays) - self.assertIn(date(2017, 1, 6), self.holidays) - self.assertIn(date(2017, 4, 16), self.holidays) - self.assertIn(date(2017, 4, 17), self.holidays) - self.assertIn(date(2017, 5, 1), self.holidays) - self.assertIn(date(2017, 5, 3), self.holidays) - self.assertIn(date(2017, 6, 4), self.holidays) - self.assertIn(date(2017, 6, 15), self.holidays) - self.assertIn(date(2017, 8, 15), self.holidays) - self.assertIn(date(2017, 11, 1), self.holidays) - self.assertIn(date(2017, 11, 11), self.holidays) - self.assertIn(date(2017, 12, 25), self.holidays) - self.assertIn(date(2017, 12, 26), self.holidays) - - def test_polish_deprecated(self): - with warnings.catch_warnings(record=True) as w: - warnings.simplefilter("always") - poland = holidays.Polish() - self.assertIsInstance(poland, holidays.Poland) - self.assertEqual(1, len(w)) - self.assertTrue(issubclass(w[-1].category, DeprecationWarning)) - - -class TestPT(unittest.TestCase): - - def setUp(self): - self.holidays = holidays.PT() - - def test_2017(self): - # http://www.officeholidays.com/countries/portugal/2017.php - self.assertIn(date(2017, 1, 1), self.holidays) # New Year - self.assertIn(date(2017, 4, 14), self.holidays) # Good Friday - self.assertIn(date(2017, 4, 16), self.holidays) # Easter - self.assertIn(date(2017, 4, 25), self.holidays) # Liberation Day - self.assertIn(date(2017, 5, 1), self.holidays) # Labour Day - self.assertIn(date(2017, 6, 10), self.holidays) # Portugal Day - self.assertIn(date(2017, 6, 15), self.holidays) # Corpus Christi - self.assertIn(date(2017, 8, 15), self.holidays) # Assumption Day - self.assertIn(date(2017, 10, 5), self.holidays) # Republic Day - self.assertIn(date(2017, 11, 1), self.holidays) # All Saints Day - self.assertIn(date(2017, 12, 1), self.holidays) # Independence - self.assertIn(date(2017, 12, 8), self.holidays) # Immaculate - self.assertIn(date(2017, 12, 25), self.holidays) # Christmas - - -class TestPortugalExt(unittest.TestCase): - - def setUp(self): - self.holidays = holidays.PortugalExt() - - def test_2017(self): - self.assertIn(date(2017, 12, 24), self.holidays) # Christmas' Eve - self.assertIn(date(2017, 12, 26), self.holidays) # S.Stephan - self.assertIn(date(2017, 12, 26), self.holidays) # New Year's Eve - - -class TestNorway(unittest.TestCase): - - def setUp(self): - self.holidays_without_sundays = holidays.Norway(include_sundays=False) - self.holidays_with_sundays = holidays.Norway() - - def test_new_years(self): - self.assertIn('1900-01-01', self.holidays_without_sundays) - self.assertIn('2017-01-01', self.holidays_without_sundays) - self.assertIn('2999-01-01', self.holidays_without_sundays) - - def test_easter(self): - self.assertIn('2000-04-20', self.holidays_without_sundays) - self.assertIn('2000-04-21', self.holidays_without_sundays) - self.assertIn('2000-04-23', self.holidays_without_sundays) - self.assertIn('2000-04-24', self.holidays_without_sundays) - - self.assertIn('2010-04-01', self.holidays_without_sundays) - self.assertIn('2010-04-02', self.holidays_without_sundays) - self.assertIn('2010-04-04', self.holidays_without_sundays) - self.assertIn('2010-04-05', self.holidays_without_sundays) - - self.assertIn('2021-04-01', self.holidays_without_sundays) - self.assertIn('2021-04-02', self.holidays_without_sundays) - self.assertIn('2021-04-04', self.holidays_without_sundays) - self.assertIn('2021-04-05', self.holidays_without_sundays) - - self.assertIn('2024-03-28', self.holidays_without_sundays) - self.assertIn('2024-03-29', self.holidays_without_sundays) - self.assertIn('2024-03-31', self.holidays_without_sundays) - self.assertIn('2024-04-01', self.holidays_without_sundays) - - def test_workers_day(self): - self.assertNotIn('1900-05-01', self.holidays_without_sundays) - self.assertNotIn('1946-05-01', self.holidays_without_sundays) - self.assertIn('1947-05-01', self.holidays_without_sundays) - self.assertIn('2017-05-01', self.holidays_without_sundays) - self.assertIn('2999-05-01', self.holidays_without_sundays) - - def test_constitution_day(self): - self.assertNotIn('1900-05-17', self.holidays_without_sundays) - self.assertNotIn('1946-05-17', self.holidays_without_sundays) - self.assertIn('1947-05-17', self.holidays_without_sundays) - self.assertIn('2017-05-17', self.holidays_without_sundays) - self.assertIn('2999-05-17', self.holidays_without_sundays) - - def test_pentecost(self): - self.assertIn('2000-06-11', self.holidays_without_sundays) - self.assertIn('2000-06-12', self.holidays_without_sundays) - - self.assertIn('2010-05-23', self.holidays_without_sundays) - self.assertIn('2010-05-24', self.holidays_without_sundays) - - self.assertIn('2021-05-23', self.holidays_without_sundays) - self.assertIn('2021-05-24', self.holidays_without_sundays) - - self.assertIn('2024-05-19', self.holidays_without_sundays) - self.assertIn('2024-05-20', self.holidays_without_sundays) - - def test_christmas(self): - self.assertIn('1901-12-25', self.holidays_without_sundays) - self.assertIn('1901-12-26', self.holidays_without_sundays) - - self.assertIn('2016-12-25', self.holidays_without_sundays) - self.assertIn('2016-12-26', self.holidays_without_sundays) - - self.assertIn('2500-12-25', self.holidays_without_sundays) - self.assertIn('2500-12-26', self.holidays_without_sundays) - - def test_sundays(self): - """ - Sundays are considered holidays in Norway - :return: - """ - self.assertIn('1989-12-31', self.holidays_with_sundays) - self.assertIn('2017-02-05', self.holidays_with_sundays) - self.assertIn('2017-02-12', self.holidays_with_sundays) - self.assertIn('2032-02-29', self.holidays_with_sundays) - - def test_not_holiday(self): - """ - Note: Sundays in Norway are considered holidays, - so make sure none of these are actually Sundays - - TODO: Should add more dates that are often confused for being a holiday - :return: - """ - self.assertNotIn('2017-02-06', self.holidays_without_sundays) - self.assertNotIn('2017-02-07', self.holidays_without_sundays) - self.assertNotIn('2017-02-08', self.holidays_without_sundays) - self.assertNotIn('2017-02-09', self.holidays_without_sundays) - self.assertNotIn('2017-02-10', self.holidays_without_sundays) - - self.assertNotIn('2001-12-24', self.holidays_without_sundays) - self.assertNotIn('2001-05-16', self.holidays_without_sundays) - self.assertNotIn('2001-05-18', self.holidays_without_sundays) - self.assertNotIn('1999-12-31', self.holidays_without_sundays) - self.assertNotIn('2016-12-31', self.holidays_without_sundays) - self.assertNotIn('2016-12-27', self.holidays_without_sundays) - self.assertNotIn('2016-12-28', self.holidays_without_sundays) - - self.assertNotIn('2017-02-06', self.holidays_with_sundays) - self.assertNotIn('2017-02-07', self.holidays_with_sundays) - self.assertNotIn('2017-02-08', self.holidays_with_sundays) - self.assertNotIn('2017-02-09', self.holidays_with_sundays) - self.assertNotIn('2017-02-10', self.holidays_with_sundays) - - self.assertNotIn('2001-12-24', self.holidays_with_sundays) - self.assertNotIn('2001-05-16', self.holidays_with_sundays) - self.assertNotIn('2001-05-18', self.holidays_with_sundays) - self.assertNotIn('1999-12-31', self.holidays_with_sundays) - self.assertNotIn('2016-12-31', self.holidays_with_sundays) - self.assertNotIn('2016-12-27', self.holidays_with_sundays) - self.assertNotIn('2016-12-28', self.holidays_with_sundays) - - -class TestItaly(unittest.TestCase): - - def setUp(self): - self.holidays = holidays.IT() - - def test_2017(self): - # https://www.giorni-festivi.it/ - self.assertIn(date(2017, 1, 1), self.holidays) - self.assertIn(date(2017, 1, 6), self.holidays) - self.assertIn(date(2017, 4, 16), self.holidays) - self.assertIn(date(2017, 4, 17), self.holidays) - self.assertIn(date(2017, 4, 25), self.holidays) - self.assertIn(date(2017, 5, 1), self.holidays) - self.assertIn(date(2017, 6, 2), self.holidays) - self.assertIn(date(2017, 8, 15), self.holidays) - self.assertIn(date(2017, 11, 1), self.holidays) - self.assertIn(date(2017, 12, 8), self.holidays) - self.assertIn(date(2017, 12, 25), self.holidays) - self.assertIn(date(2017, 12, 26), self.holidays) - - def test_new_years(self): - for year in range(1974, 2100): - self.assertIn(date(year, 1, 1), self.holidays) - - def test_easter(self): - self.assertIn(date(2017, 4, 16), self.holidays) - - def test_easter_monday(self): - self.assertIn(date(2017, 4, 17), self.holidays) - - def test_republic_day_before_1948(self): - self.holidays = holidays.IT(years=[1947]) - self.assertNotIn(date(1947, 6, 2), self.holidays) - - def test_republic_day_after_1948(self): - self.holidays = holidays.IT(years=[1948]) - self.assertIn(date(1948, 6, 2), self.holidays) - - def test_liberation_day_before_1946(self): - self.holidays = holidays.IT(years=1945) - self.assertNotIn(date(1945, 4, 25), self.holidays) - - def test_liberation_day_after_1946(self): - self.holidays = holidays.IT(years=1946) - self.assertIn(date(1946, 4, 25), self.holidays) - - def test_christmas(self): - self.holidays = holidays.IT(years=2017) - self.assertIn(date(2017, 12, 25), self.holidays) - - def test_saint_stephan(self): - self.holidays = holidays.IT(years=2017) - self.assertIn(date(2017, 12, 26), self.holidays) - - def test_province_specific_days(self): - prov_an = (holidays.IT(prov='AN', years=[2017])) - prov_ao = (holidays.IT(prov='AO', years=[2017])) - prov_ba = (holidays.IT(prov='BA', years=[2017])) - prov_bl = (holidays.IT(prov='BL', years=[2017])) - prov_bo = (holidays.IT(prov='BO', years=[2017])) - prov_bz = (holidays.IT(prov='BZ', years=[2017])) - prov_bs = (holidays.IT(prov='BS', years=[2017])) - prov_cb = (holidays.IT(prov='CB', years=[2017])) - prov_ch = (holidays.IT(prov='CH', years=[2017])) - prov_cs = (holidays.IT(prov='CS', years=[2017])) - prov_ct = (holidays.IT(prov='CT', years=[2017])) - prov_en = (holidays.IT(prov='EN', years=[2017])) - prov_fc = (holidays.IT(prov='FC', years=[2017])) - prov_fe = (holidays.IT(prov='FE', years=[2017])) - prov_fi = (holidays.IT(prov='FI', years=[2017])) - prov_fr = (holidays.IT(prov='FR', years=[2017])) - prov_ge = (holidays.IT(prov='GE', years=[2017])) - prov_go = (holidays.IT(prov='GO', years=[2017])) - prov_is = (holidays.IT(prov='IS', years=[2017])) - prov_kr = (holidays.IT(prov='KR', years=[2017])) - prov_lt = (holidays.IT(prov='LT', years=[2017])) - prov_mb = (holidays.IT(prov='MB', years=[2017])) - prov_me = (holidays.IT(prov='ME', years=[2017])) - prov_mi = (holidays.IT(prov='MI', years=[2017])) - prov_mn = (holidays.IT(prov='MN', years=[2017])) - prov_mo = (holidays.IT(prov='MO', years=[2017])) - prov_ms = (holidays.IT(prov='MS', years=[2017])) - prov_na = (holidays.IT(prov='NA', years=[2017])) - prov_pa = (holidays.IT(prov='PA', years=[2017])) - prov_pc = (holidays.IT(prov='PC', years=[2017])) - prov_pd = (holidays.IT(prov='PD', years=[2017])) - prov_pg = (holidays.IT(prov='PG', years=[2017])) - prov_pr = (holidays.IT(prov='PR', years=[2017])) - prov_rm = (holidays.IT(prov='RM', years=[2017])) - prov_sp = (holidays.IT(prov='SP', years=[2017])) - prov_to = (holidays.IT(prov='TO', years=[2017])) - prov_ts = (holidays.IT(prov='TS', years=[2017])) - prov_vi = (holidays.IT(prov='VI', years=[2017])) - - self.assertIn("2017-05-04", prov_an) - self.assertIn("2017-09-07", prov_ao) - self.assertIn("2017-12-06", prov_ba) - self.assertIn("2017-11-11", prov_bl) - self.assertIn("2017-10-04", prov_bo) - self.assertIn("2017-08-15", prov_bz) - self.assertIn("2017-02-15", prov_bs) - self.assertIn("2017-04-23", prov_cb) - self.assertIn("2017-05-11", prov_ch) - self.assertIn("2017-02-12", prov_cs) - self.assertIn("2017-02-05", prov_ct) - self.assertIn("2017-07-02", prov_en) - self.assertIn("2017-06-24", prov_fc) - self.assertIn("2017-02-04", prov_fc) - self.assertIn("2017-04-23", prov_fe) - self.assertIn("2017-06-24", prov_fi) - self.assertIn("2017-06-20", prov_fr) - self.assertIn("2017-06-24", prov_ge) - self.assertIn("2017-03-16", prov_go) - self.assertIn("2017-05-19", prov_is) - self.assertIn("2017-03-19", prov_sp) - self.assertIn("2017-10-09", prov_kr) - self.assertIn("2017-04-25", prov_lt) - self.assertIn("2017-06-24", prov_mb) - self.assertIn("2017-06-03", prov_me) - self.assertIn("2017-12-07", prov_mi) - self.assertIn("2017-03-18", prov_mn) - self.assertIn("2017-01-31", prov_mo) - self.assertIn("2017-10-04", prov_ms) - self.assertIn("2017-09-19", prov_na) - self.assertIn("2017-07-15", prov_pa) - self.assertIn("2017-07-04", prov_pc) - self.assertIn("2017-06-13", prov_pd) - self.assertIn("2017-01-29", prov_pg) - self.assertIn("2017-01-13", prov_pr) - self.assertIn("2017-06-29", prov_rm) - self.assertIn("2017-06-24", prov_to) - self.assertIn("2017-11-03", prov_ts) - self.assertIn("2017-04-25", prov_vi) - - -class TestSweden(unittest.TestCase): - - def setUp(self): - self.holidays_without_sundays = holidays.Sweden(include_sundays=False) - self.holidays_with_sundays = holidays.Sweden() - - def test_new_years(self): - self.assertIn('1900-01-01', self.holidays_without_sundays) - self.assertIn('2017-01-01', self.holidays_without_sundays) - self.assertIn('2999-01-01', self.holidays_without_sundays) - - def test_easter(self): - self.assertNotIn('2000-04-20', self.holidays_without_sundays) - self.assertIn('2000-04-21', self.holidays_without_sundays) - self.assertIn('2000-04-23', self.holidays_without_sundays) - self.assertIn('2000-04-24', self.holidays_without_sundays) - - self.assertNotIn('2010-04-01', self.holidays_without_sundays) - self.assertIn('2010-04-02', self.holidays_without_sundays) - self.assertIn('2010-04-04', self.holidays_without_sundays) - self.assertIn('2010-04-05', self.holidays_without_sundays) - - self.assertNotIn('2021-04-01', self.holidays_without_sundays) - self.assertIn('2021-04-02', self.holidays_without_sundays) - self.assertIn('2021-04-04', self.holidays_without_sundays) - self.assertIn('2021-04-05', self.holidays_without_sundays) - - self.assertNotIn('2024-03-28', self.holidays_without_sundays) - self.assertIn('2024-03-29', self.holidays_without_sundays) - self.assertIn('2024-03-31', self.holidays_without_sundays) - self.assertIn('2024-04-01', self.holidays_without_sundays) - - def test_workers_day(self): - self.assertNotIn('1800-05-01', self.holidays_without_sundays) - self.assertNotIn('1879-05-01', self.holidays_without_sundays) - self.assertIn('1939-05-01', self.holidays_without_sundays) - self.assertIn('2017-05-01', self.holidays_without_sundays) - self.assertIn('2999-05-01', self.holidays_without_sundays) - - def test_constitution_day(self): - self.assertNotIn('1900-06-06', self.holidays_without_sundays) - self.assertNotIn('2004-06-06', self.holidays_without_sundays) - self.assertIn('2005-06-06', self.holidays_without_sundays) - self.assertIn('2017-06-06', self.holidays_without_sundays) - self.assertIn('2999-06-06', self.holidays_without_sundays) - - def test_pentecost(self): - self.assertIn('2000-06-11', self.holidays_without_sundays) - self.assertIn('2000-06-12', self.holidays_without_sundays) - - self.assertIn('2010-05-23', self.holidays_without_sundays) - self.assertNotIn('2010-05-24', self.holidays_without_sundays) - - self.assertIn('2021-05-23', self.holidays_without_sundays) - self.assertNotIn('2021-05-24', self.holidays_without_sundays) - - self.assertIn('2003-06-09', self.holidays_without_sundays) - - self.assertIn('2024-05-19', self.holidays_without_sundays) - self.assertNotIn('2024-05-20', self.holidays_without_sundays) - - def test_christmas(self): - self.assertIn('1901-12-25', self.holidays_without_sundays) - self.assertIn('1901-12-26', self.holidays_without_sundays) - - self.assertIn('2016-12-25', self.holidays_without_sundays) - self.assertIn('2016-12-26', self.holidays_without_sundays) - - self.assertIn('2500-12-25', self.holidays_without_sundays) - self.assertIn('2500-12-26', self.holidays_without_sundays) - - def test_sundays(self): - """ - Sundays are considered holidays in Sweden - :return: - """ - self.assertIn('1989-12-31', self.holidays_with_sundays) - self.assertIn('2017-02-05', self.holidays_with_sundays) - self.assertIn('2017-02-12', self.holidays_with_sundays) - self.assertIn('2032-02-29', self.holidays_with_sundays) - - def test_not_holiday(self): - """ - Note: Sundays in Sweden are considered holidays, - so make sure none of these are actually Sundays - :return: - """ - self.assertNotIn('2017-02-06', self.holidays_without_sundays) - self.assertNotIn('2017-02-07', self.holidays_without_sundays) - self.assertNotIn('2017-02-08', self.holidays_without_sundays) - self.assertNotIn('2017-02-09', self.holidays_without_sundays) - self.assertNotIn('2017-02-10', self.holidays_without_sundays) - self.assertNotIn('2016-12-27', self.holidays_without_sundays) - self.assertNotIn('2016-12-28', self.holidays_without_sundays) - - self.assertNotIn('2017-02-06', self.holidays_with_sundays) - self.assertNotIn('2017-02-07', self.holidays_with_sundays) - self.assertNotIn('2017-02-08', self.holidays_with_sundays) - self.assertNotIn('2017-02-09', self.holidays_with_sundays) - self.assertNotIn('2017-02-10', self.holidays_with_sundays) - self.assertNotIn('2016-12-27', self.holidays_with_sundays) - self.assertNotIn('2016-12-28', self.holidays_with_sundays) - - -class TestJapan(unittest.TestCase): - def setUp(self): - self.holidays = holidays.Japan(observed=False) - - def test_new_years_day(self): - self.assertIn(date(1949, 1, 1), self.holidays) - self.assertIn(date(2017, 1, 1), self.holidays) - self.assertIn(date(2050, 1, 1), self.holidays) - - def test_coming_of_age(self): - self.assertIn(date(1999, 1, 15), self.holidays) - self.assertIn(date(2000, 1, 10), self.holidays) - self.assertIn(date(2017, 1, 9), self.holidays) - self.assertIn(date(2030, 1, 14), self.holidays) - self.assertIn(date(2050, 1, 10), self.holidays) - - self.assertNotIn(date(2000, 1, 15), self.holidays) - self.assertNotIn(date(2017, 1, 15), self.holidays) - self.assertNotIn(date(2030, 1, 15), self.holidays) - - def test_foundation_day(self): - self.assertIn(date(1949, 2, 11), self.holidays) - self.assertIn(date(2017, 2, 11), self.holidays) - self.assertIn(date(2050, 2, 11), self.holidays) - - def test_vernal_equinox_day(self): - self.assertIn(date(1956, 3, 21), self.holidays) - self.assertIn(date(1960, 3, 20), self.holidays) - self.assertIn(date(1970, 3, 21), self.holidays) - self.assertIn(date(1980, 3, 20), self.holidays) - self.assertIn(date(1990, 3, 21), self.holidays) - self.assertIn(date(2000, 3, 20), self.holidays) - self.assertIn(date(2010, 3, 21), self.holidays) - self.assertIn(date(2017, 3, 20), self.holidays) - self.assertIn(date(2020, 3, 20), self.holidays) - self.assertIn(date(2030, 3, 20), self.holidays) - self.assertIn(date(2040, 3, 20), self.holidays) - self.assertIn(date(2092, 3, 19), self.holidays) - - def test_showa_day(self): - self.assertIn(date(1950, 4, 29), self.holidays) - self.assertIn(date(1990, 4, 29), self.holidays) - self.assertIn(date(2010, 4, 29), self.holidays) - - def test_constitution_memorial_day(self): - self.assertIn(date(1950, 5, 3), self.holidays) - self.assertIn(date(2000, 5, 3), self.holidays) - self.assertIn(date(2050, 5, 3), self.holidays) - - def test_greenery_day(self): - self.assertNotIn(date(1950, 5, 4), self.holidays) - self.assertIn(date(2007, 5, 4), self.holidays) - self.assertIn(date(2050, 5, 4), self.holidays) - - def test_childrens_day(self): - self.assertIn(date(1950, 5, 5), self.holidays) - self.assertIn(date(2000, 5, 5), self.holidays) - self.assertIn(date(2050, 5, 5), self.holidays) - - def test_marine_day(self): - self.assertNotIn(date(1950, 7, 20), self.holidays) - self.assertIn(date(2000, 7, 20), self.holidays) - self.assertIn(date(2003, 7, 21), self.holidays) - self.assertIn(date(2017, 7, 17), self.holidays) - self.assertIn(date(2020, 7, 23), self.holidays) - self.assertIn(date(2021, 7, 22), self.holidays) - self.assertIn(date(2050, 7, 18), self.holidays) - - def test_mountain_day(self): - self.assertNotIn(date(1950, 8, 11), self.holidays) - self.assertNotIn(date(2015, 8, 11), self.holidays) - self.assertIn(date(2016, 8, 11), self.holidays) - self.assertIn(date(2017, 8, 11), self.holidays) - self.assertIn(date(2020, 8, 10), self.holidays) - self.assertIn(date(2021, 8, 8), self.holidays) - self.assertIn(date(2050, 8, 11), self.holidays) - - def test_respect_for_the_aged_day(self): - self.assertNotIn(date(1965, 9, 15), self.holidays) - self.assertIn(date(1966, 9, 15), self.holidays) - self.assertIn(date(2002, 9, 15), self.holidays) - self.assertIn(date(2003, 9, 15), self.holidays) - self.assertNotIn(date(2004, 9, 15), self.holidays) - self.assertIn(date(2004, 9, 20), self.holidays) - self.assertIn(date(2017, 9, 18), self.holidays) - self.assertIn(date(2050, 9, 19), self.holidays) - - def test_autumnal_equinox_day(self): - self.assertIn(date(2000, 9, 23), self.holidays) - self.assertIn(date(2010, 9, 23), self.holidays) - self.assertIn(date(2017, 9, 23), self.holidays) - self.assertIn(date(2020, 9, 22), self.holidays) - self.assertIn(date(2030, 9, 23), self.holidays) - self.assertIn(date(1979, 9, 24), self.holidays) - self.assertIn(date(2032, 9, 21), self.holidays) - - def test_health_and_sports_day(self): - self.assertNotIn(date(1965, 10, 10), self.holidays) - self.assertIn(date(1966, 10, 10), self.holidays) - self.assertIn(date(1999, 10, 10), self.holidays) - self.assertNotIn(date(2000, 10, 10), self.holidays) - self.assertIn(date(2000, 10, 9), self.holidays) - self.assertIn(date(2017, 10, 9), self.holidays) - self.assertIn(date(2020, 7, 24), self.holidays) - self.assertIn(date(2021, 7, 23), self.holidays) - self.assertIn(date(2050, 10, 10), self.holidays) - - def test_culture_day(self): - self.assertIn(date(1950, 11, 3), self.holidays) - self.assertIn(date(2000, 11, 3), self.holidays) - self.assertIn(date(2050, 11, 3), self.holidays) - - def test_labour_thanks_giving_day(self): - self.assertIn(date(1950, 11, 23), self.holidays) - self.assertIn(date(2000, 11, 23), self.holidays) - self.assertIn(date(2050, 11, 23), self.holidays) - - def test_emperors_birthday(self): - self.assertIn(date(1989, 12, 23), self.holidays) - self.assertIn(date(2017, 12, 23), self.holidays) - self.assertNotIn(date(2019, 12, 23), self.holidays) - self.assertIn(date(2020, 2, 23), self.holidays) - - def test_reiwa_emperor_holidays(self): - self.assertIn(date(1993, 6, 9), self.holidays) - self.assertIn(date(2019, 4, 30), self.holidays) - self.assertIn(date(2019, 5, 1), self.holidays) - self.assertIn(date(2019, 5, 2), self.holidays) - self.assertIn(date(2019, 10, 22), self.holidays) - - def test_invalid_years(self): - self.assertRaises(NotImplementedError, - lambda: date(1948, 1, 1) in self.holidays) - self.assertRaises(NotImplementedError, - lambda: date(2100, 1, 1) in self.holidays) - - -class TestFrance(unittest.TestCase): - - def setUp(self): - self.holidays = holidays.France() - self.prov_holidays = {prov: holidays.FR(prov=prov) - for prov in holidays.FRA.PROVINCES} - - def test_2017(self): - self.assertIn(date(2017, 1, 1), self.holidays) - self.assertIn(date(2017, 4, 17), self.holidays) - self.assertIn(date(2017, 5, 1), self.holidays) - self.assertIn(date(2017, 5, 8), self.holidays) - self.assertIn(date(2017, 5, 25), self.holidays) - self.assertIn(date(2017, 6, 5), self.holidays) - self.assertIn(date(2017, 7, 14), self.holidays) - - def test_others(self): - self.assertEqual(self.holidays[date(1948, 5, 1)], - 'Fête du Travail et de la Concorde sociale') - - def test_alsace_moselle(self): - am_holidays = self.prov_holidays['Alsace-Moselle'] - self.assertIn(date(2017, 4, 14), am_holidays) - self.assertIn(date(2017, 12, 26), am_holidays) - - def test_mayotte(self): - am_holidays = self.prov_holidays['Mayotte'] - self.assertIn(date(2017, 4, 27), am_holidays) - - def test_wallis_et_futuna(self): - am_holidays = self.prov_holidays['Wallis-et-Futuna'] - self.assertIn(date(2017, 4, 28), am_holidays) - self.assertIn(date(2017, 7, 29), am_holidays) - - def test_martinique(self): - am_holidays = self.prov_holidays['Martinique'] - self.assertIn(date(2017, 5, 22), am_holidays) - - def test_guadeloupe(self): - am_holidays = self.prov_holidays['Guadeloupe'] - self.assertIn(date(2017, 5, 27), am_holidays) - self.assertIn(date(2017, 7, 21), am_holidays) - - def test_guyane(self): - am_holidays = self.prov_holidays['Guyane'] - self.assertIn(date(2017, 6, 10), am_holidays) - - def test_polynesie_francaise(self): - am_holidays = self.prov_holidays['Polynésie Française'] - self.assertIn(date(2017, 6, 29), am_holidays) - - def test_nouvelle_caledonie(self): - am_holidays = self.prov_holidays['Nouvelle-Calédonie'] - self.assertIn(date(2017, 9, 24), am_holidays) - - def test_saint_barthelemy(self): - am_holidays = self.prov_holidays['Saint-Barthélémy'] - self.assertIn(date(2017, 10, 9), am_holidays) - - def test_la_reunion(self): - am_holidays = self.prov_holidays['La Réunion'] - self.assertIn(date(2017, 12, 20), am_holidays) - - -class TestBelgium(unittest.TestCase): - - def setUp(self): - self.holidays = holidays.BE() - - def test_2017(self): - # https://www.belgium.be/nl/over_belgie/land/belgie_in_een_notendop/feestdagen - self.assertIn(date(2017, 1, 1), self.holidays) - self.assertIn(date(2017, 4, 16), self.holidays) - self.assertIn(date(2017, 4, 17), self.holidays) - self.assertIn(date(2017, 5, 1), self.holidays) - self.assertIn(date(2017, 5, 25), self.holidays) - self.assertIn(date(2017, 6, 4), self.holidays) - self.assertIn(date(2017, 6, 5), self.holidays) - self.assertIn(date(2017, 7, 21), self.holidays) - self.assertIn(date(2017, 8, 15), self.holidays) - self.assertIn(date(2017, 11, 1), self.holidays) - self.assertIn(date(2017, 11, 11), self.holidays) - self.assertIn(date(2017, 12, 25), self.holidays) - - -class TestSouthAfrica(unittest.TestCase): - - def setUp(self): - self.holidays = holidays.ZA() - - def test_new_years(self): - self.assertIn('1910-01-01', self.holidays) - self.assertIn('2017-01-01', self.holidays) - self.assertIn('2999-01-01', self.holidays) - self.assertIn('2017-01-02', self.holidays) # sunday - - def test_easter(self): - self.assertIn(date(2017, 4, 14), self.holidays) - self.assertIn(date(2017, 4, 17), self.holidays) - self.assertIn(date(1994, 4, 1), self.holidays) - - def test_static(self): - self.assertIn('2004-08-09', self.holidays) - self.assertIn('2022-12-27', self.holidays) # Christmas (Observed) - - def test_not_holiday(self): - self.assertNotIn('2016-12-28', self.holidays) - self.assertNotIn('2015-03-02', self.holidays) - - def test_onceoff(self): - self.assertIn('1999-12-31', self.holidays) # Y2K - self.assertIn('2008-05-02', self.holidays) # Y2K - self.assertIn('2000-01-02', self.holidays) # Y2K - self.assertNotIn('2017-08-03', self.holidays) - - def test_historic(self): - self.assertIn('1980-05-31', self.holidays) # Union/Republic Day - self.assertNotIn('2018-05-31', self.holidays) - - self.assertIn('1952-12-16', self.holidays) # Day of the Vow - self.assertIn('1988-05-06', self.holidays) # Workers' Day - self.assertIn('1961-07-10', self.holidays) # Family Day - - self.assertIn('1947-08-04', self.holidays) # King's Birthday - self.assertNotIn('1948-08-04', self.holidays) - - self.assertIn('1975-09-01', self.holidays) # Settler's Day - self.assertNotIn('1976-09-01', self.holidays) - - def test_elections(self): - self.assertTrue('1999-06-02' in self.holidays) # Election Day 1999 - self.assertTrue('2004-04-14' in self.holidays) # Election Day 2004 - self.assertTrue('2006-03-01' in self.holidays) # Local Election - self.assertTrue('2009-04-22' in self.holidays) # Election Day 2008 - self.assertTrue('2011-05-18' in self.holidays) # Election Day 2011 - self.assertTrue('2014-05-07' in self.holidays) # Election Day 2014 - self.assertTrue('2016-08-03' in self.holidays) # Election Day 2016 - self.assertTrue('2019-05-08' in self.holidays) # Election Day 2019 - - -class TestSI(unittest.TestCase): - - def setUp(self): - self.holidays = holidays.SI() - - def test_holidays(self): - """ - Test all expected holiday dates - :return: - """ - # New Year - self.assertIn(date(2017, 1, 1), self.holidays) - self.assertIn(date(2017, 1, 2), self.holidays) - # Prešeren's day - self.assertIn(date(2017, 2, 8), self.holidays) - # Easter monday - 2016 and 2017 - self.assertIn(date(2016, 3, 28), self.holidays) - self.assertIn(date(2017, 4, 17), self.holidays) - # Day of uprising against occupation - self.assertIn(date(2017, 4, 27), self.holidays) - # Labour day - self.assertIn(date(2017, 5, 1), self.holidays) - # Labour day - self.assertIn(date(2017, 5, 2), self.holidays) - # Statehood day - self.assertIn(date(2017, 6, 25), self.holidays) - # Assumption day - self.assertIn(date(2017, 8, 15), self.holidays) - # Reformation day - self.assertIn(date(2017, 10, 31), self.holidays) - # Remembrance day - self.assertIn(date(2017, 11, 1), self.holidays) - # Christmas - self.assertIn(date(2017, 12, 25), self.holidays) - # Day of independence and unity - self.assertIn(date(2017, 12, 26), self.holidays) - - def test_non_holidays(self): - """ - Test dates that should be excluded from holidays list - :return: - """ - # January 2nd was not public holiday between 2012 and 2017 - self.assertNotIn(date(2013, 1, 2), self.holidays) - self.assertNotIn(date(2014, 1, 2), self.holidays) - self.assertNotIn(date(2015, 1, 2), self.holidays) - self.assertNotIn(date(2016, 1, 2), self.holidays) - - def test_missing_years(self): - self.assertNotIn(date(1990, 1, 1), self.holidays) - - -class TestIE(unittest.TestCase): - - def setUp(self): - self.irish_holidays = holidays.IE() - - def test_new_year_day(self): - self.assertIn('2017-01-02', self.irish_holidays) - self.assertIn('2018-01-01', self.irish_holidays) - - def test_st_patricks_day(self): - self.assertIn('2017-03-17', self.irish_holidays) - self.assertIn('2018-03-17', self.irish_holidays) - - def test_easter_monday(self): - self.assertIn('2017-04-17', self.irish_holidays) - self.assertIn('2018-04-02', self.irish_holidays) - - def test_may_bank_holiday(self): - self.assertIn('2017-05-01', self.irish_holidays) - self.assertIn('2018-05-07', self.irish_holidays) - - def test_june_bank_holiday(self): - self.assertIn('2017-06-05', self.irish_holidays) - self.assertIn('2018-06-04', self.irish_holidays) - - def test_august_bank_holiday(self): - self.assertIn('2017-08-07', self.irish_holidays) - self.assertIn('2018-08-06', self.irish_holidays) - - def test_october_bank_holiday(self): - self.assertIn('2017-10-30', self.irish_holidays) - self.assertIn('2018-10-29', self.irish_holidays) - - def test_christmas_period(self): - self.assertIn('2015-12-25', self.irish_holidays) - self.assertIn('2015-12-28', self.irish_holidays) - self.assertIn('2016-12-26', self.irish_holidays) - self.assertIn('2016-12-27', self.irish_holidays) - self.assertIn('2017-12-25', self.irish_holidays) - self.assertIn('2017-12-26', self.irish_holidays) - self.assertIn('2018-12-25', self.irish_holidays) - self.assertIn('2018-12-26', self.irish_holidays) - - -class TestFinland(unittest.TestCase): - - def setUp(self): - self.holidays = holidays.FI() - - def test_fixed_holidays(self): - self.assertIn(date(2017, 1, 1), self.holidays) - self.assertEqual(self.holidays[date(2017, 1, 1)], - "Uudenvuodenpäivä") - - self.assertIn(date(2017, 1, 6), self.holidays) - self.assertEqual(self.holidays[date(2017, 1, 6)], - "Loppiainen") - - self.assertIn(date(2017, 5, 1), self.holidays) - self.assertEqual(self.holidays[date(2017, 5, 1)], - "Vappu") - - self.assertIn(date(2017, 12, 6), self.holidays) - self.assertEqual(self.holidays[date(2017, 12, 6)], - "Itsenäisyyspäivä") - - self.assertIn(date(2017, 12, 25), self.holidays) - self.assertEqual(self.holidays[date(2017, 12, 25)], - "Joulupäivä") - - self.assertIn(date(2017, 12, 26), self.holidays) - self.assertEqual(self.holidays[date(2017, 12, 26)], - "Tapaninpäivä") - - def test_relative_holidays(self): - self.assertIn(date(2017, 4, 14), self.holidays) - self.assertEqual(self.holidays[date(2017, 4, 14)], - "Pitkäperjantai") - - self.assertIn(date(2017, 4, 16), self.holidays) - self.assertEqual(self.holidays[date(2017, 4, 16)], - "Pääsiäispäivä") - - self.assertIn(date(2017, 4, 17), self.holidays) - self.assertEqual(self.holidays[date(2017, 4, 17)], - "2. pääsiäispäivä") - - self.assertIn(date(2017, 5, 25), self.holidays) - self.assertEqual(self.holidays[date(2017, 5, 25)], - "Helatorstai") - - self.assertIn(date(2017, 11, 4), self.holidays) - self.assertEqual(self.holidays[date(2017, 11, 4)], - "Pyhäinpäivä") - - def test_Juhannus(self): - self.assertIn(date(2017, 6, 24), self.holidays) - self.assertNotIn(date(2017, 6, 20), self.holidays) - self.assertIn(date(2020, 6, 20), self.holidays) - self.assertIn(date(2021, 6, 26), self.holidays) - self.assertIn(date(2018, 6, 22), self.holidays) - self.assertEqual(self.holidays[date(2018, 6, 22)], - "Juhannusaatto") - self.assertEqual(self.holidays[date(2018, 6, 23)], - "Juhannuspäivä") - - -class TestHungary(unittest.TestCase): - - def setUp(self): - self.holidays = holidays.HU(observed=False) - self.next_year = date.today().year + 1 - - def test_national_day_was_not_celebrated_during_communism(self): - for year in range(1951, 1988): - self.assertNotIn(date(year, 3, 15), self.holidays) - self.assertIn(date(1989, 3, 15), self.holidays) - - def test_holidays_during_communism(self): - for year in range(1950, 1989): - self.assertIn(date(year, 3, 21), self.holidays) - self.assertIn(date(year, 4, 4), self.holidays) - if year != 1956: - self.assertIn(date(year, 11, 7), self.holidays) - self.assertIn(date(1989, 3, 21), self.holidays) - - def test_foundation_day_renamed_during_communism(self): - for year in range(1950, 1990): - self.assertEqual( - self.holidays[date(year, 8, 20)], "A kenyér ünnepe") - - def test_christian_holidays_2nd_day_was_not_held_in_1955(self): - hu_1955 = holidays.Hungary(years=[1955]) - self.assertNotIn(date(1955, 4, 11), hu_1955) - self.assertNotIn(date(1955, 12, 26), hu_1955) - - def test_good_friday_since_2017(self): - self.assertNotIn(date(2016, 3, 25), self.holidays) - self.assertIn(date(2017, 4, 14), self.holidays) - self.assertIn(date(2018, 3, 30), self.holidays) - - def test_whit_monday_since_1992(self): - self.assertNotIn(date(1991, 5, 20), self.holidays) - self.assertIn(date(1992, 6, 8), self.holidays) - - def test_labour_day_since_1946(self): - self.assertNotIn(date(1945, 5, 1), self.holidays) - for year in range(1946, self.next_year): - self.assertIn(date(year, 5, 1), self.holidays) - - def test_labour_day_was_doubled_in_early_50s(self): - for year in range(1950, 1954): - self.assertIn(date(year, 5, 2), self.holidays) - - def test_october_national_day_since_1991(self): - for year in range(1991, self.next_year): - self.assertIn(date(year, 10, 23), self.holidays) - - def test_all_saints_day_since_1999(self): - for year in range(1999, self.next_year): - self.assertIn(date(year, 11, 1), self.holidays) - - def test_additional_day_off(self): - observed_days_off = holidays.HU( - observed=True, years=range(2010, self.next_year)) - for day in [ - date(2010, 12, 24), - date(2011, 3, 14), date(2011, 10, 31), - date(2012, 3, 16), date(2012, 4, 30), date(2012, 10, 22), - date(2012, 11, 2), date(2012, 12, 24), - date(2013, 8, 19), date(2013, 12, 24), date(2013, 12, 27), - date(2014, 5, 2), date(2014, 10, 24), date(2014, 12, 24), - date(2015, 1, 2), date(2015, 8, 21), date(2015, 12, 24), - date(2016, 3, 14), date(2016, 10, 31), - date(2018, 3, 16), date(2018, 4, 30), date(2018, 10, 22), - date(2018, 11, 2), date(2018, 12, 24), date(2018, 12, 31), - date(2019, 8, 19), date(2019, 12, 24), date(2019, 12, 27)]: - self.assertNotIn(day, self.holidays) - self.assertIn(day, observed_days_off) - - def test_monday_new_years_eve_day_off(self): - observed_day_off = holidays.HU(observed=True) - self.assertIn(date(2018, 12, 31), observed_day_off) - - def test_2018(self): - self.assertIn(date(2018, 1, 1), self.holidays) # newyear - self.assertIn(date(2018, 3, 15), self.holidays) # national holiday - self.assertIn(date(2018, 3, 30), self.holidays) # good friday - self.assertIn(date(2018, 4, 1), self.holidays) # easter 1. - self.assertIn(date(2018, 4, 2), self.holidays) # easter 2. - self.assertIn(date(2018, 5, 1), self.holidays) # Workers' Day - self.assertIn(date(2018, 5, 20), self.holidays) # Pentecost - self.assertIn(date(2018, 5, 21), self.holidays) # Pentecost monday - self.assertIn(date(2018, 8, 20), self.holidays) # State Foundation Day - self.assertIn(date(2018, 10, 23), self.holidays) # National Day - self.assertIn(date(2018, 11, 1), self.holidays) # All Saints' Day - self.assertIn(date(2018, 12, 25), self.holidays) # First christmas - self.assertIn(date(2018, 12, 26), self.holidays) # Second christmas - - -class TestSwitzerland(unittest.TestCase): - - def setUp(self): - self.holidays = holidays.CH() - self.prov_hols = dict((prov, holidays.CH(prov=prov)) - for prov in holidays.CH.PROVINCES) - - def test_all_holidays_present(self): - ch_2018 = sum(holidays.CH(years=[2018], prov=p) - for p in holidays.CH.PROVINCES) - in_2018 = sum((ch_2018.get_list(key) for key in ch_2018), []) - all_ch = ['Neujahrestag', - 'Berchtoldstag', - 'Heilige Drei Könige', - 'Jahrestag der Ausrufung der Republik', - 'Josefstag', - 'Näfelser Fahrt', - 'Karfreitag', - 'Ostern', - 'Ostermontag', - 'Tag der Arbeit', - 'Auffahrt', - 'Pfingsten', - 'Pfingstmontag', - 'Fronleichnam', - 'Fest der Unabhängigkeit', - 'Peter und Paul', - 'Nationalfeiertag', - 'Mariä Himmelfahrt', - 'Lundi du Jeûne', - 'Bruder Klaus', - 'Allerheiligen', - 'Mariä Empfängnis', - 'Escalade de Genève', - 'Weihnachten', - 'Stephanstag', - 'Wiederherstellung der Republik'] - - for holiday in all_ch: - self.assertTrue(holiday in all_ch, "missing: {}".format(holiday)) - for holiday in in_2018: - self.assertTrue(holiday in in_2018, "extra: {}".format(holiday)) - - def test_fixed_holidays(self): - fixed_days_whole_country = ( - (1, 1), # Neujahrestag - (8, 1), # Nationalfeiertag - (12, 25), # Weihnachten - ) - for y, (m, d) in product(range(1291, 2050), fixed_days_whole_country): - self.assertTrue(date(y, m, d) in self.holidays) - - def test_berchtoldstag(self): - provinces_that_have = {'AG', 'BE', 'FR', 'GL', 'GR', 'JU', 'LU', - 'NE', 'OW', 'SH', 'SO', 'TG', 'VD', 'ZG', 'ZH'} - provinces_that_dont = set(holidays.CH.PROVINCES) - provinces_that_have - - for province, year in product(provinces_that_have, range(1970, 2050)): - self.assertTrue(date(year, 1, 2) in self.prov_hols[province]) - for province, year in product(provinces_that_dont, range(1970, 2050)): - self.assertTrue(date(year, 1, 2) not in self.prov_hols[province]) - - def test_heilige_drei_koenige(self): - provinces_that_have = {'SZ', 'TI', 'UR'} - provinces_that_dont = set(holidays.CH.PROVINCES) - provinces_that_have - - for province, year in product(provinces_that_have, range(1970, 2050)): - self.assertTrue(date(year, 1, 6) in self.prov_hols[province]) - for province, year in product(provinces_that_dont, range(1970, 2050)): - self.assertTrue(date(year, 1, 6) not in self.prov_hols[province]) - - def test_jahrestag_der_ausrufung_der_republik(self): - provinces_that_have = {'NE'} - provinces_that_dont = set(holidays.CH.PROVINCES) - provinces_that_have - - for province, year in product(provinces_that_have, range(1970, 2050)): - self.assertTrue(date(year, 3, 1) in self.prov_hols[province]) - for province, year in product(provinces_that_dont, range(1970, 2050)): - self.assertTrue(date(year, 3, 1) not in self.prov_hols[province]) - - def test_josefstag(self): - provinces_that_have = {'NW', 'SZ', 'TI', 'UR', 'VS'} - provinces_that_dont = set(holidays.CH.PROVINCES) - provinces_that_have - - for province, year in product(provinces_that_have, range(1970, 2050)): - self.assertTrue(date(year, 3, 19) in self.prov_hols[province]) - for province, year in product(provinces_that_dont, range(1970, 2050)): - self.assertTrue(date(year, 3, 19) not in self.prov_hols[province]) - - def test_naefelser_fahrt(self): - known_good = [(2018, 4, 5), (2019, 4, 4), (2020, 4, 2), - (2021, 4, 8), (2022, 4, 7), (2023, 4, 13), - (2024, 4, 4), (2025, 4, 3), (2026, 4, 9), - (2027, 4, 1), (2028, 4, 6), (2029, 4, 5), - (2030, 4, 4), (2031, 4, 3), (2032, 4, 1), - (2033, 4, 7), (2034, 4, 13), (2035, 4, 5)] - provinces_that_have = {'GL'} - provinces_that_dont = set(holidays.CH.PROVINCES) - provinces_that_have - - for province, (y, m, d) in product(provinces_that_have, known_good): - self.assertTrue(date(y, m, d) in self.prov_hols[province]) - for province, (y, m, d) in product(provinces_that_dont, known_good): - self.assertTrue(date(y, m, d) not in self.prov_hols[province]) - - def test_karfreitag(self): - known_good = [(2018, 3, 30), (2019, 4, 19), (2020, 4, 10), - (2021, 4, 2), (2022, 4, 15), (2023, 4, 7), - (2024, 3, 29), (2025, 4, 18), (2026, 4, 3), - (2027, 3, 26), (2028, 4, 14), (2029, 3, 30), - (2030, 4, 19), (2031, 4, 11), (2032, 3, 26), - (2033, 4, 15), (2034, 4, 7), (2035, 3, 23)] - provinces_that_dont = {'VS'} - provinces_that_have = set(holidays.CH.PROVINCES) - provinces_that_dont - for province, (y, m, d) in product(provinces_that_have, known_good): - self.assertTrue(date(y, m, d) in self.prov_hols[province]) - for province, (y, m, d) in product(provinces_that_dont, known_good): - self.assertTrue(date(y, m, d) not in self.prov_hols[province]) - - def test_ostern(self): - known_good = [(2018, 4, 1), (2019, 4, 21), (2020, 4, 12), - (2021, 4, 4), (2022, 4, 17), (2023, 4, 9), - (2024, 3, 31), (2025, 4, 20), (2026, 4, 5), - (2027, 3, 28), (2028, 4, 16), (2029, 4, 1), - (2030, 4, 21), (2031, 4, 13), (2032, 3, 28), - (2033, 4, 17), (2034, 4, 9), (2035, 3, 25)] - - for province, (y, m, d) in product(holidays.CH.PROVINCES, known_good): - self.assertTrue(date(y, m, d) in self.prov_hols[province]) - - def test_ostermontag(self): - known_good = [(2018, 4, 2), (2019, 4, 22), (2020, 4, 13), - (2021, 4, 5), (2022, 4, 18), (2023, 4, 10), - (2024, 4, 1), (2025, 4, 21), (2026, 4, 6), - (2027, 3, 29), (2028, 4, 17), (2029, 4, 2), - (2030, 4, 22), (2031, 4, 14), (2032, 3, 29), - (2033, 4, 18), (2034, 4, 10), (2035, 3, 26)] - provinces_that_dont = {'VS'} - provinces_that_have = set(holidays.CH.PROVINCES) - provinces_that_dont - for province, (y, m, d) in product(provinces_that_have, known_good): - self.assertTrue(date(y, m, d) in self.prov_hols[province]) - for province, (y, m, d) in product(provinces_that_dont, known_good): - self.assertTrue(date(y, m, d) not in self.prov_hols[province]) - - def test_auffahrt(self): - known_good = [(2018, 5, 10), (2019, 5, 30), (2020, 5, 21), - (2021, 5, 13), (2022, 5, 26), (2023, 5, 18), - (2024, 5, 9), (2025, 5, 29), (2026, 5, 14), - (2027, 5, 6), (2028, 5, 25), (2029, 5, 10), - (2030, 5, 30), (2031, 5, 22), (2032, 5, 6), - (2033, 5, 26), (2034, 5, 18), (2035, 5, 3)] - - for province, (y, m, d) in product(holidays.CH.PROVINCES, known_good): - self.assertTrue(date(y, m, d) in self.prov_hols[province]) - - def test_pfingsten(self): - known_good = [(2018, 5, 20), (2019, 6, 9), (2020, 5, 31), - (2021, 5, 23), (2022, 6, 5), (2023, 5, 28), - (2024, 5, 19), (2025, 6, 8), (2026, 5, 24), - (2027, 5, 16), (2028, 6, 4), (2029, 5, 20), - (2030, 6, 9), (2031, 6, 1), (2032, 5, 16), - (2033, 6, 5), (2034, 5, 28), (2035, 5, 13)] - - for province, (y, m, d) in product(holidays.CH.PROVINCES, known_good): - self.assertTrue(date(y, m, d) in self.prov_hols[province]) - - def test_pfingstmontag(self): - known_good = [(2018, 5, 21), (2019, 6, 10), (2020, 6, 1), - (2021, 5, 24), (2022, 6, 6), (2023, 5, 29), - (2024, 5, 20), (2025, 6, 9), (2026, 5, 25), - (2027, 5, 17), (2028, 6, 5), (2029, 5, 21), - (2030, 6, 10), (2031, 6, 2), (2032, 5, 17), - (2033, 6, 6), (2034, 5, 29), (2035, 5, 14)] - - for province, (y, m, d) in product(holidays.CH.PROVINCES, known_good): - self.assertTrue(date(y, m, d) in self.prov_hols[province]) - - def test_fronleichnam(self): - known_good = [(2014, 6, 19), (2015, 6, 4), (2016, 5, 26), - (2017, 6, 15), (2018, 5, 31), (2019, 6, 20), - (2020, 6, 11), (2021, 6, 3), (2022, 6, 16), - (2023, 6, 8), (2024, 5, 30)] - provinces_that_have = {'AI', 'JU', 'LU', 'NW', 'OW', 'SZ', 'TI', 'UR', - 'VS', 'ZG'} - provinces_that_dont = set(holidays.CH.PROVINCES) - provinces_that_have - - for province, (y, m, d) in product(provinces_that_have, known_good): - self.assertTrue(date(y, m, d) in self.prov_hols[province]) - for province, (y, m, d) in product(provinces_that_dont, known_good): - self.assertTrue(date(y, m, d) not in self.prov_hols[province]) - - def test_fest_der_unabhaengikeit(self): - provinces_that_have = {'JU'} - provinces_that_dont = set(holidays.CH.PROVINCES) - provinces_that_have - - for province, year in product(provinces_that_have, range(1970, 2050)): - self.assertTrue(date(year, 6, 23) in self.prov_hols[province]) - # 2011 is "Fronleichnam" on the same date, we don't test this year - for province, year in product(provinces_that_dont, range(1970, 2010)): - self.assertTrue(date(year, 6, 23) not in self.prov_hols[province]) - for province, year in product(provinces_that_dont, range(2012, 2050)): - self.assertTrue(date(year, 6, 23) not in self.prov_hols[province]) - - def test_peter_und_paul(self): - provinces_that_have = {'TI'} - provinces_that_dont = set(holidays.CH.PROVINCES) - provinces_that_have - - for province, year in product(provinces_that_have, range(1970, 2050)): - self.assertTrue(date(year, 6, 29) in self.prov_hols[province]) - for province, year in product(provinces_that_dont, range(1970, 2050)): - self.assertTrue(date(year, 6, 29) not in self.prov_hols[province]) - - def test_mariae_himmelfahrt(self): - provinces_that_have = {'AI', 'JU', 'LU', 'NW', 'OW', 'SZ', 'TI', 'UR', - 'VS', 'ZG'} - provinces_that_dont = set(holidays.CH.PROVINCES) - provinces_that_have - - for province, year in product(provinces_that_have, range(1970, 2050)): - self.assertTrue(date(year, 8, 15) in self.prov_hols[province]) - for province, year in product(provinces_that_dont, range(1970, 2050)): - self.assertTrue(date(year, 8, 15) not in self.prov_hols[province]) - - def test_lundi_du_jeune(self): - known_good = [(2014, 9, 22), (2015, 9, 21), (2016, 9, 19), - (2017, 9, 18), (2018, 9, 17), (2019, 9, 16), - (2020, 9, 21), (2021, 9, 20), (2022, 9, 19), - (2023, 9, 18), (2024, 9, 16)] - provinces_that_have = {'VD'} - provinces_that_dont = set(holidays.CH.PROVINCES) - provinces_that_have - - for province, (y, m, d) in product(provinces_that_have, known_good): - self.assertTrue(date(y, m, d) in self.prov_hols[province]) - for province, (y, m, d) in product(provinces_that_dont, known_good): - self.assertTrue(date(y, m, d) not in self.prov_hols[province]) - - def test_bruder_chlaus(self): - provinces_that_have = {'OW'} - provinces_that_dont = set(holidays.CH.PROVINCES) - provinces_that_have - - for province, year in product(provinces_that_have, range(1970, 2050)): - self.assertTrue(date(year, 9, 25) in self.prov_hols[province]) - for province, year in product(provinces_that_dont, range(1970, 2050)): - self.assertTrue(date(year, 9, 25) not in self.prov_hols[province]) - - def test_allerheiligen(self): - provinces_that_have = {'AI', 'GL', 'JU', 'LU', 'NW', 'OW', 'SG', 'SZ', - 'TI', 'UR', 'VS', 'ZG'} - provinces_that_dont = set(holidays.CH.PROVINCES) - provinces_that_have - - for province, year in product(provinces_that_have, range(1970, 2050)): - self.assertTrue(date(year, 11, 1) in self.prov_hols[province]) - for province, year in product(provinces_that_dont, range(1970, 2050)): - self.assertTrue(date(year, 11, 1) not in self.prov_hols[province]) - - def test_jeune_genevois(self): - known_good = [(2014, 9, 11), (2015, 9, 10), (2016, 9, 8), - (2017, 9, 7), (2018, 9, 6), (2019, 9, 5), - (2020, 9, 10), (2021, 9, 9), (2022, 9, 8), - (2023, 9, 7), (2024, 9, 5), (2025, 9, 11)] - provinces_that_have = {'GE'} - provinces_that_dont = set(holidays.CH.PROVINCES) - provinces_that_have - - for province, (y, m, d) in product(provinces_that_have, known_good): - self.assertTrue(date(y, m, d) in self.prov_hols[province]) - for province, (y, m, d) in product(provinces_that_dont, known_good): - self.assertTrue(date(y, m, d) not in self.prov_hols[province]) - - def test_stephanstag(self): - provinces_that_have = {'AG', 'AR', 'AI', 'BL', 'BS', 'BE', 'FR', 'GL', - 'GR', 'LU', 'NE', 'NW', 'OW', 'SG', 'SH', 'SZ', - 'SO', 'TG', 'TI', 'UR', 'ZG', 'ZH'} - provinces_that_dont = set(holidays.CH.PROVINCES) - provinces_that_have - - for province, year in product(provinces_that_have, range(1970, 2050)): - self.assertTrue(date(year, 12, 26) in self.prov_hols[province]) - for province, year in product(provinces_that_dont, range(1970, 2050)): - self.assertTrue(date(year, 12, 26) not in self.prov_hols[province]) - - def test_wiedererstellung_der_republik(self): - provinces_that_have = {'GE'} - provinces_that_dont = set(holidays.CH.PROVINCES) - provinces_that_have - - for province, year in product(provinces_that_have, range(1970, 2050)): - self.assertTrue(date(year, 12, 31) in self.prov_hols[province]) - for province, year in product(provinces_that_dont, range(1970, 2050)): - self.assertTrue(date(year, 12, 31) not in self.prov_hols[province]) - - -class TestAR(unittest.TestCase): - - def setUp(self): - self.holidays = holidays.AR(observed=True) - - def test_new_years(self): - self.holidays.observed = False - self.assertNotIn(date(2010, 12, 31), self.holidays) - self.assertNotIn(date(2017, 1, 2), self.holidays) - self.holidays.observed = True - self.assertIn(date(2017, 1, 1), self.holidays) - for year in range(1900, 2100): - dt = date(year, 1, 1) - self.assertIn(dt, self.holidays) - self.assertNotIn(dt + relativedelta(days=-1), self.holidays) - self.assertNotIn(dt + relativedelta(days=+1), self.holidays) - - def test_carnival_day(self): - for dt in [date(2018, 2, 12), date(2018, 2, 13), date(2017, 2, 27), - date(2017, 2, 28), date(2016, 2, 8), date(2016, 2, 9)]: - self.assertIn(dt, self.holidays) - - def test_memory_national_day(self): - self.holidays.observed = False - self.assertNotIn(date(1907, 3, 24), self.holidays) - self.assertNotIn(date(2002, 3, 24), self.holidays) - self.holidays.observed = True - for dt in [date(2018, 3, 24), date(2017, 3, 24), - date(2016, 3, 24)]: - self.assertIn(dt, self.holidays) - - def test_holy_week_day(self): - for dt in [date(2018, 3, 29), date(2018, 3, 30), date(2017, 4, 13), - date(2017, 4, 14), date(2016, 3, 24), date(2016, 3, 25)]: - self.assertIn(dt, self.holidays) - - def test_malvinas_war_day(self): - for year in range(1900, 2100): - dt = date(year, 4, 2) - self.assertIn(dt, self.holidays) - - def test_labor_day(self): - self.holidays.observed = False - self.assertNotIn(date(2010, 4, 30), self.holidays) - self.assertNotIn(date(2011, 5, 2), self.holidays) - self.holidays.observed = True - self.assertIn(date(1922, 5, 1), self.holidays) - for year in range(1900, 2100): - dt = date(year, 5, 1) - self.assertIn(dt, self.holidays) - self.assertNotIn(dt + relativedelta(days=-1), self.holidays) - self.assertNotIn(dt + relativedelta(days=+1), self.holidays) - - def test_may_revolution_day(self): - self.holidays.observed = False - self.assertNotIn(date(1930, 5, 25), self.holidays) - self.assertNotIn(date(2014, 5, 25), self.holidays) - self.holidays.observed = True - for year in range(1900, 2100): - dt = date(year, 5, 1) - self.assertIn(dt, self.holidays) - self.assertNotIn(dt + relativedelta(days=-1), self.holidays) - self.assertNotIn(dt + relativedelta(days=+1), self.holidays) - - def test_guemes_day(self): - for year in range(1900, 2100): - dt = date(year, 6, 17) - self.assertIn(dt, self.holidays) - self.assertNotIn(dt + relativedelta(days=-1), self.holidays) - self.assertNotIn(dt + relativedelta(days=+1), self.holidays) - - def test_belgrano_day(self): - for year in range(1900, 2100): - dt = date(year, 6, 20) - self.assertIn(dt, self.holidays) - self.assertNotIn(dt + relativedelta(days=-1), self.holidays) - self.assertNotIn(dt + relativedelta(days=+1), self.holidays) - - def test_independence_day(self): - self.holidays.observed = False - self.assertNotIn(date(2017, 7, 9), self.holidays) - self.assertNotIn(date(2011, 7, 9), self.holidays) - self.holidays.observed = True - self.assertIn(date(2017, 7, 9), self.holidays) - self.assertIn(date(2011, 7, 9), self.holidays) - for year in range(1900, 2100): - dt = date(year, 7, 9) - self.assertIn(dt, self.holidays) - self.assertNotIn(dt + relativedelta(days=-1), self.holidays) - self.assertNotIn(dt + relativedelta(days=+1), self.holidays) - - def test_san_martin_day(self): - self.holidays.observed = False - self.assertNotIn(date(1930, 8, 10), self.holidays) - self.assertNotIn(date(2008, 8, 10), self.holidays) - self.holidays.observed = True - for year in range(1900, 2100): - dt = date(year, 8, 17) - self.assertIn(dt, self.holidays) - self.assertNotIn(dt + relativedelta(days=-1), self.holidays) - self.assertNotIn(dt + relativedelta(days=+1), self.holidays) - - def test_cultural_day(self): - self.holidays.observed = False - self.assertNotIn(date(2014, 10, 12), self.holidays) - self.assertNotIn(date(1913, 10, 12), self.holidays) - self.holidays.observed = True - for year in range(1900, 2100): - dt = date(year, 10, 12) - self.assertIn(dt, self.holidays) - self.assertNotIn(dt + relativedelta(days=-1), self.holidays) - self.assertNotIn(dt + relativedelta(days=+1), self.holidays) - - def test_national_sovereignty_day(self): - for year in range(1900, 2100): - dt = date(year, 11, 20) - if year < 2010: - self.assertNotIn(dt, self.holidays) - else: - self.assertIn(dt, self.holidays) - self.assertNotIn(dt + relativedelta(days=-1), self.holidays) - self.assertNotIn(dt + relativedelta(days=+1), self.holidays) - - def test_inmaculate_conception_day(self): - self.holidays.observed = False - self.assertNotIn(date(1940, 12, 8), self.holidays) - self.assertNotIn(date(2013, 12, 8), self.holidays) - self.holidays.observed = True - for year in range(1900, 2100): - dt = date(year, 12, 8) - self.assertIn(dt, self.holidays) - self.assertNotIn(dt + relativedelta(days=-1), self.holidays) - self.assertNotIn(dt + relativedelta(days=+1), self.holidays) - - def test_christmas(self): - for year in range(1900, 2100): - dt = date(year, 12, 25) - self.assertIn(dt, self.holidays) - self.assertNotIn(dt + relativedelta(days=-1), self.holidays) - self.assertNotIn(dt + relativedelta(days=+1), self.holidays) - - -class TestIND(unittest.TestCase): - - def setUp(self): - self.holidays = holidays.IND() - - def test_2018(self): - self.assertIn(date(2018, 1, 14), self.holidays) - self.assertIn(date(2018, 1, 26), self.holidays) - self.assertIn(date(2018, 10, 2), self.holidays) - self.assertIn(date(2018, 5, 1), self.holidays) - self.assertIn(date(2018, 8, 15), self.holidays) - self.assertIn(date(2018, 10, 2), self.holidays) - self.assertIn(date(2018, 12, 25), self.holidays) - - gj_holidays = holidays.IND(prov="GJ") - as_holidays = holidays.IND(prov="AS") - tn_holidays = holidays.IND(prov="TN") - wb_holidays = holidays.IND(prov="WB") - cg_holidays = holidays.IND(prov="CG") - sk_holidays = holidays.IND(prov="SK") - ka_holidays = holidays.IND(prov="KA") - br_holidays = holidays.IND(prov="BR") - rj_holidays = holidays.IND(prov="RJ") - od_holidays = holidays.IND(prov="OD") - ap_holidays = holidays.IND(prov="AP") - kl_holidays = holidays.IND(prov="KL") - hr_holidays = holidays.IND(prov="HR") - mh_holidays = holidays.IND(prov="MH") - mp_holidays = holidays.IND(prov="MP") - up_holidays = holidays.IND(prov="UP") - uk_holidays = holidays.IND(prov="UK") - ts_holidays = holidays.IND(prov="TS") - - for dt in ([date(2018, 1, 14), date(2018, 5, 1), date(2018, 10, 31)]): - self.assertIn(dt, gj_holidays) - for dt in [date(2018, 4, 15), date(2018, 4, 14)]: - self.assertIn(dt, tn_holidays) - self.assertIn(dt, wb_holidays) - for dt in ([date(2018, 1, 14), date(2018, 5, 1), date(2018, 10, 31)]): - self.assertIn(dt, gj_holidays) - self.assertIn(date(2018, 3, 22), br_holidays) - self.assertIn(date(2018, 3, 30), rj_holidays) - self.assertIn(date(2018, 6, 15), rj_holidays) - self.assertIn(date(2018, 4, 1), od_holidays) - self.assertIn(date(2018, 4, 6), ts_holidays) - self.assertIn(date(2018, 4, 15), od_holidays) - self.assertIn(date(2018, 4, 14), od_holidays) - self.assertIn(date(2018, 4, 14), br_holidays) - self.assertIn(date(2018, 4, 14), kl_holidays) - self.assertIn(date(2018, 4, 14), up_holidays) - self.assertIn(date(2018, 4, 14), uk_holidays) - self.assertIn(date(2018, 4, 14), hr_holidays) - self.assertIn(date(2018, 4, 14), mh_holidays) - self.assertIn(date(2018, 4, 14), wb_holidays) - self.assertIn(date(2018, 5, 9), wb_holidays) - self.assertIn(date(2018, 4, 15), as_holidays) - self.assertIn(date(2018, 5, 1), mh_holidays) - self.assertIn(date(2018, 5, 16), sk_holidays) - self.assertIn(date(2018, 10, 6), ts_holidays) - self.assertIn(date(2018, 11, 1), ka_holidays) - self.assertIn(date(2018, 11, 1), ap_holidays) - self.assertIn(date(2018, 11, 1), hr_holidays) - self.assertIn(date(2018, 11, 1), mp_holidays) - self.assertIn(date(2018, 11, 1), kl_holidays) - self.assertIn(date(2018, 11, 1), cg_holidays) - - -class TestBelarus(unittest.TestCase): - - def setUp(self): - self.holidays = holidays.BY() - - def test_2018(self): - # http://calendar.by/procal.php?year=2018 - # https://www.officeholidays.com/countries/belarus/index.php - self.assertIn(date(2018, 1, 1), self.holidays) - self.assertIn(date(2018, 1, 7), self.holidays) - self.assertIn(date(2018, 3, 8), self.holidays) - self.assertIn(date(2018, 4, 17), self.holidays) - self.assertIn(date(2018, 5, 1), self.holidays) - self.assertIn(date(2018, 5, 9), self.holidays) - self.assertIn(date(2018, 7, 3), self.holidays) - self.assertIn(date(2018, 11, 7), self.holidays) - self.assertIn(date(2018, 12, 25), self.holidays) - - def test_new_year(self): - self.assertIn(date(2019, 1, 1), self.holidays) - self.assertNotIn(date(2019, 1, 2), self.holidays) - self.assertIn(date(2020, 1, 1), self.holidays) - self.assertIn(date(2020, 1, 2), self.holidays) - self.assertIn(date(2021, 1, 1), self.holidays) - self.assertIn(date(2021, 1, 2), self.holidays) - - def test_radunitsa(self): - # http://calendar.by/content.php?id=20 - self.assertIn(date(2012, 4, 24), self.holidays) - self.assertIn(date(2013, 5, 14), self.holidays) - self.assertIn(date(2014, 4, 29), self.holidays) - self.assertIn(date(2015, 4, 21), self.holidays) - self.assertIn(date(2016, 5, 10), self.holidays) - self.assertIn(date(2017, 4, 25), self.holidays) - self.assertIn(date(2018, 4, 17), self.holidays) - self.assertIn(date(2019, 5, 7), self.holidays) - self.assertIn(date(2020, 4, 28), self.holidays) - self.assertIn(date(2021, 5, 11), self.holidays) - self.assertIn(date(2022, 5, 3), self.holidays) - self.assertIn(date(2023, 4, 25), self.holidays) - self.assertIn(date(2024, 5, 14), self.holidays) - self.assertIn(date(2025, 4, 29), self.holidays) - self.assertIn(date(2026, 4, 21), self.holidays) - self.assertIn(date(2027, 5, 11), self.holidays) - self.assertIn(date(2028, 4, 25), self.holidays) - self.assertIn(date(2029, 4, 17), self.holidays) - self.assertIn(date(2030, 5, 7), self.holidays) - - def test_before_1998(self): - self.assertNotIn(date(1997, 7, 3), self.holidays) - - -class TestHonduras(unittest.TestCase): - - def setUp(self): - self.holidays = holidays.HND() - - def test_2014(self): - self.assertIn(date(2014, 10, 3), self.holidays) # Morazan's Day - self.assertIn(date(2014, 10, 12), self.holidays) # Columbus Day - self.assertIn(date(2014, 10, 21), self.holidays) # Army Day - - def test_2018(self): - self.assertIn(date(2018, 1, 1), self.holidays) # New Year - self.assertIn(date(2018, 4, 14), self.holidays) # America's Day - self.assertIn(date(2018, 5, 1), self.holidays) # Workers' Day - self.assertNotIn(date(2018, 5, 6), self.holidays) # Mother's Day - self.assertIn(date(2018, 5, 13), self.holidays) # Mother's Day - self.assertIn(date(2018, 9, 10), self.holidays) # Children weekend - self.assertIn(date(2018, 9, 15), self.holidays) # Independence Day - self.assertIn(date(2018, 9, 17), self.holidays) # Teacher's Day - self.assertIn(date(2018, 10, 3), self.holidays) # Morazan's weekend - self.assertIn(date(2018, 12, 25), self.holidays) # Christmas - - -class TestCroatia(unittest.TestCase): - - def setUp(self): - self.holidays = holidays.HR() - - def test_2018(self): - self.assertIn(date(2018, 1, 1), self.holidays) - self.assertIn(date(2018, 1, 6), self.holidays) - self.assertIn(date(2018, 4, 1), self.holidays) - self.assertIn(date(2018, 4, 2), self.holidays) - self.assertIn(date(2018, 5, 1), self.holidays) - self.assertIn(date(2018, 6, 25), self.holidays) - self.assertIn(date(2018, 8, 15), self.holidays) - self.assertIn(date(2018, 10, 8), self.holidays) - self.assertIn(date(2018, 11, 1), self.holidays) - self.assertIn(date(2018, 12, 25), self.holidays) - self.assertIn(date(2018, 12, 26), self.holidays) - - def test_2020_new(self): - self.assertIn(date(2020, 5, 30), self.holidays) - self.assertIn(date(2020, 11, 18), self.holidays) - - -class TestUkraine(unittest.TestCase): - - def setUp(self): - self.holidays = holidays.UA() - - def test_before_1918(self): - self.assertNotIn(date(1917, 12, 31), self.holidays) - - def test_2018(self): - # http://www.buhoblik.org.ua/kadry-zarplata/vremya/1676-1676-kalendar.html - self.assertIn(date(2018, 1, 1), self.holidays) - self.assertIn(date(2018, 1, 7), self.holidays) - self.assertIn(date(2018, 12, 25), self.holidays) - self.assertIn(date(2018, 4, 8), self.holidays) - self.assertIn(date(2018, 5, 27), self.holidays) - self.assertIn(date(2018, 5, 9), self.holidays) - self.assertIn(date(2018, 6, 28), self.holidays) - self.assertIn(date(2018, 8, 24), self.holidays) - self.assertIn(date(2018, 10, 14), self.holidays) - - def test_old_holidays(self): - self.assertIn(date(2018, 5, 1), self.holidays) - self.assertIn(date(2016, 5, 2), self.holidays) - self.assertIn(date(1991, 7, 16), self.holidays) - self.assertIn(date(1950, 1, 22), self.holidays) - self.assertIn(date(1999, 11, 7), self.holidays) - self.assertIn(date(1999, 11, 8), self.holidays) - self.assertIn(date(1945, 5, 9), self.holidays) - self.assertIn(date(1945, 9, 3), self.holidays) - self.assertIn(date(1981, 10, 7), self.holidays) - self.assertIn(date(1937, 12, 5), self.holidays) - self.assertIn(date(1918, 3, 18), self.holidays) - - -class TestBrazil(unittest.TestCase): - - def test_BR_holidays(self): - self.holidays = holidays.BR(years=2018) - self.assertIn("2018-01-01", self.holidays) - self.assertEqual(self.holidays[date(2018, 1, 1)], "Ano novo") - self.assertIn("2018-02-14", self.holidays) - self.assertEqual(self.holidays[date(2018, 2, 14)], - "Quarta-feira de cinzas (Início da Quaresma)") - self.assertIn("2018-02-13", self.holidays) - self.assertEqual(self.holidays[date(2018, 2, 13)], "Carnaval") - self.assertIn("2018-03-30", self.holidays) - self.assertEqual(self.holidays[date(2018, 3, 30)], "Sexta-feira Santa") - self.assertIn("2018-02-13", self.holidays) - self.assertEqual(self.holidays[date(2018, 2, 13)], "Carnaval") - self.assertIn("2018-04-01", self.holidays) - self.assertEqual(self.holidays[date(2018, 4, 1)], "Páscoa") - self.assertIn("2018-04-21", self.holidays) - self.assertEqual(self.holidays[date(2018, 4, 21)], "Tiradentes") - self.assertIn("2018-05-01", self.holidays) - self.assertEqual(self.holidays[date(2018, 5, 1)], - "Dia Mundial do Trabalho") - self.assertIn("2018-05-31", self.holidays) - self.assertEqual(self.holidays[date(2018, 5, 31)], "Corpus Christi") - self.assertIn("2018-09-07", self.holidays) - self.assertEqual(self.holidays[date(2018, 9, 7)], - "Independência do Brasil") - self.assertIn("2018-10-12", self.holidays) - self.assertEqual(self.holidays[date(2018, 10, 12)], - "Nossa Senhora Aparecida") - self.assertIn("2018-11-02", self.holidays) - self.assertEqual(self.holidays[date(2018, 11, 2)], "Finados") - self.assertIn("2018-11-15", self.holidays) - self.assertEqual(self.holidays[date(2018, 11, 15)], - "Proclamação da República") - self.assertIn("2018-12-25", self.holidays) - self.assertEqual(self.holidays[date(2018, 12, 25)], "Natal") - - def test_AC_holidays(self): - ac_holidays = holidays.BR(state="AC") - self.assertIn("2018-01-23", ac_holidays) - self.assertEqual(ac_holidays[date(2018, 1, 23)], "Dia do evangélico") - self.assertIn("2018-06-15", ac_holidays) - self.assertEqual(ac_holidays[date(2018, 6, 15)], "Aniversário do Acre") - self.assertIn("2018-09-05", ac_holidays) - self.assertEqual(ac_holidays[date(2018, 9, 5)], "Dia da Amazônia") - self.assertIn("2018-11-17", ac_holidays) - self.assertEqual(ac_holidays[date(2018, 11, 17)], - "Assinatura do Tratado de Petrópolis") - - def test_AL_holidays(self): - al_holidays = holidays.BR(state="AL") - self.assertIn("2018-06-24", al_holidays) - self.assertEqual(al_holidays[date(2018, 6, 24)], "São João") - self.assertIn("2018-06-29", al_holidays) - self.assertEqual(al_holidays[date(2018, 6, 29)], "São Pedro") - self.assertIn("2018-09-16", al_holidays) - self.assertEqual(al_holidays[date(2018, 9, 16)], - "Emancipação política de Alagoas") - self.assertIn("2018-11-20", al_holidays) - self.assertEqual(al_holidays[date(2018, 11, 20)], "Consciência Negra") - - def test_AP_holidays(self): - ap_holidays = holidays.BR(state="AP") - self.assertIn("2018-03-19", ap_holidays) - self.assertEqual(ap_holidays[date(2018, 3, 19)], "Dia de São José") - self.assertIn("2018-07-25", ap_holidays) - self.assertEqual(ap_holidays[date(2018, 7, 25)], "São Tiago") - self.assertIn("2018-10-05", ap_holidays) - self.assertEqual(ap_holidays[date(2018, 10, 5)], "Criação do estado") - self.assertIn("2018-11-20", ap_holidays) - self.assertEqual(ap_holidays[date(2018, 11, 20)], "Consciência Negra") - - def test_AM_holidays(self): - am_holidays = holidays.BR(state="AM") - self.assertIn("2018-09-05", am_holidays) - self.assertEqual(am_holidays[date(2018, 9, 5)], - "Elevação do Amazonas à categoria de província") - self.assertIn("2018-11-20", am_holidays) - self.assertEqual(am_holidays[date(2018, 11, 20)], "Consciência Negra") - self.assertIn("2018-12-08", am_holidays) - self.assertEqual(am_holidays[date(2018, 12, 8)], - "Dia de Nossa Senhora da Conceição") - - def test_BA_holidays(self): - ba_holidays = holidays.BR(state="BA") - self.assertIn("2018-07-02", ba_holidays) - self.assertEqual(ba_holidays[date(2018, 7, 2)], - "Independência da Bahia") - - def test_CE_holidays(self): - ce_holidays = holidays.BR(state="CE") - self.assertIn("2018-03-19", ce_holidays) - self.assertEqual(ce_holidays[date(2018, 3, 19)], "São José") - self.assertIn("2018-03-25", ce_holidays) - self.assertEqual(ce_holidays[date(2018, 3, 25)], "Data Magna do Ceará") - - def test_DF_holidays(self): - df_holidays = holidays.BR(state="DF") - self.assertIn("2018-04-21", df_holidays) - self.assertEqual(df_holidays[date(2018, 4, 21)], - "Fundação de Brasília, Tiradentes") - self.assertIn("2018-11-30", df_holidays) - self.assertEqual(df_holidays[date(2018, 11, 30)], "Dia do Evangélico") - - def test_ES_holidays(self): - es_holidays = holidays.BR(state="ES") - self.assertIn("2018-10-28", es_holidays) - self.assertEqual( - es_holidays[date(2018, 10, 28)], "Dia do Servidor Público") - - def test_GO_holidays(self): - go_holidays = holidays.BR(state="GO") - self.assertIn("2018-10-28", go_holidays) - self.assertEqual( - go_holidays[date(2018, 10, 28)], "Dia do Servidor Público") - - def test_MA_holidays(self): - ma_holidays = holidays.BR(state="MA") - self.assertIn("2018-07-28", ma_holidays) - self.assertEqual(ma_holidays[date(2018, 7, 28)], - "Adesão do Maranhão à independência do Brasil") - self.assertIn("2018-12-08", ma_holidays) - self.assertEqual(ma_holidays[date(2018, 12, 8)], - "Dia de Nossa Senhora da Conceição") - - def test_MT_holidays(self): - mt_holidays = holidays.BR(state="MT") - self.assertIn("2018-11-20", mt_holidays) - self.assertEqual(mt_holidays[date(2018, 11, 20)], "Consciência Negra") - - def test_MS_holidays(self): - ms_holidays = holidays.BR(state="MS") - self.assertIn("2018-10-11", ms_holidays) - self.assertEqual(ms_holidays[date(2018, 10, 11)], "Criação do estado") - - def test_MG_holidays(self): - mg_holidays = holidays.BR(state="MG") - self.assertIn("2018-04-21", mg_holidays) - self.assertEqual(mg_holidays[date(2018, 4, 21)], - "Data Magna de MG, Tiradentes") - - def test_PA_holidays(self): - pa_holidays = holidays.BR(state="PA") - self.assertIn("2018-08-15", pa_holidays) - self.assertEqual(pa_holidays[date(2018, 8, 15)], - "Adesão do Grão-Pará à independência do Brasil") - - def test_PB_holidays(self): - pb_holidays = holidays.BR(state="PB") - self.assertIn("2018-08-05", pb_holidays) - self.assertEqual(pb_holidays[date(2018, 8, 5)], "Fundação do Estado") - - def test_PE_holidays(self): - pe_holidays = holidays.BR(state="PE") - self.assertIn("2018-03-06", pe_holidays) - self.assertEqual(pe_holidays[date(2018, 3, 6)], - "Revolução Pernambucana (Data Magna)") - self.assertIn("2018-06-24", pe_holidays) - self.assertEqual(pe_holidays[date(2018, 6, 24)], "São João") - - def test_PI_holidays(self): - pi_holidays = holidays.BR(state="PI") - self.assertIn("2018-03-13", pi_holidays) - self.assertEqual(pi_holidays[date(2018, 3, 13)], - "Dia da Batalha do Jenipapo") - self.assertIn("2018-10-19", pi_holidays) - self.assertEqual(pi_holidays[date(2018, 10, 19)], "Dia do Piauí") - - def test_PR_holidays(self): - pr_holidays = holidays.BR(state="PR") - self.assertIn("2018-12-19", pr_holidays) - self.assertEqual(pr_holidays[date(2018, 12, 19)], - "Emancipação do Paraná") - - def test_RJ_holidays(self): - rj_holidays = holidays.BR(state="RJ") - self.assertIn("2018-04-23", rj_holidays) - self.assertEqual(rj_holidays[date(2018, 4, 23)], "Dia de São Jorge") - self.assertIn("2018-10-28", rj_holidays) - self.assertEqual(rj_holidays[date(2018, 10, 28)], - "Dia do Funcionário Público") - self.assertIn("2018-11-20", rj_holidays) - self.assertEqual(rj_holidays[date(2018, 11, 20)], "Zumbi dos Palmares") - - def test_RN_holidays(self): - rn_holidays = holidays.BR(state="RN") - self.assertIn("2018-06-29", rn_holidays) - self.assertEqual(rn_holidays[date(2018, 6, 29)], "Dia de São Pedro") - self.assertIn("2018-10-03", rn_holidays) - self.assertEqual(rn_holidays[date(2018, 10, 3)], - "Mártires de Cunhaú e Uruaçuu") - - def test_RS_holidays(self): - rs_holidays = holidays.BR(state="RS") - self.assertIn("2018-09-20", rs_holidays) - self.assertEqual( - rs_holidays[date(2018, 9, 20)], "Revolução Farroupilha") - - def test_RO_holidays(self): - ro_holidays = holidays.BR(state="RO") - self.assertIn("2018-01-04", ro_holidays) - self.assertEqual(ro_holidays[date(2018, 1, 4)], "Criação do estado") - self.assertIn("2018-06-18", ro_holidays) - self.assertEqual(ro_holidays[date(2018, 6, 18)], "Dia do Evangélico") - - def test_RR_holidays(self): - rr_holidays = holidays.BR(state="RR") - self.assertIn("2018-10-05", rr_holidays) - self.assertEqual(rr_holidays[date(2018, 10, 5)], "Criação de Roraima") - - def test_SC_holidays(self): - sc_holidays = holidays.BR(state="SC") - self.assertIn("2018-08-11", sc_holidays) - self.assertEqual(sc_holidays[date(2018, 8, 11)], - "Criação da capitania, separando-se de SP") - - def test_SP_holidays(self): - sp_holidays = holidays.BR(state="SP") - self.assertIn("2018-07-09", sp_holidays) - self.assertEqual(sp_holidays[date(2018, 7, 9)], - "Revolução Constitucionalista de 1932") - - def test_SE_holidays(self): - se_holidays = holidays.BR(state="SE") - self.assertIn("2018-07-08", se_holidays) - self.assertEqual(se_holidays[date(2018, 7, 8)], - "Autonomia política de Sergipe") - - def test_TO_holidays(self): - to_holidays = holidays.BR(state="TO") - self.assertIn("2018-01-01", to_holidays) - self.assertEqual(to_holidays[date(2018, 1, 1)], - "Instalação de Tocantins, Ano novo") - self.assertIn("2018-09-08", to_holidays) - self.assertEqual(to_holidays[date(2018, 9, 8)], - "Nossa Senhora da Natividade") - self.assertIn("2018-10-05", to_holidays) - self.assertEqual(to_holidays[date(2018, 10, 5)], - "Criação de Tocantins") - - -class TestLU(unittest.TestCase): - - def setUp(self): - self.holidays = holidays.LU() - - def test_2019(self): - # https://www.officeholidays.com/countries/luxembourg/2019 - self.assertIn(date(2019, 1, 1), self.holidays) - self.assertIn(date(2019, 4, 22), self.holidays) - self.assertIn(date(2019, 5, 1), self.holidays) - self.assertIn(date(2019, 5, 9), self.holidays) - self.assertIn(date(2019, 5, 30), self.holidays) - self.assertIn(date(2019, 6, 10), self.holidays) - self.assertIn(date(2019, 6, 23), self.holidays) - self.assertIn(date(2019, 8, 15), self.holidays) - self.assertIn(date(2019, 11, 1), self.holidays) - self.assertIn(date(2019, 12, 25), self.holidays) - self.assertIn(date(2019, 12, 26), self.holidays) - - -class TestRomania(unittest.TestCase): - - def setUp(self): - self.holidays = holidays.RO() - - def test_2020(self): - # https://en.wikipedia.org/wiki/Public_holidays_in_Romania - # https://publicholidays.ro/2020-dates/ - self.assertIn(date(2020, 1, 1), self.holidays) - self.assertIn(date(2020, 1, 2), self.holidays) - self.assertIn(date(2020, 1, 24), self.holidays) - self.assertIn(date(2020, 4, 17), self.holidays) - self.assertIn(date(2020, 4, 19), self.holidays) - self.assertIn(date(2020, 4, 20), self.holidays) - self.assertIn(date(2020, 5, 1), self.holidays) - self.assertIn(date(2020, 6, 1), self.holidays) - self.assertIn(date(2020, 6, 7), self.holidays) - self.assertIn(date(2020, 6, 8), self.holidays) - self.assertIn(date(2020, 8, 15), self.holidays) - self.assertIn(date(2020, 11, 30), self.holidays) - self.assertIn(date(2020, 12, 1), self.holidays) - self.assertIn(date(2020, 12, 25), self.holidays) - self.assertIn(date(2020, 12, 26), self.holidays) - - def test_children_s_day(self): - # Children’s Day became an official Romanian public holiday in 2017. - self.assertNotIn(date(2016, 6, 1), self.holidays) - self.assertIn(date(2017, 6, 1), self.holidays) - - -class TestRussia(unittest.TestCase): - - def setUp(self): - self.holidays = holidays.RU() - - def test_before_2005(self): - self.assertIn(date(2004, 11, 7), self.holidays) - self.assertNotIn(date(2004, 11, 4), self.holidays) - - def test_2018(self): - # https://en.wikipedia.org/wiki/Public_holidays_in_Russia - self.assertIn(date(2018, 1, 1), self.holidays) - self.assertIn(date(2018, 1, 2), self.holidays) - self.assertIn(date(2018, 1, 3), self.holidays) - self.assertIn(date(2018, 1, 4), self.holidays) - self.assertIn(date(2018, 1, 5), self.holidays) - self.assertIn(date(2018, 1, 6), self.holidays) - self.assertIn(date(2018, 1, 7), self.holidays) - self.assertIn(date(2018, 1, 8), self.holidays) - self.assertIn(date(2018, 2, 23), self.holidays) - self.assertIn(date(2018, 3, 8), self.holidays) - self.assertIn(date(2018, 5, 1), self.holidays) - self.assertIn(date(2018, 5, 9), self.holidays) - self.assertIn(date(2018, 6, 12), self.holidays) - self.assertIn(date(2018, 11, 4), self.holidays) - self.assertNotIn(date(2018, 11, 7), self.holidays) - - -class TestLatvia(unittest.TestCase): - def setUp(self): - self.holidays = holidays.LV() - - def test_2020(self): - # https://www.officeholidays.com/countries/latvia/2020 - # https://en.wikipedia.org/wiki/Public_holidays_in_Latvia - # https://likumi.lv/ta/id/72608-par-svetku-atceres-un-atzimejamam-dienam - self.assertIn(date(2020, 1, 1), self.holidays) - self.assertIn(date(2020, 4, 10), self.holidays) - self.assertIn(date(2020, 4, 13), self.holidays) - self.assertIn(date(2020, 5, 1), self.holidays) - self.assertIn(date(2020, 5, 4), self.holidays) - self.assertIn(date(2020, 6, 23), self.holidays) - self.assertIn(date(2020, 6, 24), self.holidays) - self.assertIn(date(2020, 11, 18), self.holidays) - self.assertIn(date(2020, 12, 24), self.holidays) - self.assertIn(date(2020, 12, 25), self.holidays) - self.assertIn(date(2020, 12, 26), self.holidays) - self.assertIn(date(2020, 12, 31), self.holidays) - - -class TestLithuania(unittest.TestCase): - - def setUp(self): - self.holidays = holidays.LT() - - def test_2018(self): - # New Year's Day - self.assertIn(date(2018, 1, 1), self.holidays) - # Day of Restoration of the State of Lithuania - self.assertIn(date(2018, 2, 16), self.holidays) - # Day of Restoration of Independence of Lithuania - self.assertIn(date(2018, 3, 11), self.holidays) - # Easter - self.assertIn(date(2018, 4, 1), self.holidays) - # Easter 2nd day - self.assertIn(date(2018, 4, 2), self.holidays) - # International Workers' Day - self.assertIn(date(2018, 5, 1), self.holidays) - # Mother's day - self.assertIn(date(2018, 5, 6), self.holidays) - # Fathers's day - self.assertIn(date(2018, 6, 3), self.holidays) - # St. John's Day, Day of Dew - self.assertIn(date(2018, 6, 24), self.holidays) - # Statehood Day - self.assertIn(date(2018, 7, 6), self.holidays) - # Assumption Day - self.assertIn(date(2018, 8, 15), self.holidays) - # All Saints' Day - self.assertIn(date(2018, 11, 1), self.holidays) - # Christmas Eve - self.assertIn(date(2018, 12, 24), self.holidays) - # Christmas 1st day - self.assertIn(date(2018, 12, 25), self.holidays) - # Christmas 2nd day - self.assertIn(date(2018, 12, 26), self.holidays) - - def test_easter(self): - self.assertNotIn(date(2019, 4, 20), self.holidays) - self.assertIn(date(2019, 4, 21), self.holidays) - self.assertIn(date(2019, 4, 22), self.holidays) - self.assertNotIn(date(2019, 4, 23), self.holidays) - - def test_mothers_day(self): - self.assertNotIn(date(2019, 5, 4), self.holidays) - self.assertIn(date(2019, 5, 5), self.holidays) - self.assertNotIn(date(2019, 5, 6), self.holidays) - self.assertIn(date(2020, 5, 3), self.holidays) - - def test_fathers_day(self): - self.assertNotIn(date(2019, 6, 1), self.holidays) - self.assertIn(date(2019, 6, 2), self.holidays) - self.assertNotIn(date(2019, 6, 3), self.holidays) - self.assertIn(date(2020, 6, 7), self.holidays) - - def test_day_of_dew(self): - self.assertNotIn(date(2002, 6, 24), self.holidays) - self.assertIn(date(2020, 6, 24), self.holidays) - - -class TestEstonia(unittest.TestCase): - def setUp(self): - self.holidays = holidays.EE() - self.cur_date = datetime.now() - - def test_new_years(self): - test_date = date(self.cur_date.year, 1, 1) - self.assertEqual(self.holidays.get(test_date), "uusaasta") - self.assertIn(test_date, self.holidays) - - def test_independence_day(self): - test_date = date(self.cur_date.year, 2, 24) - self.assertEqual(self.holidays.get(test_date), "iseseisvuspäev") - self.assertIn(test_date, self.holidays) - - def test_good_friday(self): - test_date = date(2019, 4, 19) - self.assertEqual(self.holidays.get(test_date), "suur reede") - self.assertIn(test_date, self.holidays) - - def test_easter_sunday(self): - test_date = date(2019, 4, 21) - self.assertEqual(self.holidays.get(test_date), - "ülestõusmispühade 1. püha") - self.assertIn(test_date, self.holidays) - - def test_spring_day(self): - test_date = date(self.cur_date.year, 5, 1) - self.assertEqual(self.holidays.get(test_date), "kevadpüha") - self.assertIn(test_date, self.holidays) - - def test_pentecost(self): - test_date = date(2019, 6, 9) - self.assertEqual(self.holidays.get(test_date), "nelipühade 1. püha") - self.assertIn(test_date, self.holidays) - - def test_victory_day(self): - test_date = date(self.cur_date.year, 6, 23) - self.assertEqual(self.holidays.get(test_date), "võidupüha") - self.assertIn(test_date, self.holidays) - - def test_midsummers_day(self): - test_date = date(self.cur_date.year, 6, 24) - self.assertEqual(self.holidays.get(test_date), "jaanipäev") - self.assertIn(test_date, self.holidays) - - def test_restoration_of_independence_day(self): - test_date = date(self.cur_date.year, 8, 20) - self.assertEqual(self.holidays.get(test_date), "taasiseseisvumispäev") - self.assertIn(test_date, self.holidays) - - def test_christmas_eve(self): - test_date = date(self.cur_date.year, 12, 24) - self.assertEqual(self.holidays.get(test_date), "jõululaupäev") - self.assertIn(test_date, self.holidays) - - def test_christmas_day(self): - test_date = date(self.cur_date.year, 12, 25) - self.assertEqual(self.holidays.get(test_date), "esimene jõulupüha") - self.assertIn(test_date, self.holidays) - - def test_boxing_day(self): - test_date = date(self.cur_date.year, 12, 26) - self.assertEqual(self.holidays.get(test_date), "teine jõulupüha") - self.assertIn(test_date, self.holidays) - - -class TestIceland(unittest.TestCase): - def setUp(self): - self.holidays = holidays.Iceland() - self.cur_date = datetime.now() - - def test_new_year(self): - test_date = date(self.cur_date.year, 1, 1) - self.assertEqual(self.holidays.get(test_date), "Nýársdagur") - self.assertIn(test_date, self.holidays) - - def test_maundy_thursday(self): - test_date = date(2019, 4, 18) - self.assertEqual(self.holidays.get(test_date), "Skírdagur") - self.assertIn(test_date, self.holidays) - - def test_first_day_of_summer(self): - test_date = date(2019, 4, 25) - self.assertEqual(self.holidays.get(test_date), "Sumardagurinn fyrsti") - self.assertIn(test_date, self.holidays) - - def test_commerce_day(self): - test_date = date(2019, 8, 5) - self.assertEqual(self.holidays.get(test_date), - "Frídagur verslunarmanna") - self.assertIn(test_date, self.holidays) - - def test_holy_friday(self): - test_date = date(2019, 4, 19) - self.assertEqual(self.holidays.get(test_date), "Föstudagurinn langi") - self.assertIn(test_date, self.holidays) - - -class TestKenya(unittest.TestCase): - def setUp(self): - self.holidays = holidays.Kenya() - - def test_2019(self): - # New Year's Day - self.assertIn(date(2019, 1, 1), self.holidays) - # Good Friday - self.assertIn(date(2019, 4, 19), self.holidays) - # Easter Monday - self.assertIn(date(2019, 4, 22), self.holidays) - # Labour Day - self.assertIn(date(2019, 5, 1), self.holidays) - # Madaraka Day - self.assertIn(date(2019, 6, 1), self.holidays) - # Mashujaa Day - self.assertIn(date(2019, 10, 20), self.holidays) - # Jamhuri (Independence) Day - self.assertIn(date(2019, 12, 12), self.holidays) - # Christmas Day - self.assertIn(date(2019, 12, 25), self.holidays) - # Boxing Day - self.assertIn(date(2018, 12, 26), self.holidays) - - -class TestHongKong(unittest.TestCase): - - def setUp(self): - self.holidays = holidays.HK() - - def test_common(self): - self.assertTrue(self.holidays.isLeapYear(2000)) - self.assertFalse(self.holidays.isLeapYear(2100)) - holidaysNoObserved = holidays.HK(observed=False) - self.assertEqual(holidaysNoObserved[date(2019, 1, 1)], - "The first day of January") - self.assertEqual(self.holidays[date(2015, 9, 3)], "The 70th " + - "anniversary day of the victory of the Chinese " + - "people's war of resistance against Japanese " + - "aggression") - - def test_first_day_of_january(self): - exception_years = [2006, 2012, 2017] - for year in range(2006, 2021): - if year in exception_years: - self.assertEqual(self.holidays[date(year, 1, 2)], - "The day following the first day of January") - else: - self.assertEqual(self.holidays[date(year, 1, 1)], - "The first day of January") - - def test_lunar_new_year(self): - for year, month, day in [ - (2006, 1, 28), (2007, 2, 17), (2010, 2, 13)]: - self.assertEqual(self.holidays[date(year, month, day)], - "The day preceding Lunar New Year's Day") - - for year, month, day in [ - (2008, 2, 7), (2009, 1, 26), (2011, 2, 3), (2012, 1, 23), - (2014, 1, 31), (2015, 2, 19), (2016, 2, 8), (2017, 1, 28), - (2018, 2, 16), (2019, 2, 5), (2020, 1, 25)]: - self.assertEqual(self.holidays[date(year, month, day)], - "Lunar New Year's Day") - - for year, month, day in [ - (2006, 1, 30), (2007, 2, 19), (2008, 2, 8), (2009, 1, 27), - (2010, 2, 15), (2011, 2, 4), (2012, 1, 24), (2013, 2, 11), - (2014, 2, 1), (2015, 2, 20), (2016, 2, 9), (2018, 2, 17), - (2019, 2, 6)]: - self.assertEqual(self.holidays[date(year, month, day)], - "The second day of Lunar New Year") - - for year, month, day in [ - (2006, 1, 31), (2007, 2, 20), (2008, 2, 9), (2009, 1, 28), - (2010, 2, 16), (2011, 2, 5), (2012, 1, 25), (2013, 2, 12), - (2015, 2, 21), (2016, 2, 10), (2017, 1, 30), (2019, 2, 7), - (2020, 1, 27)]: - self.assertEqual(self.holidays[date(year, month, day)], - "The third day of Lunar New Year") - - for year, month, day in [ - (2013, 2, 13), (2014, 2, 3), (2017, 1, 31), (2020, 1, 28), - (2018, 2, 19)]: - self.assertEqual(self.holidays[date(year, month, day)], - "The fourth day of Lunar New Year") - - def test_ching_ming_festival(self): - for year, month, day in [ - (2006, 4, 5), (2007, 4, 5), (2008, 4, 4), (2009, 4, 4), - (2010, 4, 5), (2011, 4, 5), (2012, 4, 4), (2013, 4, 4), - (2014, 4, 5), (2016, 4, 4), (2017, 4, 4), (2018, 4, 5), - (2019, 4, 5), (2020, 4, 4)]: - self.assertEqual(self.holidays[date(year, month, day)], - "Ching Ming Festival") - - self.assertEqual(self.holidays[date(2015, 4, 6)], "The day " + - "following Ching Ming Festival") - - def test_easter(self): - for year, month, day in [ - (2006, 4, 14), (2007, 4, 6), (2008, 3, 21), (2009, 4, 10), - (2010, 4, 2), (2011, 4, 22), (2012, 4, 6), (2013, 3, 29), - (2014, 4, 18), (2015, 4, 3), (2016, 3, 25), (2017, 4, 14), - (2018, 3, 30), (2019, 4, 19), (2020, 4, 10)]: - self.assertEqual(self.holidays[date(year, month, day)], - "Good Friday") - - for year, month, day in [ - (2019, 4, 20), (2013, 3, 30), (2020, 4, 11), (2009, 4, 11), - (2018, 3, 31), (2008, 3, 22), (2011, 4, 23), (2010, 4, 3), - (2015, 4, 4), (2006, 4, 15), (2017, 4, 15), (2016, 3, 26), - (2012, 4, 7), (2007, 4, 7), (2014, 4, 19)]: - self.assertEqual(self.holidays[date(year, month, day)], - "The day following Good Friday") - - for year, month, day in [ - (2006, 4, 17), (2007, 4, 9), (2009, 4, 13), (2008, 3, 24), - (2011, 4, 25), (2012, 4, 9), (2013, 4, 1), (2014, 4, 21), - (2016, 3, 28), (2017, 4, 17), (2018, 4, 2), (2019, 4, 22), - (2020, 4, 13)]: - self.assertEqual(self.holidays[date(year, month, day)], - "Easter Monday") - - name = "The day following Easter Monday" - self.assertEqual(self.holidays[date(2010, 4, 6)], name) - self.assertEqual(self.holidays[date(2015, 4, 7)], name) - - def test_labour_day(self): - for year in [2006, 2007, 2008, 2009, 2010, 2012, 2013, 2014, 2015, - 2017, 2018, 2019, 2020]: - self.assertEqual(self.holidays[date(year, 5, 1)], - "Labour Day") - - name = "The day following Labour Day" - self.assertEqual(self.holidays[date(2011, 5, 2)], name) - self.assertEqual(self.holidays[date(2016, 5, 2)], name) - - def test_tuen_ng_festival(self): - for year, month, day in [ - (2006, 5, 31), (2007, 6, 19), (2009, 5, 28), (2010, 6, 16), - (2011, 6, 6), (2012, 6, 23), (2013, 6, 12), (2014, 6, 2), - (2015, 6, 20), (2016, 6, 9), (2017, 5, 30), (2018, 6, 18), - (2019, 6, 7), (2020, 6, 25)]: - self.assertEqual(self.holidays[date(year, month, day)], "Tuen " + - "Ng Festival") - - self.assertEqual(self.holidays[date(2008, 6, 9)], "The day " + - "following Tuen Ng Festival") - - def test_hksar_day(self): - for year in [2006, 2008, 2009, 2010, 2011, 2013, 2014, 2015, 2016, - 2017, 2019, 2020]: - self.assertEqual(self.holidays[date(year, 7, 1)], "Hong Kong " + - "Special Administrative Region Establishment " + - "Day") - - name = "The day following Hong Kong Special Administrative Region " + \ - "Establishment Day" - self.assertEqual(self.holidays[date(2007, 7, 2)], name) - self.assertEqual(self.holidays[date(2012, 7, 2)], name) - self.assertEqual(self.holidays[date(2018, 7, 2)], name) - - def test_mid_autumn_festival(self): - for year, month, day in [ - (2006, 10, 7), (2007, 9, 26), (2008, 9, 15), (2010, 9, 23), - (2011, 9, 13), (2012, 10, 1), (2013, 9, 20), (2014, 9, 9), - (2015, 9, 28), (2016, 9, 16), (2017, 10, 5), (2018, 9, 25), - (2019, 9, 14), (2020, 10, 2)]: - self.assertEqual(self.holidays[date(year, month, day)], "The " + - "day following the Chinese Mid-Autumn Festival") - - self.assertEqual(self.holidays[date(2009, 10, 3)], "Chinese " + - "Mid-Autumn Festival") - - def test_national_day(self): - for year in [2007, 2008, 2009, 2010, 2011, 2013, 2014, 2015, 2016, - 2018, 2019, 2020]: - self.assertEqual(self.holidays[date(year, 10, 1)], "National Day") - - name = "The day following National Day" - self.assertEqual(self.holidays[date(2006, 10, 2)], name) - self.assertEqual(self.holidays[date(2012, 10, 2)], name) - self.assertEqual(self.holidays[date(2017, 10, 2)], name) - - def test_chung_yeung_festival(self): - for year, month, day in [ - (2006, 10, 30), (2007, 10, 19), (2008, 10, 7), (2009, 10, 26), - (2010, 10, 16), (2011, 10, 5), (2012, 10, 23), (2014, 10, 2), - (2015, 10, 21), (2017, 10, 28), (2018, 10, 17), (2019, 10, 7)]: - self.assertEqual(self.holidays[date(year, month, day)], "Chung " + - "Yeung Festival") - - name = "The day following Chung Yeung Festival" - self.assertEqual(self.holidays[date(2013, 10, 14)], name) - self.assertEqual(self.holidays[date(2016, 10, 10)], name) - self.assertEqual(self.holidays[date(2020, 10, 26)], name) - - def test_christmas_day(self): - for year in [2006, 2007, 2008, 2009, 2010, 2012, 2013, 2014, 2015, - 2017, 2018, 2019, 2020]: - self.assertEqual(self.holidays[date(year, 12, 25)], "Christmas " + - "Day") - - name = "The first weekday after Christmas Day" - for year in range(2006, 2010): - self.assertEqual(self.holidays[date(year, 12, 26)], name) - self.assertEqual(self.holidays[date(2010, 12, 27)], name) - for year in range(2011, 2021): - self.assertEqual(self.holidays[date(year, 12, 26)], name) - - name = "The second weekday after Christmas Day" - self.assertEqual(self.holidays[date(2011, 12, 27)], name) - self.assertEqual(self.holidays[date(2016, 12, 27)], name) - - -class TestPeru(unittest.TestCase): - def setUp(self): - self.holidays = holidays.Peru() - - def test_2019(self): - # No laborables (sector público) not included - self.assertIn(date(2019, 1, 1), self.holidays) - self.assertIn(date(2019, 4, 18), self.holidays) - self.assertIn(date(2019, 4, 19), self.holidays) - self.assertIn(date(2019, 5, 1), self.holidays) - self.assertIn(date(2019, 6, 29), self.holidays) - self.assertIn(date(2019, 7, 29), self.holidays) - self.assertIn(date(2019, 8, 30), self.holidays) - self.assertIn(date(2019, 10, 8), self.holidays) - self.assertIn(date(2019, 11, 1), self.holidays) - self.assertIn(date(2019, 12, 8), self.holidays) - self.assertIn(date(2019, 12, 25), self.holidays) - - -class TestNigeria(unittest.TestCase): - def setUp(self): - self.holidays = holidays.Nigeria() - - def test_fixed_holidays(self): - self.assertIn(date(2019, 1, 1), self.holidays) - self.assertIn(date(2019, 5, 1), self.holidays) - self.assertIn(date(2019, 5, 27), self.holidays) - self.assertIn(date(2019, 6, 12), self.holidays) - self.assertIn(date(2019, 10, 1), self.holidays) - self.assertIn(date(2019, 12, 25), self.holidays) - self.assertIn(date(2019, 12, 26), self.holidays) - - -class TestChile(unittest.TestCase): - def setUp(self): - self.holidays = holidays.Chile() - self.holidays_AP = holidays.CL(state='AP') - self.holidays_NB = holidays.CHL(state='NB') - - def test_2009(self): - self.assertIn(date(2009, 10, 12), self.holidays) - - def test_2017(self): - self.assertIn(date(2017, 1, 2), self.holidays) - - def test_2018(self): - self.assertIn(date(2018, 9, 17), self.holidays) - - def test_2019(self): - # No laborables (sector público) not included - self.assertIn(date(2019, 1, 1), self.holidays) - # self.assertIn(date(2019, 4, 18), self.holidays) - self.assertIn(date(2019, 4, 19), self.holidays) - self.assertIn(date(2019, 5, 1), self.holidays) - self.assertIn(date(2019, 5, 21), self.holidays) - self.assertIn(date(2019, 6, 29), self.holidays) - self.assertIn(date(2019, 7, 16), self.holidays) - self.assertIn(date(2019, 8, 15), self.holidays) - self.assertIn(date(2019, 9, 18), self.holidays) - self.assertIn(date(2019, 9, 19), self.holidays) - self.assertIn(date(2019, 9, 20), self.holidays) - self.assertIn(date(2019, 10, 12), self.holidays) - self.assertIn(date(2019, 11, 1), self.holidays) - self.assertIn(date(2019, 12, 8), self.holidays) - self.assertIn(date(2019, 12, 25), self.holidays) - - def test_2020(self): - # from https://feriados.cl/2020.htm - self.assertIn(date(2020, 1, 1), self.holidays) - self.assertIn(date(2020, 4, 10), self.holidays) - self.assertIn(date(2020, 4, 11), self.holidays) - self.assertIn(date(2020, 5, 1), self.holidays) - self.assertIn(date(2020, 5, 21), self.holidays) - self.assertIn(date(2020, 6, 29), self.holidays) - self.assertIn(date(2020, 7, 16), self.holidays) - self.assertIn(date(2020, 8, 15), self.holidays) - self.assertIn(date(2020, 9, 18), self.holidays) - self.assertIn(date(2020, 9, 19), self.holidays) - self.assertIn(date(2020, 10, 12), self.holidays) - self.assertIn(date(2020, 10, 31), self.holidays) - self.assertIn(date(2020, 11, 1), self.holidays) - self.assertIn(date(2020, 12, 8), self.holidays) - self.assertIn(date(2020, 12, 25), self.holidays) - self.assertIn(date(2020, 6, 7), self.holidays_AP) - self.assertIn(date(2020, 8, 20), self.holidays_NB) - - def test_2021(self): - # from https://feriados.cl/2021.htm - self.assertIn(date(2021, 1, 1), self.holidays) - self.assertIn(date(2021, 4, 2), self.holidays) - self.assertIn(date(2021, 4, 3), self.holidays) - self.assertIn(date(2021, 5, 1), self.holidays) - self.assertIn(date(2021, 5, 21), self.holidays) - self.assertIn(date(2021, 6, 28), self.holidays) - self.assertIn(date(2021, 7, 16), self.holidays) - self.assertIn(date(2021, 8, 15), self.holidays) - self.assertIn(date(2021, 9, 18), self.holidays) - self.assertIn(date(2021, 9, 19), self.holidays) - self.assertIn(date(2021, 10, 11), self.holidays) - self.assertIn(date(2021, 10, 31), self.holidays) - self.assertIn(date(2021, 11, 1), self.holidays) - self.assertIn(date(2021, 12, 8), self.holidays) - self.assertIn(date(2021, 12, 25), self.holidays) - self.assertIn(date(2021, 6, 7), self.holidays_AP) - self.assertIn(date(2021, 8, 20), self.holidays_NB) - - def test_2024(self): - self.assertIn(date(2024, 10, 12), self.holidays) - - def test_2029(self): - self.assertIn(date(2029, 7, 2), self.holidays) - self.assertIn(date(2029, 10, 15), self.holidays) - - -class TestDominicanRepublic(unittest.TestCase): - def setUp(self): - self.do_holidays = holidays.DO() - - def test_do_holidays_2020(self): - year = 2020 - - # New Year's Day - self.assertIn(date(year, 1, 1), self.do_holidays) - # Epiphany - self.assertIn(date(year, 1, 6), self.do_holidays) - # Lady of Altagracia - self.assertIn(date(year, 1, 21), self.do_holidays) - # Juan Pablo Duarte Day - self.assertIn(date(year, 1, 26), self.do_holidays) - # Independence Day - self.assertIn(date(year, 2, 27), self.do_holidays) - # Good Friday - self.assertIn(date(year, 4, 10), self.do_holidays) - # Labor Day - self.assertIn(date(year, 5, 4), self.do_holidays) - # Feast of Corpus Christi - self.assertIn(date(year, 6, 11), self.do_holidays) - # Restoration Day - self.assertIn(date(year, 8, 16), self.do_holidays) - # Our Lady of Mercedes Day - self.assertIn(date(year, 9, 24), self.do_holidays) - # Constitution Day - self.assertIn(date(year, 11, 9), self.do_holidays) - # Christmas Day - self.assertIn(date(year, 12, 25), self.do_holidays) - - # Change day by law test - # New Year's Day - self.assertIn(date(2019, 1, 1), self.do_holidays) - - -class TestNicaragua(unittest.TestCase): - def setUp(self): - self.ni_holidays = holidays.NI() - - def test_ni_holidays_2020(self): - year = 2020 - mn_holidays = holidays.NI(prov="MN") - - # New Year's Day - self.assertIn(date(year, 1, 1), self.ni_holidays) - # Maundy Thursday - self.assertIn(date(year, 4, 9), self.ni_holidays) - # Good Friday - self.assertIn(date(year, 4, 10), self.ni_holidays) - # Labor Day - self.assertIn(date(year, 5, 1), self.ni_holidays) - # Revolution Day - self.assertIn(date(year, 7, 19), self.ni_holidays) - # Battle of San Jacinto Day - self.assertIn(date(year, 9, 14), self.ni_holidays) - # Independence Day - self.assertIn(date(year, 9, 15), self.ni_holidays) - # Virgin's Day - self.assertIn(date(year, 12, 8), self.ni_holidays) - # Christmas Day - self.assertIn(date(year, 12, 25), self.ni_holidays) - # Santo Domingo Day Down - self.assertIn(date(year, 8, 1), mn_holidays) - # Santo Domingo Day Up - self.assertIn(date(year, 8, 10), mn_holidays) - - -class TestSingapore(unittest.TestCase): - def setUp(self): - self.holidays = holidays.Singapore() - - def test_Singapore(self): - # <= 1968 holidays - self.assertIn(date(1968, 4, 13), self.holidays) - self.assertIn(date(1968, 4, 15), self.holidays) - self.assertIn(date(1968, 12, 26), self.holidays) - # latest polling day - self.assertIn(date(2015, 9, 11), self.holidays) - # SG50 - self.assertIn(date(2015, 8, 7), self.holidays) - # Year with lunar leap month - self.assertIn(date(2015, 8, 7), self.holidays) - # Latest holidays - # Source: https://www.mom.gov.sg/employment-practices/public-holidays - # 2018 - self.assertIn(date(2018, 1, 1), self.holidays) - self.assertIn(date(2018, 2, 16), self.holidays) - self.assertIn(date(2018, 2, 17), self.holidays) - self.assertIn(date(2018, 3, 30), self.holidays) - self.assertIn(date(2018, 5, 1), self.holidays) - self.assertIn(date(2018, 5, 29), self.holidays) - self.assertIn(date(2018, 6, 15), self.holidays) - self.assertIn(date(2018, 8, 9), self.holidays) - self.assertIn(date(2018, 8, 22), self.holidays) - self.assertIn(date(2018, 11, 6), self.holidays) - self.assertIn(date(2018, 12, 25), self.holidays) - # total holidays (11 + 0 falling on a Sunday) - self.assertEqual(len(holidays.Singapore(years=[2018])), 11 + 0) - # 2019 - self.assertIn(date(2019, 1, 1), self.holidays) - self.assertIn(date(2019, 2, 5), self.holidays) - self.assertIn(date(2019, 2, 6), self.holidays) - self.assertIn(date(2019, 4, 19), self.holidays) - self.assertIn(date(2019, 5, 1), self.holidays) - self.assertIn(date(2019, 5, 19), self.holidays) - self.assertIn(date(2019, 6, 5), self.holidays) - self.assertIn(date(2019, 8, 9), self.holidays) - self.assertIn(date(2019, 8, 11), self.holidays) - self.assertIn(date(2019, 10, 27), self.holidays) - self.assertIn(date(2019, 12, 25), self.holidays) - # total holidays (11 + 3 falling on a Sunday) - self.assertEqual(len(holidays.Singapore(years=[2019])), 11 + 3) - # 2020 - self.assertIn(date(2020, 1, 1), self.holidays) - self.assertIn(date(2020, 1, 25), self.holidays) - self.assertIn(date(2020, 1, 26), self.holidays) - self.assertIn(date(2020, 4, 10), self.holidays) - self.assertIn(date(2020, 5, 1), self.holidays) - self.assertIn(date(2020, 5, 7), self.holidays) - self.assertIn(date(2020, 5, 24), self.holidays) - self.assertIn(date(2020, 7, 31), self.holidays) - self.assertIn(date(2020, 8, 9), self.holidays) - self.assertIn(date(2020, 11, 14), self.holidays) - self.assertIn(date(2020, 12, 25), self.holidays) - # total holidays (11 + 3 falling on a Sunday) - self.assertEqual(len(holidays.Singapore(years=[2020])), 11 + 4) - # holidays estimated using lunar calendar - self.assertIn(date(2021, 5, 26), self.holidays) - self.assertIn(date(2021, 11, 4), self.holidays) - # holidays estimated using library hijri-converter - if sys.version_info >= (3, 6): - import importlib.util - if importlib.util.find_spec("hijri_converter"): - # <= 1968 holidays - self.assertIn(date(1968, 1, 2), self.holidays) - # 2021 - self.assertIn(date(2021, 5, 13), self.holidays) - self.assertIn(date(2021, 7, 20), self.holidays) - - -class TestSaudiArabia(unittest.TestCase): - - def setUp(self): - self.holidays = holidays.SA(observed=True) - - def test_2020(self): - # Eid al-Fitr Holiday - # (skipping 14, and 15 because they are weekends) - self.assertIn(date(2021, 5, 12), self.holidays) - self.assertIn(date(2021, 5, 13), self.holidays) - self.assertIn(date(2021, 5, 16), self.holidays) - self.assertIn(date(2021, 5, 17), self.holidays) - # Eid al-Fitr Holiday - self.assertIn(date(2021, 7, 19), self.holidays) - self.assertIn(date(2021, 7, 20), self.holidays) - self.assertIn(date(2021, 7, 21), self.holidays) - self.assertIn(date(2021, 7, 22), self.holidays) - # National day holiday - self.assertIn(date(2021, 9, 23), self.holidays) - - def test_national_day(self): - self.assertIn(date(2020, 9, 23), self.holidays) - # National day started as a holiday at 2005 - self.assertNotIn(date(2004, 9, 23), self.holidays) - self.assertIn(date(2005, 9, 23), self.holidays) - - def test_national_day_observed(self): - # September 23rd, 2016 was Friday (Weekend) - # so, observed is Thursday - self.assertIn(date(2016, 9, 22), self.holidays) - self.assertIn(date(2016, 9, 23), self.holidays) - self.assertNotIn(date(2016, 9, 24), self.holidays) - - # September 23rd, 2017 was Saturday (Weekend) - # so, observed is Sunday - self.assertNotIn(date(2017, 9, 22), self.holidays) - self.assertIn(date(2017, 9, 23), self.holidays) - self.assertIn(date(2017, 9, 24), self.holidays) - - def test_national_day_not_observed(self): - self.holidays.observed = False - self.assertNotIn(date(2016, 9, 22), self.holidays) - self.assertNotIn(date(2017, 9, 24), self.holidays) - - def test_hijri_based(self): - if sys.version_info >= (3, 6): - import importlib.util - if importlib.util.find_spec("hijri_converter"): - self.holidays = holidays.SA(years=[2020]) - # eid alfitr - self.assertIn(date(2020, 5, 23), self.holidays) - self.assertIn(date(2020, 5, 24), self.holidays) - self.assertIn(date(2020, 5, 25), self.holidays) - self.assertIn(date(2020, 5, 26), self.holidays) - - # eid aladha - self.assertIn(date(2020, 7, 30), self.holidays) - self.assertIn(date(2020, 7, 31), self.holidays) - self.assertIn(date(2020, 8, 1), self.holidays) - self.assertIn(date(2020, 8, 2), self.holidays) - - def test_hijri_based_observed(self): - if sys.version_info >= (3, 6): - import importlib.util - if importlib.util.find_spec("hijri_converter"): - self.holidays = holidays.SA(years=range(2014, 2021)) - # observed eid alfitr - self.assertIn(date(2020, 5, 27), self.holidays) - - # self.assertIn(date(2016, 7, 10), self.holidays) - # self.assertIn(date(2016, 7, 11), self.holidays) - - self.assertIn(date(2018, 6, 18), self.holidays) - self.assertIn(date(2018, 6, 19), self.holidays) - - self.assertIn(date(2019, 6, 9), self.holidays) - - - # osbserved eid aladha - self.assertIn(date(2014, 10, 8), self.holidays) - - # self.assertIn(date(2017, 8, 3), self.holidays) - # self.assertIn(date(2017, 8, 4), self.holidays) - - # self.assertIn(date(2019, 8, 13), self.holidays) - # self.assertIn(date(2019, 8, 14), self.holidays) - - - # self.assertIn(date(2017, 8, 6), self.holidays) - - def test_hijri_based_not_observed(self): - - if sys.version_info >= (3, 6): - import importlib.util - if importlib.util.find_spec("hijri_converter"): - self.holidays = holidays.SA(observed=False, years=range(2014, 2021)) - # observed eid alfitr - self.assertNotIn(date(2020, 5, 27), self.holidays) - - # self.assertNotIn(date(2016, 7, 10), self.holidays) - # self.assertNotIn(date(2016, 7, 11), self.holidays) - - self.assertNotIn(date(2018, 6, 18), self.holidays) - self.assertNotIn(date(2018, 6, 19), self.holidays) - - self.assertNotIn(date(2019, 6, 9), self.holidays) - - - # osbserved eid aladha - self.assertNotIn(date(2014, 10, 8), self.holidays) - - # self.assertNotIn(date(2017, 8, 3), self.holidays) - # self.assertNotIn(date(2017, 8, 4), self.holidays) - - # self.assertNotIn(date(2019, 8, 13), self.holidays) - # self.assertNotIn(date(2019, 8, 14), self.holidays) - - # self.assertNotIn(date(2017, 8, 6), self.holidays) - - - def test_hijri_based_with_two_holidays_in_one_year(self): - """ - Note: this might required change if weekend changes - took effect in the holiday.SA class (weekend changed - on June 28th, 2013), from (Thursdays and Fridays) to - (Fridays, Saturdays). - Currently, using newest weekend days (Fridays, and Saturdays) - """ - if sys.version_info >= (3, 6): - import importlib.util - if importlib.util.find_spec("hijri_converter"): - self.holidays = holidays.SA(years=[2006]) - # eid_alfitr - # 23rd is a weekend day (Saturday), so there - # is a one day shift - self.assertIn(date(2006, 10, 23), self.holidays) - self.assertIn(date(2006, 10, 24), self.holidays) - self.assertIn(date(2006, 10, 25), self.holidays) - self.assertIn(date(2006, 10, 26), self.holidays) - # eid_aladha 1 (hijiry year 1426) - self.assertIn(date(2006, 1, 9), self.holidays) - self.assertIn(date(2006, 1, 10), self.holidays) - self.assertIn(date(2006, 1, 11), self.holidays) - self.assertIn(date(2006, 1, 12), self.holidays) - # eid_aladha 2 (hijiry year 1427) - # The remaining holidays fall in the next year 2007 - self.assertIn(date(2006, 12, 31), self.holidays) - - -class TestSerbia(unittest.TestCase): - def setUp(self): - self.holidays = holidays.Serbia(observed=True) - - def test_new_year(self): - # If January 1st is in Weekend, test oberved - self.assertIn(date(2017, 1, 1), self.holidays) - self.assertIn(date(2017, 1, 2), self.holidays) - self.assertIn(date(2017, 1, 3), self.holidays) - self.holidays.observed = False - self.assertNotIn(date(2017, 1, 3), self.holidays) - - def test_statehood_day(self): - # If February 15th is in Weekend, test oberved - self.assertIn(date(2020, 2, 15), self.holidays) - self.assertIn(date(2020, 2, 16), self.holidays) - self.assertIn(date(2020, 2, 17), self.holidays) - self.holidays.observed = False - self.assertNotIn(date(2020, 2, 17), self.holidays) - - def test_labour_day(self): - # If May 1st is in Weekend, test oberved - self.assertIn(date(2016, 5, 1), self.holidays) - self.assertIn(date(2016, 5, 2), self.holidays) - self.assertIn(date(2016, 5, 3), self.holidays) - self.holidays.observed = False - self.assertNotIn(date(2016, 5, 3), self.holidays) - - def test_armistice_day(self): - # If November 11th is in Weekend, test oberved - self.assertIn(date(2018, 11, 11), self.holidays) - self.assertIn(date(2018, 11, 12), self.holidays) - self.holidays.observed = False - self.assertNotIn(date(2018, 11, 12), self.holidays) - - def test_religious_holidays(self): - # Orthodox Christmas - self.assertIn(date(2020, 1, 7), self.holidays) - self.assertNotIn(date(2020, 1, 8), self.holidays) - # Orthodox Easter - self.assertNotIn(date(2020, 4, 16), self.holidays) - self.assertIn(date(2020, 4, 17), self.holidays) - self.assertIn(date(2020, 4, 18), self.holidays) - self.assertIn(date(2020, 4, 19), self.holidays) - self.assertIn(date(2020, 4, 20), self.holidays) - self.assertNotIn(date(2020, 4, 21), self.holidays) - - -class TestEgypt(unittest.TestCase): - - def setUp(self): - self.holidays = holidays.EG() - - def test_2019(self): - self.assertIn(date(2019, 1, 7), self.holidays) - self.assertIn(date(2019, 1, 25), self.holidays) - self.assertIn(date(2019, 4, 25), self.holidays) - self.assertIn(date(2019, 4, 28), self.holidays) - self.assertIn(date(2019, 4, 29), self.holidays) - self.assertIn(date(2019, 5, 1), self.holidays) - self.assertIn(date(2019, 6, 30), self.holidays) - self.assertIn(date(2019, 7, 23), self.holidays) - self.assertIn(date(2019, 10, 6), self.holidays) - - def test_coptic_christmas(self): - self.assertIn(date(2019, 1, 7), self.holidays) - - def test_25_jan(self): - self.assertIn(date(2019, 1, 25), self.holidays) - - def test_labour_day(self): - self.assertIn(date(2019, 5, 1), self.holidays) - - def test_25_jan_from_2009(self): - # Before 2009 Jan 25th wasn't celebrated - self.holidays = holidays.EG(years=[2010]) - self.assertIn(date(2010, 1, 25), self.holidays) - - def test_hijri_based(self): - if sys.version_info >= (3, 6): - import importlib.util - if importlib.util.find_spec("hijri_converter"): - self.holidays = holidays.EG(years=[2010]) - self.assertIn(date(2019, 6, 5), self.holidays) - self.assertIn(date(2019, 8, 10), self.holidays) - self.assertIn(date(2019, 8, 11), self.holidays) - self.assertIn(date(2019, 8, 12), self.holidays) - self.assertIn(date(2019, 8, 31), self.holidays) - self.assertIn(date(2019, 11, 9), self.holidays) - # eid_alfitr - self.assertIn(date(2019, 6, 4), self.holidays) - # eid_aladha - self.assertIn(date(2019, 8, 11), self.holidays) - # islamic_new_year - self.assertIn(date(2019, 8, 31), self.holidays) - # eid_elfetr_2010 - self.assertIn(date(2010, 9, 10), self.holidays) - # arafat_2010 - self.assertIn(date(2010, 11, 15), self.holidays) - # muhammad's birthday - self.assertIn(date(2010, 2, 26), self.holidays) - - -class TestIsrael(unittest.TestCase): - def test_memorial_day(self): - self._test_observed_holidays('Memorial Day') - - def test_independence_day(self): - self._test_observed_holidays('Independence Day') - - def _test_observed_holidays(self, holiday_name): - days_delta = 0 if holiday_name == 'Memorial Day' else 1 - - # Postponed - il_holidays = holidays.IL(years=[2017], observed=True) - official_memorial_day = date(2017, 4, 30) + relativedelta(days=days_delta) - observed_memorial_day = date(2017, 5, 1) + relativedelta(days=days_delta) - self.assertIn(official_memorial_day, il_holidays) - self.assertIn(holiday_name, il_holidays[official_memorial_day]) - self.assertIn(observed_memorial_day, il_holidays) - self.assertIn(holiday_name + ' (Observed)', il_holidays[observed_memorial_day]) - - # Earlier - il_holidays = holidays.IL(years=[2018], observed=True) - official_memorial_day = date(2018, 4, 19) + relativedelta(days=days_delta) - observed_memorial_day = date(2018, 4, 18) + relativedelta(days=days_delta) - self.assertIn(official_memorial_day, il_holidays) - self.assertIn(holiday_name, il_holidays[official_memorial_day]) - self.assertIn(observed_memorial_day, il_holidays) - self.assertIn(holiday_name + ' (Observed)', il_holidays[observed_memorial_day]) - - # On time - il_holidays = holidays.IL(years=[2020], observed=True) - official_memorial_day = date(2020, 4, 28) + relativedelta(days=days_delta) - self.assertIn(official_memorial_day, il_holidays) - self.assertIn(holiday_name, il_holidays[official_memorial_day]) - - for names in il_holidays.values(): - self.assertNotIn(holiday_name + ' (Observed)', names) - - -class TestGreece(unittest.TestCase): - def setUp(self): - self.gr_holidays = holidays.GR() - - def test_fixed_holidays(self): - years = range(2000, 2025) - for y in years: - fdays = ((date(y, 1, 1), "Πρωτοχρονιά [New Year's Day]"), - (date(y, 1, 6), "Θεοφάνεια [Epiphany]"), - (date(y, 3, 25), "Εικοστή Πέμπτη Μαρτίου " + - "[Independence Day]"), - (date(y, 5, 1), "Εργατική Πρωτομαγιά [Labour day]"), - (date(y, 8, 15), "Κοίμηση της Θεοτόκου " + - "[Assumption of Mary]"), - (date(y, 10, 28), "Ημέρα του Όχι [Ochi Day]"), - (date(y, 12, 25), "Χριστούγεννα [Christmas]"), - (date(y, 12, 26), "Επόμενη ημέρα των Χριστουγέννων " + - "[Day after Christmas]")) - - for (d, dstr) in fdays: - self.assertIn(d, self.gr_holidays) - self.assertIn(dstr, self.gr_holidays[d]) - - def test_gr_clean_monday(self): - checkdates = (date(2018, 2, 19), - date(2019, 3, 11), - date(2020, 3, 2), - date(2021, 3, 15), - date(2022, 3, 7), - date(2023, 2, 27), - date(2024, 3, 18)) - - for d in checkdates: - self.assertIn(d, self.gr_holidays) - self.assertIn("Καθαρά Δευτέρα [Clean Monday]", self.gr_holidays[d]) - - def test_gr_easter_monday(self): - checkdates = (date(2018, 4, 9), - date(2019, 4, 29), - date(2020, 4, 20), - date(2021, 5, 3), - date(2022, 4, 25), - date(2023, 4, 17), - date(2024, 5, 6)) - - for d in checkdates: - self.assertIn(d, self.gr_holidays) - self.assertIn("Δευτέρα του Πάσχα [Easter Monday]", - self.gr_holidays[d]) - - def test_gr_monday_of_the_holy_spirit(self): - checkdates = (date(2018, 5, 28), - date(2019, 6, 17), - date(2020, 6, 8), - date(2021, 6, 21), - date(2022, 6, 13), - date(2023, 6, 5), - date(2024, 6, 24)) - - for d in checkdates: - self.assertIn(d, self.gr_holidays) - self.assertIn("Δευτέρα του Αγίου Πνεύματος " + - "[Monday of the Holy Spirit]", self.gr_holidays[d]) - - -class TestParaguay(unittest.TestCase): - def setUp(self): - self.holidays = holidays.PY() - - def test_fixed_holidays(self): - checkdates = (date(2016, 1, 1), - date(2020, 1, 1), - date(2020, 3, 2), - date(2020, 4, 9), - date(2020, 5, 1), - date(2020, 5, 15), - date(2020, 6, 15), - date(2020, 8, 15), - date(2020, 9, 29), - date(2020, 12, 8), - date(2020, 12, 25)) - - for d in checkdates: - self.assertIn(d, self.holidays) - - def test_no_observed(self): - # no observed dates - self.holidays.observed = False - checkdates = (date(2017, 1, 1), - date(2014, 3, 2), - date(2020, 4, 12), - date(2016, 5, 1), - date(2016, 5, 15), - date(2016, 6, 12), - date(2015, 8, 15), - date(2018, 9, 29), - date(2018, 12, 8)) - - for d in checkdates: - self.assertNotIn(d, self.holidays) - - def test_easter(self): - for year, month, day in [ - (2002, 3, 31), (2003, 4, 20), (2004, 4, 11), - (2005, 3, 27), (2006, 4, 16), (2007, 4, 8), - (2008, 3, 23), (2009, 4, 12), (2010, 4, 4), - (2011, 4, 24), (2012, 4, 8), (2013, 3, 31), - (2014, 4, 20), (2015, 4, 5), (2016, 3, 27), - (2017, 4, 16), (2018, 4, 1), (2019, 4, 21), - (2020, 4, 12), (2021, 4, 4), (2022, 4, 17)]: - easter = date(year, month, day) - easter_thursday = easter - timedelta(days=3) - easter_friday = easter - timedelta(days=2) - for holiday in [easter_thursday, easter_friday, easter]: - self.assertIn(holiday, self.holidays) - - -class TestTurkey(unittest.TestCase): - - def setUp(self): - self.holidays = holidays.TR() - - def test_2019(self): - self.assertIn(date(2019, 1, 1), self.holidays) - self.assertIn(date(2019, 4, 23), self.holidays) - self.assertIn(date(2019, 5, 1), self.holidays) - self.assertIn(date(2019, 5, 19), self.holidays) - self.assertIn(date(2019, 7, 15), self.holidays) - self.assertIn(date(2019, 8, 30), self.holidays) - self.assertIn(date(2019, 10, 29), self.holidays) - - def test_hijri_based(self): - if sys.version_info >= (3, 6): - import importlib.util - if importlib.util.find_spec("hijri_converter"): - self.holidays = holidays.TR(years=[2020]) - # Ramadan Feast - self.assertIn(date(2020, 5, 24), self.holidays) - self.assertIn(date(2020, 5, 25), self.holidays) - self.assertIn(date(2020, 5, 26), self.holidays) - # Sacrifice Feast - self.assertIn(date(2020, 7, 31), self.holidays) - self.assertIn(date(2020, 8, 1), self.holidays) - self.assertIn(date(2020, 8, 2), self.holidays) - self.assertIn(date(2020, 8, 3), self.holidays) - - -class TestKorea(unittest.TestCase): - - def setUp(self): - self.holidays = holidays.KR() - - def test_common(self): - holidaysNoObserved = holidays.KR(observed=False) - self.assertEqual(holidaysNoObserved[date(2019, 1, 1)], - "New Year's Day") - - self.assertNotIn(date(1582, 10, 2), self.holidays) - self.assertNotIn(date(1582, 11, 14), self.holidays) - - def test_first_day_of_january(self): - for year in range(2006, 2021): - self.assertIn(self.holidays[date(year, 1, 1)], - "New Year's Day") - - def test_lunar_new_year(self): - for year, month, day in [ - (2006, 1, 28), (2007, 2, 17), (2010, 2, 13), (2014, 1, 30)]: - self.assertEqual(self.holidays[date(year, month, day)], - "The day preceding of Lunar New Year's Day") - - for year, month, day in [ - (1916, 2, 4), (1944, 1, 26), (1954, 2, 4), (1958, 2, 19), - (1966, 1, 22), (1988, 2, 18), (1997, 2, 8), (2008, 2, 7), - (2009, 1, 26), (2011, 2, 3), (2012, 1, 23), (2014, 1, 31), - (2015, 2, 19), (2016, 2, 8), (2017, 1, 28), (2018, 2, 16), - (2019, 2, 5), (2020, 1, 25), (2027, 2, 7), (2028, 1, 27)]: - self.assertEqual(self.holidays[date(year, month, day)], - "Lunar New Year's Day") - - for year, month, day in [ - (2006, 1, 30), (2007, 2, 19), (2008, 2, 8), (2009, 1, 27), - (2010, 2, 15), (2011, 2, 4), (2012, 1, 24), (2013, 2, 11), - (2014, 2, 1), (2015, 2, 20), (2016, 2, 9), (2018, 2, 17), - (2019, 2, 6)]: - self.assertEqual(self.holidays[date(year, month, day)], - "The second day of Lunar New Year's Day") - - for year, month, day in [ - (2016, 2, 10), (2017, 1, 30), - (2020, 1, 27)]: - self.assertEqual(self.holidays[date(year, month, day)], - "Alternative holiday of Lunar New Year's Day") - - self.assertNotIn(date(2015, 2, 21), self.holidays) - self.assertNotIn(date(2015, 2, 7), self.holidays) - - def test_independence_movement_day(self): - for year, month, day in [ - (2006, 3, 1), (2007, 3, 1), (2008, 3, 1), (2009, 3, 1), - (2010, 3, 1), (2011, 3, 1), (2012, 3, 1), (2013, 3, 1), - (2014, 3, 1), (2016, 3, 1), (2017, 3, 1), (2018, 3, 1), - (2019, 3, 1), (2020, 3, 1)]: - self.assertEqual(self.holidays[date(year, month, day)], - "Independence Movement Day") - - def test_tree_planting_day(self): - for year, month, day in [ - (1949, 4, 5), (1962, 4, 5), (1982, 4, 5), (1990, 4, 5), - (1995, 4, 5), (1998, 4, 5), (2000, 4, 5), (2007, 4, 5)]: - self.assertEqual(self.holidays[date(year, month, day)], - "Tree Planting Day") - - def test_childrens_day(self): - for year, month, day in [ - (2015, 5, 5), (2016, 5, 5), (2017, 5, 5), (2018, 5, 5)]: - self.assertEqual(self.holidays[date(year, month, day)], - "Children's Day") - - for year, month, day in [ - (2018, 5, 7), (2019, 5, 6)]: - self.assertEqual(self.holidays[date(year, month, day)], - "Alternative holiday of Children's Day") - for year, month, day in [ - (2025, 5, 6), (2044, 5, 6)]: - self.assertIn("Alternative holiday of Children's Day", - self.holidays[date(year, month, day)]) - - def test_birthday_of_buddha(self): - name = "Birthday of the Buddha" - for year, month, day in [ - (1931, 5, 25), (1968, 5, 5), (2010, 5, 21), (2011, 5, 10), - (2012, 5, 28), (2013, 5, 17), (2014, 5, 6), (2015, 5, 25), - (2016, 5, 14), (2017, 5, 3), (2018, 5, 22), (2019, 5, 12), - (2020, 4, 30), (2021, 5, 19), (2022, 5, 8), (2023, 5, 27), - (2024, 5, 15), (2026, 5, 24), (2027, 5, 13), (2028, 5, 2), - (2029, 5, 20), (2030, 5, 9)]: - self.assertEqual(self.holidays[date(year, month, day)], name) - - for year, month, day in [(2001, 5, 1)]: - self.assertIn("Birthday of the Buddha", - self.holidays[date(year, month, day)]) - - def test_labour_day(self): - for year in [2006, 2007, 2008, 2009, 2010, 2012, 2013, 2014, 2015, - 2017, 2018, 2019, 2020]: - self.assertEqual(self.holidays[date(year, 5, 1)], - "Labour Day") - - def test_memorial_day(self): - for year in [2006, 2007, 2008, 2009, 2010, 2012, 2013, 2014, 2015, - 2017, 2018, 2019, 2020]: - self.assertEqual(self.holidays[date(year, 6, 6)], - "Memorial Day") - - def test_constitution_day(self): - for year in range(1948, 2007): - self.assertEqual( - self.holidays[date(year, 7, 17)], "Constitution Day") - self.assertNotIn(date(2008, 7, 17), self.holidays) - self.assertNotIn(date(1947, 7, 17), self.holidays) - - def test_liberation_day(self): - for year in range(1945, 2020): - self.assertEqual( - self.holidays[date(year, 8, 15)], "Liberation Day") - - def test_chuseok(self): - for year, month, day in [ - (2010, 9, 21), (2011, 9, 11), (2012, 9, 29), (2013, 9, 18), - (2014, 9, 7), (2015, 9, 26), (2016, 9, 14), (2018, 9, 23), - (2019, 9, 12), (2020, 9, 30), (2021, 9, 20), (2022, 9, 9), - (2023, 9, 28), (2024, 9, 16), (2025, 10, 5), (2026, 9, 24), - (2027, 9, 14), (2028, 10, 2), (2029, 9, 21), (2030, 9, 11)]: - self.assertEqual(self.holidays[date(year, month, day)], - "The day preceding of Chuseok") - - for year, month, day in [(2017, 10, 3)]: - self.assertIn("The day preceding of Chuseok", - self.holidays[date(year, month, day)]) - - for year, month, day in [ - (1942, 9, 25), (1978, 9, 17), (2010, 9, 22), (2011, 9, 12), - (2012, 9, 30), (2013, 9, 19), (2014, 9, 8), (2015, 9, 27), - (2016, 9, 15), (2017, 10, 4), (2018, 9, 24), (2019, 9, 13), - (2020, 10, 1), (2021, 9, 21), (2022, 9, 10), (2023, 9, 29), - (2024, 9, 17), (2025, 10, 6), (2026, 9, 25), (2027, 9, 15), - (2029, 9, 22), (2030, 9, 12), (2040, 9, 21)]: - self.assertEqual(self.holidays[date(year, month, day)], - "Chuseok") - - for year, month, day in [(2028, 10, 3)]: - self.assertIn("Chuseok", self.holidays[date(year, month, day)]) - - for year, month, day in [ - (2010, 9, 23), (2011, 9, 13), (2012, 10, 1), (2013, 9, 20), - (2014, 9, 9), (2015, 9, 28), (2016, 9, 16), (2017, 10, 5), - (2018, 9, 25), (2019, 9, 14), (2020, 10, 2), (2021, 9, 22), - (2022, 9, 11), (2023, 9, 30), (2024, 9, 18), (2025, 10, 7), - (2026, 9, 26), (2027, 9, 16), (2028, 10, 4), (2029, 9, 23), - (2030, 9, 13)]: - self.assertEqual(self.holidays[date(year, month, day)], - "The second day of Chuseok") - - for year, month, day in [ - (2014, 9, 10), (2015, 9, 29), (2018, 9, 26), (2022, 9, 12), - (2025, 10, 8), (2029, 9, 24)]: - self.assertEqual(self.holidays[date(year, month, day)], - "Alternative holiday of Chuseok") - - def test_national_foundation_day(self): - for year in range(1948, 2050): - if year in [1952, 1963, 1971, 1990, 2009, 2017, 2028, - 2036, 2039, 2047]: - self.assertIn("National Foundation Day", - self.holidays[date(year, 10, 3)]) - else: - self.assertEqual(self.holidays[date(year, 10, 3)], - "National Foundation Day") - - def test_hangeul_day(self): - for year in range(1948, 2007): - self.assertEqual(self.holidays[date(year, 10, 9)], - "Hangeul Day") - - def test_christmas_day(self): - for year in range(1948, 2050): - self.assertEqual(self.holidays[date(year, 12, 25)], - "Christmas Day") - - def test_years_range(self): - self.holidays = holidays.KR(years=range(2006, 2021)) - for year in range(2006, 2021): - self.assertIn(self.holidays[date(year, 1, 1)], - "New Year's Day") - - -class TestVietnam(unittest.TestCase): - - def setUp(self): - self.holidays = holidays.VN() - - def test_common(self): - self.assertEqual(self.holidays[date(2020, 1, 1)], "International New Year's Day") - - def test_first_day_of_january(self): - for year in range(1979, 2050): - self.assertIn("International New Year's Day", self.holidays[date(year, 1, 1)]) - - def test_lunar_new_year(self): - lunar_new_year_list = [ - (2008, 2, 7), (2009, 1, 26), (2010, 2, 14), (2011, 2, 3), - (2012, 1, 23), (2013, 2, 10), (2014, 1, 31), (2015, 2, 19), - (2016, 2, 8), (2017, 1, 28), (2018, 2, 16), (2019, 2, 5), - (2020, 1, 25), (2021, 2, 12), (2022, 2, 1)] - for year, month, day in lunar_new_year_list: - self.assertEqual(self.holidays[date(year, month, day) + relativedelta(days=-1)], - "Vietnamese New Year's Eve") - self.assertEqual(self.holidays[date(year, month, day) + relativedelta(days=0)], - "Vietnamese New Year") - self.assertEqual(self.holidays[date(year, month, day) + relativedelta(days=+1)], - "The second day of Tet Holiday") - self.assertEqual(self.holidays[date(year, month, day) + relativedelta(days=+2)], - "The third day of Tet Holiday") - self.assertEqual(self.holidays[date(year, month, day) + relativedelta(days=+3)], - "The forth day of Tet Holiday") - self.assertEqual(self.holidays[date(year, month, day) + relativedelta(days=+4)], - "The fifth day of Tet Holiday") - - def test_king_hung_day(self): - for year, month, day in [(2020, 4, 2), (2021, 4, 21), (2022, 4, 10)]: - self.assertEqual(self.holidays[date(year, month, day)], - "Hung Kings Commemoration Day") - - def test_liberation_day(self): - for year in range(1979, 2050): - self.assertIn("Liberation Day/Reunification Day", - self.holidays[date(year, 4, 30)]) - - def test_international_labor_day(self): - for year in range(1979, 2050): - self.assertIn("International Labor Day", - self.holidays[date(year, 5, 1)]) - - def test_independence_day(self): - for year in range(1979, 2050): - self.assertIn("Independence Day", - self.holidays[date(year, 9, 2)]) - - def test_years_range(self): - self.holidays = holidays.VN(years=range(1979, 2050)) - for year in range(1979, 2050): - self.assertIn("International New Year's Day", self.holidays[date(year, 1, 1)]) - - -class TestMorocco(unittest.TestCase): - - def setUp(self): - self.holidays = holidays.Morocco() - - def test_2019(self): - _holidays = [date(2019, 1, 1), - date(2019, 1, 11), - date(2019, 5, 1), - date(2019, 7, 30), - date(2019, 8, 14), - date(2019, 8, 20), - date(2019, 8, 21), - date(2019, 11, 6), - date(2019, 11, 18)] - - for holiday in _holidays: - self.assertIn(holiday, self.holidays) - - def test_1999(self): - self.holidays = holidays.Morocco(years=[1999]) - _holidays = [date(1999, 1, 1), - date(1999, 1, 11), - date(1999, 5, 1), - date(1999, 3, 3), - date(1999, 8, 14), - date(1999, 8, 20), - date(1999, 7, 9), - date(1999, 11, 6), - date(1999, 11, 18)] - - for holiday in _holidays: - self.assertIn(holiday, self.holidays) - - def test_1961(self): - self.holidays = holidays.Morocco(years=[1961]) - _holidays = [date(1961, 11, 18), ] - - for holiday in _holidays: - self.assertIn(holiday, self.holidays) - - def test_hijri_based(self): - if sys.version_info >= (3, 6): - import importlib.util - if importlib.util.find_spec("hijri_converter"): - self.holidays = holidays.Morocco(years=[2019, 1999]) - # eid_alfitr - self.assertIn(date(2019, 6, 4), self.holidays) - self.assertIn(date(2019, 6, 5), self.holidays) - # eid_aladha - self.assertIn(date(2019, 8, 11), self.holidays) - self.assertIn(date(2019, 8, 12), self.holidays) - # islamic_new_year - self.assertIn(date(2019, 8, 31), self.holidays) - - self.assertIn(date(2019, 11, 9), self.holidays) - self.assertIn(date(2019, 11, 10), self.holidays) - - self.assertIn(date(1999, 4, 17), self.holidays) - -class TestBurundi(unittest.TestCase): - - def setUp(self): - self.holidays = holidays.BI() - - def test_new_year_day(self): - for year in range(1979, 2050): - self.assertIn("New Year's Day", self.holidays[date(year, 1, 1)]) - - def test_unity_day(self): - self.assertIn("Unity Day", self.holidays[date(2017, 2, 5)]) - self.assertIn("Unity Day (Observed)", self.holidays[date(2017, 2, 6)]) - - def test_labour_day(self): - self.assertIn("Labour Day", self.holidays[date(2017, 5, 1)]) - self.assertIn("Labour Day (Observed)", self.holidays[date(2022, 5, 2)]) - - def test_rwagasore_day(self): - self.assertIn("Prince Louis Rwagasore Day", self.holidays[date(2017, 10, 13)]) - self.assertIn("Prince Louis Rwagasore Day (Observed)", self.holidays[date(2024, 10, 14)]) - - def test_ntaryamira_day(self): - self.assertIn("President Ntaryamira Day", self.holidays[date(2017, 4, 6)]) - - def test_ndadaye_day(self): - self.assertIn("President Ndadaye's Day", self.holidays[date(2017, 10, 21)]) - self.assertIn("President Ndadaye's Day (Observed)", self.holidays[date(2018, 10, 22)]) - - def test_independence_day(self): - for year in range(1962, 2050): - self.assertIn(date(year, 7, 1), self.holidays) - - for year in range(1930, 1962): - if year != 1958: - # in 1958 it's Eid Al Adha (as estimated by convertdate) - self.assertNotIn(date(year, 7, 1), self.holidays) - - self.assertIn("Independence Day (Observed)", self.holidays[date(2018, 7, 2)]) - - def test_ascension_day(self): - self.assertIn("Ascension Day", self.holidays[date(2020, 5, 21)]) - - def test_assumption_Day(self): - self.assertIn('Assumption Day', self.holidays[date(2020, 8, 15)]) - - def test_all_saints_Day(self): - self.assertIn("All Saints' Day", self.holidays[date(2020, 11, 1)]) - self.assertIn("All Saints' Day (Observed)", self.holidays[date(2020, 11, 2)]) - - def test_christmas_Day(self): - self.assertIn("Christmas Day", self.holidays[date(2020, 12, 25)]) - - def test_eid_al_adha(self): - if sys.version_info >= (3, 6): - import importlib.util - if importlib.util.find_spec("hijri_converter"): - self.holidays = holidays.Burundi(years=[2019, 1999]) - - # eid Al Adha - self.assertIn(date(2020, 7, 31), self.holidays) - self.assertIn(date(2020, 7, 31), self.holidays) - -class UnitedArabEmirates(unittest.TestCase): - - def setUp(self): - self.holidays = holidays.AE() - - def test_2020(self): - self.assertIn(date(2020, 1, 1), self.holidays) - self.assertIn(date(2020, 12, 1), self.holidays) - self.assertIn(date(2020, 12, 2), self.holidays) - self.assertIn(date(2020, 12, 3), self.holidays) - - def test_commemoration_day_since_2015(self): - # Before 2009 Jan 25th wasn't celebrated - self.holidays = holidays.AE(years=[2015]) - self.assertIn(date(2015, 11, 30), self.holidays) - - def test_hijri_based(self): - if sys.version_info >= (3, 6): - import importlib.util - if importlib.util.find_spec("hijri_converter"): - self.holidays = holidays.AE(years=[2020]) - # Eid Al-Fitr - self.assertIn(date(2020, 5, 24), self.holidays) - self.assertIn(date(2020, 5, 25), self.holidays) - self.assertIn(date(2020, 5, 26), self.holidays) - # Arafat Day & Eid Al-Adha - self.assertIn(date(2020, 7, 30), self.holidays) - self.assertIn(date(2020, 7, 31), self.holidays) - self.assertIn(date(2020, 8, 1), self.holidays) - self.assertIn(date(2020, 8, 2), self.holidays) - # Islamic New Year - self.assertIn(date(2020, 8, 23), self.holidays) - # Leilat Al-Miraj 2018 - self.assertIn(date(2018, 4, 13), self.holidays) - # Prophet's Birthday 2018 - self.assertIn(date(2018, 11, 19), self.holidays) - - -class TestDjibouti(unittest.TestCase): - - def setUp(self): - self.holidays = holidays.DJ() - - def test_2019(self): - self.assertIn(date(2019, 5, 1), self.holidays) - self.assertIn(date(2019, 6, 27), self.holidays) - self.assertIn(date(2019, 6, 28), self.holidays) - - def test_labour_day(self): - self.assertIn(date(2019, 5, 1), self.holidays) - - def test_hijri_based(self): - if sys.version_info >= (3, 6): - import importlib.util - if importlib.util.find_spec("hijri_converter"): - self.holidays = holidays.DJ(years=[2010]) - self.assertIn(date(2019, 6, 5), self.holidays) - self.assertIn(date(2019, 8, 10), self.holidays) - self.assertIn(date(2019, 8, 11), self.holidays) - self.assertIn(date(2019, 8, 12), self.holidays) - self.assertIn(date(2019, 8, 31), self.holidays) - self.assertIn(date(2019, 11, 9), self.holidays) - # eid_alfitr - self.assertIn(date(2019, 6, 5), self.holidays) - # eid_aladha - self.assertIn(date(2019, 8, 11), self.holidays) - # islamic_new_year - self.assertIn(date(2019, 8, 31), self.holidays) - # arafat_2019 - self.assertIn(date(2019, 8, 10), self.holidays) - # muhammad's birthday 2019 - self.assertIn(date(2019, 11, 9), self.holidays) - - -class TestAngola(unittest.TestCase): - - def setUp(self): - self.holidays = holidays.AO() - - def test_new_years(self): - self.assertIn('1975-01-01', self.holidays) - self.assertIn('2017-01-01', self.holidays) - self.assertIn('2999-01-01', self.holidays) - self.assertIn('2017-01-02', self.holidays) # sunday - - def test_easter(self): - self.assertIn(date(2017, 4, 14), self.holidays) - self.assertIn(date(2020, 4, 10), self.holidays) - self.assertIn(date(1994, 4, 1), self.holidays) - - def test_static(self): - self.assertIn('2004-03-08', self.holidays) - self.assertIn('2020-03-23', self.holidays) - - def test_long_weekend(self): - self.assertIn('2020-02-03', self.holidays) - self.assertIn('2019-04-05', self.holidays) - self.assertIn('2050-03-07', self.holidays) - - def test_not_holiday(self): - self.assertNotIn('2016-12-28', self.holidays) - self.assertNotIn('2015-03-02', self.holidays) - self.assertNotIn('2018-03-23', self.holidays) - - -class TestMalawi(unittest.TestCase): - - def setUp(self): - self.holidays = holidays.MW() - - def test_new_years(self): - self.assertIn('2015-01-01', self.holidays) - self.assertIn('2017-01-01', self.holidays) - self.assertIn('2999-01-01', self.holidays) - self.assertIn('2017-01-02', self.holidays) # sunday - - def test_good_friday(self): - self.assertIn('2022-04-15', self.holidays) - self.assertIn('2018-03-30', self.holidays) - - def test_easter(self): - self.assertIn(date(2017, 4, 14), self.holidays) - self.assertIn(date(2020, 4, 10), self.holidays) - self.assertIn(date(2015, 4, 6), self.holidays) - - def test_static(self): - self.assertIn('2004-03-03', self.holidays) - - def test_not_holiday(self): - self.assertNotIn('2016-12-28', self.holidays) - self.assertNotIn('2015-03-02', self.holidays) - - -class TestBangladesh(unittest.TestCase): - def setUp(self): - self.holidays = holidays.BD() - - def test_2020(self): - self.assertIn(date(2020, 2, 21), self.holidays) - self.assertIn(date(2020, 3, 17), self.holidays) - self.assertIn(date(2020, 3, 26), self.holidays) - self.assertIn(date(2020, 4, 14), self.holidays) - self.assertIn(date(2020,5, 1), self.holidays) - self.assertIn(date(2020, 8, 15), self.holidays) - self.assertIn(date(2020, 12, 16), self.holidays) - -class TestMozambique(unittest.TestCase): - def setUp(self): - self.holidays = holidays.MZ() - - def test_new_years(self): - self.assertIn('1975-01-01', self.holidays) - self.assertIn('2017-01-01', self.holidays) - self.assertIn('2999-01-01', self.holidays) - self.assertIn('2017-01-02', self.holidays) # sunday - - def test_easter(self): - self.assertIn(date(2017, 4, 14), self.holidays) - self.assertIn(date(2020, 4, 10), self.holidays) - self.assertIn(date(1994, 4, 1), self.holidays) - - def test_not_holiday(self): - self.assertNotIn('2018-02-04', self.holidays) - self.assertNotIn('2015-04-13', self.holidays) - self.assertNotIn('2018-03-23', self.holidays) +from test import * if __name__ == "__main__": unittest.main() diff --git a/tox.ini b/tox.ini new file mode 100644 index 000000000..a7250bfa7 --- /dev/null +++ b/tox.ini @@ -0,0 +1,16 @@ +[tox] +minversion = 3.4.0 +skip_missing_interpreters = true +envlist = py{36,37,38,39,py3}, pre-commit + +[pytest] +addopts = --cov=./ --cov-report term --cov-report xml --cov-config=pyproject.toml + +[testenv:pre-commit] +basepython=python +deps=pre-commit +commands=pre-commit run -a + +[testenv] +deps = -r{toxinidir}/requirements_dev.txt +commands = pytest