summaryrefslogtreecommitdiffstats
path: root/tests/interval/test_add_subtract.py
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2023-01-05 10:38:34 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2023-01-05 10:38:34 +0000
commite3bdad36cc3a1a00c1e6772ca1c1898085ab73e0 (patch)
tree34512072a667ae716fd262e7b37e733e60fe4d89 /tests/interval/test_add_subtract.py
parentAdding upstream version 2.1.2. (diff)
downloadpendulum-e3bdad36cc3a1a00c1e6772ca1c1898085ab73e0.tar.xz
pendulum-e3bdad36cc3a1a00c1e6772ca1c1898085ab73e0.zip
Adding upstream version 3.0.0~a1.upstream/3.0.0_a1
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'tests/interval/test_add_subtract.py')
-rw-r--r--tests/interval/test_add_subtract.py49
1 files changed, 49 insertions, 0 deletions
diff --git a/tests/interval/test_add_subtract.py b/tests/interval/test_add_subtract.py
new file mode 100644
index 0000000..88525a3
--- /dev/null
+++ b/tests/interval/test_add_subtract.py
@@ -0,0 +1,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)
+ 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)
+
+ period = end - start
+ new_end = start + period
+
+ assert new_end == end