Beispiel #1
0
def test_delta_operators_ltgt():
    assert ChronykDelta(5) > ChronykDelta(4) and ChronykDelta(5) > 3
    assert ChronykDelta(5) < ChronykDelta(7) and ChronykDelta(5) < 9
    assert ChronykDelta(5) >= ChronykDelta(5) and ChronykDelta(5) >= 3
    assert ChronykDelta(5) <= 5 and ChronykDelta(5) <= ChronykDelta(6)
Beispiel #2
0
def test_delta_operators_eq():
    assert ChronykDelta(5) == ChronykDelta(5) and ChronykDelta(5) == 5
Beispiel #3
0
def test_delta_operators_neq():
    assert ChronykDelta(5) != ChronykDelta(6) and ChronykDelta(5) != 3
Beispiel #4
0
def test_delta_operators_str():
    assert ChronykDelta(5).timestring() == str(ChronykDelta(5))
Beispiel #5
0
def test_delta_operators_num():
    assert 5 == int(ChronykDelta(5)) and int(ChronykDelta(5)) == float(ChronykDelta(5))
Beispiel #6
0
def test_delta_operators_mul():
    assert ChronykDelta(12) * 2 == 24
Beispiel #7
0
def test_operators_add():
    timest = time.time()
    assert Chronyk(timest) + ChronykDelta(5) == Chronyk(timest + 5)
    assert Chronyk(timest) + 5 == Chronyk(timest + 5)
Beispiel #8
0
def test_delta_timestring_4():
    assert ChronykDelta("1 day and 12 hours").timestring() == "1 day and 12 hours"
Beispiel #9
0
def test_delta_timestring_5():
    assert ChronykDelta("1 day and 12 hours").timestring(maxunits=1) == "1 day"
Beispiel #10
0
def test_delta_timestring_2():
    assert ChronykDelta("1 week").timestring() == "7 days"
Beispiel #11
0
def test_delta_timestring_3():
    assert ChronykDelta("1 hour").timestring() == "1 hour"
Beispiel #12
0
def test_delta_timestring_1():
    assert ChronykDelta("5 hours").timestring() == "5 hours"
Beispiel #13
0
def test_delta_type():
    with pytest.raises(TypeError):
        ChronykDelta(["WEEE", "EEEEE", "EEEEEE"])
Beispiel #14
0
def test_operators_sub():
    timest = time.time()
    assert Chronyk(timest) - Chronyk(timest - 5) == ChronykDelta(5)
    assert Chronyk(timest) - ChronykDelta(5) == Chronyk(timest - 5)
    assert Chronyk(timest, timezone=0) - 5 == timest - 5
Beispiel #15
0
def test_delta_operators_add():
    timest = time.time()
    assert ChronykDelta(5) + ChronykDelta(-5) == 0
    assert ChronykDelta(5) + Chronyk(timest) == Chronyk(timest + 5)
    assert ChronykDelta(5) + 10 == 15
Beispiel #16
0
def test_delta_timestring_6():
    with pytest.raises(ValueError):
        ChronykDelta("1 day ago").timestring(maxunits=0)
Beispiel #17
0
def test_delta_operators_sub():
    assert ChronykDelta(5) - 5 == 0
    assert ChronykDelta(5) - ChronykDelta(1) == 4
Beispiel #18
0
def test_delta_timestring_7():
    assert ChronykDelta(0).timestring() == ""
Beispiel #19
0
def test_delta_operators_div():
    assert ChronykDelta(10) / 2 == 5
Beispiel #20
0
def test_guesstype():
    assert guesstype(9001) == Chronyk(9001)
    assert guesstype("2 hours ago").relativestring() == Chronyk("2 hours ago").relativestring()
    assert guesstype("2 hours") == ChronykDelta("2 hours")