summaryrefslogtreecommitdiffstats
path: root/tests/time/test_behavior.py
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2023-01-05 10:38:41 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2023-01-05 10:39:17 +0000
commitd6d80a17444c90259c5bfdacb84c61e6bfece655 (patch)
tree157bff98bd572acf0b64cd5d478b0bdac87a37ae /tests/time/test_behavior.py
parentReleasing debian version 2.1.2-4. (diff)
downloadpendulum-d6d80a17444c90259c5bfdacb84c61e6bfece655.tar.xz
pendulum-d6d80a17444c90259c5bfdacb84c61e6bfece655.zip
Merging upstream version 3.0.0~a1.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'tests/time/test_behavior.py')
-rw-r--r--tests/time/test_behavior.py49
1 files changed, 49 insertions, 0 deletions
diff --git a/tests/time/test_behavior.py b/tests/time/test_behavior.py
new file mode 100644
index 0000000..0071c94
--- /dev/null
+++ b/tests/time/test_behavior.py
@@ -0,0 +1,49 @@
+from __future__ import annotations
+
+import pickle
+
+from datetime import time
+
+import pytest
+
+import pendulum
+
+from pendulum import Time
+
+
+@pytest.fixture()
+def p():
+ return pendulum.Time(12, 34, 56, 123456, tzinfo=pendulum.timezone("Europe/Paris"))
+
+
+@pytest.fixture()
+def d():
+ return time(12, 34, 56, 123456, tzinfo=pendulum.timezone("Europe/Paris"))
+
+
+def test_hash(p, d):
+ assert hash(d) == hash(p)
+ dt1 = Time(12, 34, 57, 123456)
+
+ assert hash(p) != hash(dt1)
+
+
+def test_pickle():
+ dt1 = Time(12, 34, 56, 123456)
+ s = pickle.dumps(dt1)
+ dt2 = pickle.loads(s)
+
+ assert dt2 == dt1
+
+
+def test_utcoffset(p, d):
+ assert d.utcoffset() == p.utcoffset()
+
+
+def test_dst(p, d):
+ assert d.dst() == p.dst()
+
+
+def test_tzname(p, d):
+ assert d.tzname() == p.tzname()
+ assert Time(12, 34, 56, 123456).tzname() == time(12, 34, 56, 123456).tzname()