Esempio n. 1
0
def test_parse_format_inverse():
    for duration in (
        "0s",
        "1s",
        "1m",
        "1h",
        "1d",
        "1d 4h",
        "1d 4h 7s",
    ):
        assert format_duration(parse_duration(duration)) == duration
Esempio n. 2
0
def test_parse_format_inverse():
    for duration in (
            "0s",
            "1s",
            "1m",
            "1h",
            "1d",
            "1d 4h",
            "1d 4h 7s",
    ):
        assert format_duration(parse_duration(duration)) == duration
Esempio n. 3
0
def test_format_duration():
    assert format_duration(timedelta()) == "0s"
    assert format_duration(timedelta(seconds=10)) == "10s"
    assert format_duration(timedelta(minutes=10)) == "10m"
    assert format_duration(timedelta(hours=10)) == "10h"
    assert format_duration(timedelta(days=10)) == "10d"
    assert format_duration(timedelta(days=1, hours=2, minutes=3, seconds=4)) == "1d 2h 3m 4s"
Esempio n. 4
0
def test_format_duration():
    assert format_duration(timedelta()) == "0s"
    assert format_duration(timedelta(seconds=10)) == "10s"
    assert format_duration(timedelta(minutes=10)) == "10m"
    assert format_duration(timedelta(hours=10)) == "10h"
    assert format_duration(timedelta(days=10)) == "10d"
    assert format_duration(timedelta(days=1, hours=2, minutes=3,
                                     seconds=4)) == "1d 2h 3m 4s"