<commit_before># -*- 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 <<EMAIL>> (c) 2014-2017
#           dr-prodigy <<EMAIL>> (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_matariki(self):
        for dt in [
            date(2022, 6, 24),
            date(2023, 7, 14),
            date(2024, 6, 28),
            date(2025, 6, 20),
            date(2026, 7, 10),
            date(2027, 6, 25),
            date(2028, 7, 14),
            date(2029, 7, 6),
            date(2030, 6, 21),
            date(2031, 7, 11),
            date(2032, 7, 2),
            date(2033, 6, 24),
            date(2034, 7, 7),
            date(2035, 6, 29),
            date(2036, 7, 18),
            date(2037, 7, 10),
            date(2038, 6, 25),
            date(2039, 7, 15),
            date(2040, 7, 6),
            date(2041, 7, 19),
            date(2042, 7, 11),
            date(2043, 7, 3),
            date(2044, 6, 24),
            date(2045, 7, 7),
            date(2046, 6, 29),
            date(2047, 7, 19),
            date(2048, 7, 3),
            date(2049, 6, 25),
            date(2050, 7, 15),
            date(2051, 6, 30),
            date(2052, 6, 21)
        ]:
            self.assertIn(dt, self.holidays)
            self.assertEqual(self.holidays[dt], "Matariki")
            self.assertNotIn(dt + relativedelta(days=-1), self.holidays)
            self.assertNotIn(dt + relativedelta(days=+1), self.holidays)


    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,<commit_msg>flake8 issue fix<commit_after># -*- 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 <<EMAIL>> (c) 2014-2017
#           dr-prodigy <ma<EMAIL>> (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_matariki(self):
        for dt in [
            date(2022, 6, 24),
            date(2023, 7, 14),
            date(2024, 6, 28),
            date(2025, 6, 20),
            date(2026, 7, 10),
            date(2027, 6, 25),
            date(2028, 7, 14),
            date(2029, 7, 6),
            date(2030, 6, 21),
            date(2031, 7, 11),
            date(2032, 7, 2),
            date(2033, 6, 24),
            date(2034, 7, 7),
            date(2035, 6, 29),
            date(2036, 7, 18),
            date(2037, 7, 10),
            date(2038, 6, 25),
            date(2039, 7, 15),
            date(2040, 7, 6),
            date(2041, 7, 19),
            date(2042, 7, 11),
            date(2043, 7, 3),
            date(2044, 6, 24),
            date(2045, 7, 7),
            date(2046, 6, 29),
            date(2047, 7, 19),
            date(2048, 7, 3),
            date(2049, 6, 25),
            date(2050, 7, 15),
            date(2051, 6, 30),
            date(2052, 6, 21),
        ]:
            self.assertIn(dt, self.holidays)
            self.assertEqual(self.holidays[dt], "Matariki")
            self.assertNotIn(dt + relativedelta(days=-1), self.holidays)
            self.assertNotIn(dt + relativedelta(days=+1), self.holidays)

    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,
{'fraction_non_alphanumeric': 0.11401438217050008, 'fraction_numerical': 0.09458198386122853, 'mean_word_length': 0.9678116223806438, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 11, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6868929', 'n_tokens_mistral': 6628, 'n_tokens_neox': 5508, 'n_words': 1303}