summaryrefslogtreecommitdiffstats
path: root/tests/time/test_behavior.py
diff options
context:
space:
mode:
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()