示例#1
0
    def test_create_uses_transition_rule(self):
        pendulum.set_transition_rule(pendulum.PRE_TRANSITION)
        dt = pendulum.create(2013, 3, 31, 2, 30, 45, 123456, 'Europe/Paris')

        self.assertEqual(2013, dt.year)
        self.assertEqual(3, dt.month)
        self.assertEqual(31, dt.day)
        self.assertEqual(1, dt.hour)
        self.assertEqual(30, dt.minute)
        self.assertEqual(45, dt.second)
        self.assertEqual(123456, dt.microsecond)
        self.assertEqual('Europe/Paris', dt.timezone_name)
        self.assertEqual(3600, dt.offset)
        self.assertFalse(dt.is_dst)
示例#2
0
    def test_add_time_to_new_transition_does_not_use_transition_rule(self):
        pendulum.set_transition_rule(pendulum.TRANSITION_ERROR)
        dt = pendulum.create(2013, 3, 31, 1, 59, 59, 999999, 'Europe/Paris')

        self.assertPendulum(dt, 2013, 3, 31, 1, 59, 59, 999999)
        self.assertEqual('Europe/Paris', dt.timezone_name)
        self.assertEqual(3600, dt.offset)
        self.assertFalse(dt.is_dst)

        dt = dt.add(microseconds=1)

        self.assertPendulum(dt, 2013, 3, 31, 3, 0, 0, 0)
        self.assertEqual('Europe/Paris', dt.timezone_name)
        self.assertEqual(7200, dt.offset)
        self.assertTrue(dt.is_dst)
示例#3
0
 def test_set(self):
     pendulum.set_transition_rule(pendulum.PRE_TRANSITION)
     self.assertEqual(pendulum.PRE_TRANSITION,
                      pendulum.get_transition_rule())