Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def test_nth_of_month_outside_year(self):
d = Pendulum.create(1975, 12, 5)
self.assertRaises(PendulumException, d.nth_of, 'month', 55, pendulum.MONDAY)
def test_average_from_greater(self):
d1 = Pendulum.create(2000, 1, 1, 1, 1, 1, 1, tz='local')
d2 = Pendulum.create(2009, 12, 31, 23, 59, 59, 999999, tz='local').average(d1)
self.assertPendulum(d2, 2004, 12, 31, 12, 30, 30, 500000)
def test_average_from_same(self):
d1 = Pendulum.create(2000, 1, 31, 2, 3, 4, 5)
d2 = Pendulum.create(2000, 1, 31, 2, 3, 4, 5).average(d1)
self.assertPendulum(d2, 2000, 1, 31, 2, 3, 4, 5)
def test_next(self):
d = Pendulum.create(1975, 5, 21).next()
self.assertPendulum(d, 1975, 5, 28, 0, 0, 0)
def test_previous_saturday(self):
d = Pendulum.create(1975, 5, 21).previous(6)
self.assertPendulum(d, 1975, 5, 17, 0, 0, 0)
def test_last_day_of_year(self):
d = Pendulum.create(1975, 8, 5).last_of('year', )
self.assertPendulum(d, 1975, 12, 31, 0, 0, 0)
def test_next_keep_time(self):
d = Pendulum.create(1975, 5, 21, 12).next()
self.assertPendulum(d, 1975, 5, 28, 0, 0, 0)
d = Pendulum.create(1975, 5, 21, 12).next(keep_time=True)
self.assertPendulum(d, 1975, 5, 28, 12, 0, 0)
def test_next_saturday(self):
d = Pendulum.create(1975, 5, 21).next(6)
self.assertPendulum(d, 1975, 5, 24, 0, 0, 0)
def test_first_of_quarter_from_a_day_that_will_not_exist_in_the_first_month(self):
d = Pendulum.create(2014, 5, 31).first_of('quarter', )
self.assertPendulum(d, 2014, 4, 1, 0, 0, 0)
def test_average_from_lower(self):
d1 = Pendulum.create(2009, 12, 31, 23, 59, 59, 999999, tz='local')
d2 = Pendulum.create(2000, 1, 1, 1, 1, 1, 1, tz='local').average(d1)
self.assertPendulum(d2, 2004, 12, 31, 12, 30, 30, 500000)