Exemple #1
0
class TestAstronomicalCalendar(CalendarTest):
    def setUp(self):
        self.calendar = AstronomicalCalendar()
        self.addTypeEqualityFunc(
            DateWithCalendar,
            DateWithCalendar.make_assertEqual(self)
        )

    def test_zero_year_date(self):
        d = self.calendar.date(0, 1, 1)
        self.assertIsNotNone(d)

    def test_non_zero_year_date(self):
        d = self.calendar.date(1, 1, 1)
        self.assertIsNotNone(d)

    @given(integers(min_value=1583, max_value=last_vanilla_year))
    def test_CE_dates_after_1582(self, y):
        d = self.calendar.date(y, 1, 1)
        converted = d.convert_to(ProlepticGregorianCalendar())
        self.assertIsNotNone(converted)
        expected = ProlepticGregorianCalendar().date(y, 1, 1)
        self.assertEqual(converted, expected)

    @given(integers(min_value=1, max_value=1582))
    def test_CE_dates_before_1582(self, y):
        d = self.calendar.date(y, 1, 1)
        converted = d.convert_to(JulianCalendar())
        self.assertIsNotNone(converted)
        expected = ProlepticJulianCalendar().date(y, 1, 1)
        self.assertEqual(converted, expected)

    @example(-2147483648)
    @given(integers(max_value=-45))
    def test_BCE_proleptic_dates(self, y):
        expected = ProlepticJulianCalendar().date(y - 1, 1, 1)
        d = self.calendar.date(y, 1, 1)
        converted = d.convert_to(ProlepticJulianCalendar())
        self.assertIsNotNone(converted)
        self.assertEqual(converted, expected)

    @given(integers(min_value=-44, max_value=-1))
    def test_BCE_julian_dates(self, y):
        expected = JulianCalendar().date(y - 1, 1, 1)
        d = self.calendar.date(y, 1, 1)
        converted = d.convert_to(JulianCalendar())
        self.assertIsNotNone(converted)
        self.assertEqual(converted, expected)
Exemple #2
0
 def setUp(self):
     self.calendar = AstronomicalCalendar()
     self.addTypeEqualityFunc(
         DateWithCalendar,
         DateWithCalendar.make_assertEqual(self)
     )