From 2473d6dbbaaf98a70c2d3f2f597fd670d3249e7f Mon Sep 17 00:00:00 2001 From: Nuz / Lovegood Date: Mon, 11 Jul 2022 11:14:32 -0700 Subject: [PATCH] Add more tests to catch the "odd months" bug described in #14. --- tests/test_time.py | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/tests/test_time.py b/tests/test_time.py index 456468f..220acf9 100644 --- a/tests/test_time.py +++ b/tests/test_time.py @@ -494,6 +494,14 @@ def test_precisedelta_one_unit_enough( "minutes", "0 minutes", ), + (dt.timedelta(days=31), "seconds", "1 month and 12 hours"), + (dt.timedelta(days=32), "seconds", "1 month, 1 day and 12 hours"), + (dt.timedelta(days=62), "seconds", "2 months and 1 day"), + (dt.timedelta(days=92), "seconds", "3 months and 12 hours"), + (dt.timedelta(days=31), "days", "1 month and 0.50 days"), + (dt.timedelta(days=32), "days", "1 month and 1.50 days"), + (dt.timedelta(days=62), "days", "2 months and 1 day"), + (dt.timedelta(days=92), "days", "3 months and 0.50 days"), ], ) def test_precisedelta_multiple_units( @@ -545,6 +553,9 @@ def test_precisedelta_multiple_units( (dt.timedelta(days=5, hours=4, seconds=30 * 60), "days", "%0.2f", "5.19 days"), (dt.timedelta(days=31), "days", "%d", "1 month"), (dt.timedelta(days=31.01), "days", "%d", "1 month and 1 day"), + (dt.timedelta(days=31.99), "days", "%d", "1 month and 1 day"), + (dt.timedelta(days=32), "days", "%d", "1 month and 2 days"), + (dt.timedelta(days=62), "days", "%d", "2 months and 1 day"), (dt.timedelta(days=92), "days", "%d", "3 months"), (dt.timedelta(days=120), "months", "%0.2f", "3.93 months"), (dt.timedelta(days=183), "years", "%0.1f", "0.5 years"),