diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2021-01-30 07:57:29 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2021-01-30 07:57:29 +0000 |
commit | a003430ded2dbfbfb48acd3c17f143cbafeee60a (patch) | |
tree | 9016b0b904b32c46542f48de704b3e536b90e1af /tests/period/test_add_subtract.py | |
parent | Initial commit. (diff) | |
download | pendulum-a003430ded2dbfbfb48acd3c17f143cbafeee60a.tar.xz pendulum-a003430ded2dbfbfb48acd3c17f143cbafeee60a.zip |
Adding upstream version 2.1.2.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to '')
-rw-r--r-- | tests/period/test_add_subtract.py | 52 |
1 files changed, 52 insertions, 0 deletions
diff --git a/tests/period/test_add_subtract.py b/tests/period/test_add_subtract.py new file mode 100644 index 0000000..d9a739e --- /dev/null +++ b/tests/period/test_add_subtract.py @@ -0,0 +1,52 @@ +# -*- coding: utf-8 -*- + +import pendulum + + +def test_dst_add(): + start = pendulum.datetime(2017, 3, 7, tz="America/Toronto") + end = start.add(days=6) + period = end - start + new_end = start + period + + 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) + period = end - start + new_end = start + period + + assert new_end == end + + +def test_dst_subtract(): + start = pendulum.datetime(2017, 3, 7, tz="America/Toronto") + end = start.add(days=6) + period = end - start + new_start = end - period + + assert new_start == start + + +def test_naive_subtract(): + start = pendulum.naive(2013, 3, 31, 1, 30) + end = start.add(hours=1) + period = end - start + new_end = start + period + + 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) + + print((start - end).in_words()) + + period = end - start + print(period.in_words()) + new_end = start + period + + assert new_end == end |