def test_valid_day_for_february(self): year = randint(2000, 2999) for day in range(1, 29): with self.subTest(day=day, year=year): self.assertTrue(validate_day(year, 2, day))
def test_valid_day_for_30_days_months(self): for month in [4, 6, 9, 11]: year = randint(2000, 2999) for day in range(1, 31): with self.subTest(day=day, month=month, year=year): self.assertTrue(validate_day(year, month, day))
def test_invalid_day_for_30_days_months(self): for month in [4, 6, 9, 11]: year = randint(2000, 3000) with self.subTest(month=month, year=year): self.assertFalse(validate_day(year, month, 31))
def test_invalid_day_for_31_days_months(self): for month in [1, 3, 5, 7, 8, 10, 12]: year = randint(2000, 3000) with self.subTest(month=month, year=year): self.assertFalse(validate_day(year, month, 32))
def test_valid_day_for_31_days_months(self): for month in [1, 3, 5, 7, 8, 10, 12]: for day in range(1, 32): year = randint(2000, 3000) with self.subTest(day=day, month=month, year=year): self.assertTrue(validate_day(year, month, day))
def test_0_as_a_day(self): for month in range(1, 13): year = randint(2000, 3000) with self.subTest(month=month, year=year): self.assertFalse(validate_day(year, month, 0))
def test_invalid_day_for_february_not_leap_year(self): leap_years = [year for year in range(2000, 3000) if is_leap_year(year)] for year in [year for year in range(2000, 3000) if year not in leap_years]: with self.subTest(year=year): self.assertFalse(validate_day(year, 2, 29))
def test_valid_day_for_february_in_leap_years(self): leap_years = [year for year in range(2000, 3000) if is_leap_year(year)] for day in range(1, 30): year = choice(leap_years) with self.subTest(day=day, year=year): self.assertTrue(validate_day(year, 2, day))