Ejemplo 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
Ejemplo 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
Ejemplo n.º 3
0
def test_parse_duration():
    assert parse_duration("0s") == timedelta()
    assert parse_duration("10s") == timedelta(seconds=10)
    assert parse_duration("10m") == timedelta(minutes=10)
    assert parse_duration("10h") == timedelta(hours=10)
    assert parse_duration("10d") == timedelta(days=10)
    assert parse_duration("1d 2h 3m 4s") == timedelta(days=1, hours=2, minutes=3, seconds=4)
Ejemplo n.º 4
0
def test_parse_duration():
    assert parse_duration("0s") == timedelta()
    assert parse_duration("10s") == timedelta(seconds=10)
    assert parse_duration("10m") == timedelta(minutes=10)
    assert parse_duration("10h") == timedelta(hours=10)
    assert parse_duration("10d") == timedelta(days=10)
    assert parse_duration("1d 2h 3m 4s") == timedelta(days=1,
                                                      hours=2,
                                                      minutes=3,
                                                      seconds=4)