示例#1
0
def test_init_bad_vals():
    with pytest.raises(ValueError):
        ct.WeekTime(10, 3, 15)
    with pytest.raises(ValueError):
        ct.WeekTime(1, 24, 15)
    with pytest.raises(ValueError):
        ct.WeekTime(1, 3, 60)
示例#2
0
def test_order():
    d1 = ct.DayTime(3, 0)
    d2 = ct.DayTime(3, 15)
    assert d1 < d2

    d1 = ct.DayTime(1, 15)
    d2 = ct.DayTime(2, 15)
    assert d1 < d2

    w1 = ct.WeekTime(1, 3, 15)
    w2 = ct.WeekTime(2, 3, 15)
    assert w1 < w2
示例#3
0
def test_as_tod_string():
    d = ct.DayTime(18, 30)
    assert '18:30' == d.as_tod_string()

    d = ct.DayTime(3, 5)
    assert '03:05' == d.as_tod_string()

    w = ct.WeekTime(3, 18, 30)
    assert '18:30' == w.as_tod_string()
示例#4
0
def test_repr():
    d = ct.DayTime(18, 29)
    assert d == eval('ct.' + d.__repr__())

    w = ct.WeekTime(2, 18, 29)
    assert w == eval('ct.' + w.__repr__())
示例#5
0
def test_weektime_init():
    w = ct.WeekTime(3, 18, 30)
    assert 3 == w.day
    assert 18 == w.hour
    assert 30 == w.minute