Skip to content

Commit 3a5ff46

Browse files
nuztalgiaDaniel Gillet
authored andcommitted
Add tests defining the desired behavior for precisedelta.
1 parent bb99238 commit 3a5ff46

1 file changed

Lines changed: 21 additions & 0 deletions

File tree

tests/test_time.py

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -608,8 +608,29 @@ def test_precisedelta_multiple_units(
608608
"5 days and 4.50 hours",
609609
),
610610
(dt.timedelta(days=5, hours=4, seconds=30 * 60), "days", "%0.2f", "5.19 days"),
611+
(dt.timedelta(days=31), "days", "%d", "1 month"),
612+
(dt.timedelta(days=31.01), "days", "%d", "1 month and 1 day"),
613+
(dt.timedelta(days=92), "days", "%d", "3 months"),
611614
(dt.timedelta(days=120), "months", "%0.2f", "3.93 months"),
612615
(dt.timedelta(days=183), "years", "%0.1f", "0.5 years"),
616+
(0.01, "seconds", "%0.3f", "0.010 seconds"),
617+
(31, "minutes", "%d", "1 minute"),
618+
(60 + 29.99, "minutes", "%d", "1 minute"),
619+
(60 + 30, "minutes", "%d", "2 minutes"),
620+
(60 * 60 + 30.99, "minutes", "%.0f", "1 hour"),
621+
(60 * 60 + 31, "minutes", "%.0f", "1 hour and 1 minute"),
622+
(
623+
ONE_DAY - MILLISECONDS_1_337,
624+
"seconds",
625+
"%.1f",
626+
"23 hours, 59 minutes and 58.7 seconds",
627+
),
628+
(
629+
ONE_DAY - ONE_MILLISECOND,
630+
"seconds",
631+
"%.4f",
632+
"23 hours, 59 minutes and 59.9990 seconds",
633+
),
613634
],
614635
)
615636
def test_precisedelta_custom_format(

0 commit comments

Comments
 (0)