def test_1992_to_2021(self): leap_year = 366 not_leap_year = 365 expected = Date(2021, 1, 1) test_date = Date(1991, 1, 1) for intyear in range(1992, 2022): year = Year(intyear) if year.is_leap(): test_date += DayDelta(leap_year) else: test_date += DayDelta(not_leap_year) self.assertEqual(expected, test_date)
def test_ne(self): self.assertNotEqual(DayDelta(1), DayDelta(2))
def test_eq(self): self.assertEqual(DayDelta(1), DayDelta(1))
def test_ge(self): self.assertGreaterEqual(DayDelta(2), DayDelta(1)) self.assertGreaterEqual(DayDelta(2), DayDelta(2))
def test_gt(self): self.assertGreater(DayDelta(2), DayDelta(1))
def test_le(self): self.assertLessEqual(DayDelta(1), DayDelta(2)) self.assertLessEqual(DayDelta(2), DayDelta(2))
def test_lt(self): self.assertLess(DayDelta(1), DayDelta(2))
def test_Date_add_DayDelta(self): self.assertEqual(Date(1, 1, 10), Date(1, 1, 1) + DayDelta(9))
def test_remove_day_2021_3_1(self): self.assertEqual(Date(2021, 2, 28), Date(2021, 3, 1) - DayDelta(1)) self.assertEqual(Date(2021, 2, 28), Date(2021, 3, 1) + DayDelta(-1))
def test_remove_366_days_in_a_leap_year(self): self.assertEqual(Date(2018, 12, 31), Date(2020, 1, 1) - DayDelta(366)) self.assertEqual(Date(2018, 12, 31), Date(2020, 1, 1) + DayDelta(-366)) self.assertEqual(Date(1991, 2, 28), Date(1992, 2, 29) - DayDelta(366)) self.assertEqual(Date(1991, 2, 28), Date(1992, 2, 29) + DayDelta(-366))
def test_add_366_days_in_a_leap_year(self): self.assertEqual(Date(2021, 1, 1), Date(2020, 1, 1) + DayDelta(366)) self.assertEqual(Date(1992, 2, 29), Date(1991, 2, 28) + DayDelta(366))
def test_remove_365_days(self): self.assertEqual(Date(1, 1, 1), Date(2, 1, 1) - DayDelta(365)) self.assertEqual(Date(1, 1, 1), Date(2, 1, 1) + DayDelta(-365)) self.assertEqual(Date(1991, 3, 1), Date(1992, 2, 29) - DayDelta(365)) self.assertEqual(Date(1991, 3, 1), Date(1992, 2, 29) + DayDelta(-365))
def test_add_365_days(self): self.assertEqual(Date(2, 1, 1), Date(1, 1, 1) + DayDelta(365)) self.assertEqual(Date(1993, 2, 28), Date(1992, 2, 29) + DayDelta(365))
def test_february_not_leap_year_27_add_3(self): self.assertEqual(Date(1991, 3, 2), Date(1991, 2, 27) + DayDelta(3))