diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2023-01-05 10:38:41 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2023-01-05 10:39:17 +0000 |
commit | d6d80a17444c90259c5bfdacb84c61e6bfece655 (patch) | |
tree | 157bff98bd572acf0b64cd5d478b0bdac87a37ae /tests/time/test_strings.py | |
parent | Releasing debian version 2.1.2-4. (diff) | |
download | pendulum-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_strings.py')
-rw-r--r-- | tests/time/test_strings.py | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/tests/time/test_strings.py b/tests/time/test_strings.py new file mode 100644 index 0000000..db3c9cd --- /dev/null +++ b/tests/time/test_strings.py @@ -0,0 +1,39 @@ +from __future__ import annotations + +from pendulum import Time + + +def test_to_string(): + d = Time(1, 2, 3) + assert str(d) == "01:02:03" + d = Time(1, 2, 3, 123456) + assert str(d) == "01:02:03.123456" + + +def test_repr(): + d = Time(1, 2, 3) + assert repr(d) == "Time(1, 2, 3)" + + d = Time(1, 2, 3, 123456) + assert repr(d) == "Time(1, 2, 3, 123456)" + + +def test_format_with_locale(): + d = Time(14, 15, 16) + assert d.format("hh:mm:ss A", locale="fr") == "02:15:16 PM" + + +def test_strftime(): + d = Time(14, 15, 16) + assert d.strftime("%H") == "14" + + +def test_for_json(): + d = Time(14, 15, 16) + assert d.for_json() == "14:15:16" + + +def test_format(): + d = Time(14, 15, 16) + assert f"{d}" == "14:15:16" + assert f"{d:mm}" == "15" |