1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49
|
from __future__ import annotations
import pendulum
def test_dst_add():
start = pendulum.datetime(2017, 3, 7, tz="America/Toronto")
end = start.add(days=6)
interval = end - start
new_end = start + interval
assert new_end == end
def test_dst_add_non_variable_units():
start = pendulum.datetime(2013, 3, 31, 1, 30, tz="Europe/Paris")
end = start.add(hours=1)
interval = end - start
new_end = start + interval
assert new_end == end
def test_dst_subtract():
start = pendulum.datetime(2017, 3, 7, tz="America/Toronto")
end = start.add(days=6)
interval = end - start
new_start = end - interval
assert new_start == start
def test_naive_subtract():
start = pendulum.naive(2013, 3, 31, 1, 30)
end = start.add(hours=1)
interval = end - start
new_end = start + interval
assert new_end == end
def test_negative_difference_subtract():
start = pendulum.datetime(2018, 5, 28, 12, 34, 56, 123456)
end = pendulum.datetime(2018, 1, 1)
interval = end - start
new_end = start + interval
assert new_end == end
|