1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
|
import datetime
import mgr_util
import pytest
@pytest.mark.parametrize(
"delta, out",
[
(datetime.timedelta(minutes=90), '90m'),
(datetime.timedelta(minutes=190), '3h'),
(datetime.timedelta(days=3), '3d'),
(datetime.timedelta(hours=3), '3h'),
(datetime.timedelta(days=365 * 3.1), '3y'),
(datetime.timedelta(minutes=90), '90m'),
]
)
def test_pretty_timedelta(delta: datetime.timedelta, out: str):
assert mgr_util.to_pretty_timedelta(delta) == out
|