Skip to content

Commit

Permalink
Add more tests to catch the "odd months" bug described in python-huma…
Browse files Browse the repository at this point in the history
  • Loading branch information
nuztalgia committed Jul 11, 2022
1 parent 27643cc commit 2473d6d
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions tests/test_time.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down Expand Up @@ -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"),
Expand Down

0 comments on commit 2473d6d

Please sign in to comment.