summaryrefslogtreecommitdiffstats
path: root/tests/date/test_strings.py
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2021-01-30 07:57:29 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2021-01-30 07:57:29 +0000
commita003430ded2dbfbfb48acd3c17f143cbafeee60a (patch)
tree9016b0b904b32c46542f48de704b3e536b90e1af /tests/date/test_strings.py
parentInitial commit. (diff)
downloadpendulum-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 'tests/date/test_strings.py')
-rw-r--r--tests/date/test_strings.py47
1 files changed, 47 insertions, 0 deletions
diff --git a/tests/date/test_strings.py b/tests/date/test_strings.py
new file mode 100644
index 0000000..2323bc3
--- /dev/null
+++ b/tests/date/test_strings.py
@@ -0,0 +1,47 @@
+# -*- coding: utf-8 -*-
+import pendulum
+
+
+def test_to_string():
+ d = pendulum.Date(2016, 10, 16)
+ assert str(d) == "2016-10-16"
+
+
+def test_to_date_string():
+ d = pendulum.Date(1975, 12, 25)
+ assert d.to_date_string() == "1975-12-25"
+
+
+def test_to_formatted_date_string():
+ d = pendulum.Date(1975, 12, 25)
+ assert d.to_formatted_date_string() == "Dec 25, 1975"
+
+
+def test_repr():
+ d = pendulum.Date(1975, 12, 25)
+
+ assert repr(d) == "Date(1975, 12, 25)"
+ assert d.__repr__() == "Date(1975, 12, 25)"
+
+
+def test_format_with_locale():
+ d = pendulum.Date(1975, 12, 25)
+ expected = u"jeudi 25e jour de décembre 1975"
+ assert d.format("dddd Do [jour de] MMMM YYYY", locale="fr") == expected
+
+
+def test_strftime():
+ d = pendulum.Date(1975, 12, 25)
+ assert d.strftime("%d") == "25"
+
+
+def test_for_json():
+ d = pendulum.Date(1975, 12, 25)
+ assert d.for_json() == "1975-12-25"
+
+
+def test_format():
+ d = pendulum.Date(1975, 12, 25)
+ assert "{}".format(d) == "1975-12-25"
+ assert "{:YYYY}".format(d) == "1975"
+ assert "{:%Y}".format(d) == "1975"