summaryrefslogtreecommitdiffstats
path: root/tests/date/test_behavior.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/date/test_behavior.py
parentAdding upstream version 2.1.2. (diff)
downloadpendulum-83a7f839c9a467bc9d84890cf9e61ed3520cd627.tar.xz
pendulum-83a7f839c9a467bc9d84890cf9e61ed3520cd627.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/date/test_behavior.py')
-rw-r--r--tests/date/test_behavior.py73
1 files changed, 73 insertions, 0 deletions
diff --git a/tests/date/test_behavior.py b/tests/date/test_behavior.py
new file mode 100644
index 0000000..98dd175
--- /dev/null
+++ b/tests/date/test_behavior.py
@@ -0,0 +1,73 @@
+from __future__ import annotations
+
+import pickle
+
+from datetime import date
+
+import pytest
+
+import pendulum
+
+
+@pytest.fixture()
+def p():
+ return pendulum.Date(2016, 8, 27)
+
+
+@pytest.fixture()
+def d():
+ return date(2016, 8, 27)
+
+
+def test_timetuple(p, d):
+ assert p.timetuple() == d.timetuple()
+
+
+def test_ctime(p, d):
+ assert p.ctime() == d.ctime()
+
+
+def test_isoformat(p, d):
+ assert p.isoformat() == d.isoformat()
+
+
+def test_toordinal(p, d):
+ assert p.toordinal() == d.toordinal()
+
+
+def test_weekday(p, d):
+ assert p.weekday() == d.weekday()
+
+
+def test_isoweekday(p, d):
+ assert p.isoweekday() == d.isoweekday()
+
+
+def test_isocalendar(p, d):
+ assert p.isocalendar() == d.isocalendar()
+
+
+def test_fromtimestamp():
+ assert pendulum.Date.fromtimestamp(0) == date.fromtimestamp(0)
+
+
+def test_fromordinal():
+ assert pendulum.Date.fromordinal(730120) == date.fromordinal(730120)
+
+
+def test_hash():
+ d1 = pendulum.Date(2016, 8, 27)
+ d2 = pendulum.Date(2016, 8, 27)
+ d3 = pendulum.Date(2016, 8, 28)
+
+ assert hash(d2) == hash(d1)
+ assert hash(d1) != hash(d3)
+
+
+def test_pickle():
+ d1 = pendulum.Date(2016, 8, 27)
+ s = pickle.dumps(d1)
+ d2 = pickle.loads(s)
+
+ assert isinstance(d2, pendulum.Date)
+ assert d2 == d1