From d6d80a17444c90259c5bfdacb84c61e6bfece655 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Thu, 5 Jan 2023 11:38:41 +0100 Subject: Merging upstream version 3.0.0~a1. Signed-off-by: Daniel Baumann --- tests/time/test_strings.py | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100644 tests/time/test_strings.py (limited to 'tests/time/test_strings.py') 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" -- cgit v1.2.3