示例#1
0
 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))
示例#2
0
 def test_set_month(self):
     date = Date(1991, 10, 25)
     with self.assertRaises(ValueError):
         date.month = 66
示例#3
0
    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))
示例#4
0
 def test_add_12_months(self):
     self.assertEqual(Date(2, 1, 1), Date(1, 1, 1) + MonthDelta(12))
     self.assertEqual(Date(1993, 2, 28), Date(1992, 2, 29) + MonthDelta(12))
示例#5
0
 def test_add_12_months_in_a_leap_year(self):
     self.assertEqual(Date(2021, 1, 1), Date(2020, 1, 1) + MonthDelta(12))
     self.assertEqual(Date(1992, 2, 28), Date(1991, 2, 28) + MonthDelta(12))
示例#6
0
 def test_Date_add_DayDelta(self):
     self.assertEqual(Date(1, 2, 1), Date(1, 1, 1) + MonthDelta(1))
示例#7
0
 def test_february_not_leap_year_27_add_3(self):
     self.assertEqual(Date(1991, 5, 27), Date(1991, 2, 27) + MonthDelta(3))
示例#8
0
 def test_Date_add_YearDelta(self):
     self.assertEqual(Date(2, 1, 1), Date(1, 1, 1) + YearDelta(1))
示例#9
0
 def test_add_1_year(self):
     self.assertEqual(Date(2, 1, 1), Date(1, 1, 1) + YearDelta(1))
     self.assertEqual(Date(1993, 2, 28), Date(1992, 2, 28) + YearDelta(1))
示例#10
0
 def test_february_leap_year_27_add_3(self):
     self.assertEqual(Date(1992, 3, 1), Date(1992, 2, 27) + DayDelta(3))
示例#11
0
 def test_YearDelta_add_Date(self):
     self.assertEqual(Date(2, 1, 1), YearDelta(1) + Date(1, 1, 1))
示例#12
0
 def test_1992_to_2021(self):
     self.assertEqual(Date(2021, 1, 1), Date(1992, 1, 1) + YearDelta(29))
示例#13
0
 def test_remove_month_2021_3_31(self):
     self.assertEqual(Date(2021, 2, 28), Date(2021, 3, 31) - MonthDelta(1))
     self.assertEqual(Date(2021, 2, 28), Date(2021, 3, 31) + MonthDelta(-1))
示例#14
0
 def test_set_year(self):
     date = Date(1991, 10, 25)
     with self.assertRaises(ValueError):
         date.year = -66
示例#15
0
    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))
示例#16
0
    def test_remove_1_year(self):
        self.assertEqual(Date(1, 1, 1), Date(2, 1, 1) - YearDelta(1))
        self.assertEqual(Date(1, 1, 1), Date(2, 1, 1) + YearDelta(-1))

        self.assertEqual(Date(1991, 3, 1), Date(1992, 2, 29) - YearDelta(1))
        self.assertEqual(Date(1991, 3, 1), Date(1992, 2, 29) + YearDelta(-1))
示例#17
0
 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))
示例#18
0
 def test_add_1_year_in_a_leap_year(self):
     self.assertEqual(Date(2021, 1, 1), Date(2020, 1, 1) + YearDelta(1))
     self.assertEqual(Date(1992, 2, 28), Date(1991, 2, 28) + YearDelta(1))
     self.assertEqual(Date(1992, 3, 1), Date(1991, 3, 1) + YearDelta(1))
示例#19
0
 def test_february_leap_year_add_3(self):
     self.assertEqual(Date(1992, 2, 29), Date(1991, 11, 29) + MonthDelta(3))
示例#20
0
    def test_remove_1_year_in_a_leap_year(self):
        self.assertEqual(Date(2019, 1, 1), Date(2020, 1, 1) - YearDelta(1))
        self.assertEqual(Date(2019, 1, 1), Date(2020, 1, 1) + YearDelta(-1))

        self.assertEqual(Date(1991, 3, 1), Date(1992, 2, 29) - YearDelta(1))
        self.assertEqual(Date(1991, 3, 1), Date(1992, 2, 29) + YearDelta(-1))
示例#21
0
    def test_1992_to_2021(self):
        expected = Date(2021, 1, 1)
        test_date = Date(1991, 1, 1)

        self.assertEqual(expected, test_date + MonthDelta(30 * 12))
示例#22
0
 def test_remove_year_2021_3_1(self):
     self.assertEqual(Date(2020, 3, 1), Date(2021, 3, 1) - YearDelta(1))
     self.assertEqual(Date(2020, 3, 1), Date(2021, 3, 1) + YearDelta(-1))
示例#23
0
 def test_Date_add_DayDelta(self):
     self.assertEqual(Date(1, 1, 10), Date(1, 1, 1) + DayDelta(9))
示例#24
0
 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))
示例#25
0
 def test_repr(self):
     self.assertEqual(repr(Date(1991, 10, 25)), 'Date(1991, 10, 25)')
示例#26
0
 def test_set_day(self):
     date = Date(1991, 10, 25)
     with self.assertRaises(ValueError):
         date.day = 66