diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2023-01-05 10:38:34 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2023-01-05 10:38:34 +0000 |
commit | e3bdad36cc3a1a00c1e6772ca1c1898085ab73e0 (patch) | |
tree | 34512072a667ae716fd262e7b37e733e60fe4d89 /tests/date/test_strings.py | |
parent | Adding upstream version 2.1.2. (diff) | |
download | pendulum-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_strings.py')
-rw-r--r-- | tests/date/test_strings.py | 48 |
1 files changed, 48 insertions, 0 deletions
diff --git a/tests/date/test_strings.py b/tests/date/test_strings.py new file mode 100644 index 0000000..f373581 --- /dev/null +++ b/tests/date/test_strings.py @@ -0,0 +1,48 @@ +from __future__ import annotations + +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 = "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 f"{d}" == "1975-12-25" + assert f"{d:YYYY}" == "1975" + assert f"{d:%Y}" == "1975" |