コード例 #1
0
def test_intvar_update():
    f = Frame()
    intv = IntVar(f, 1.)

    def dx(f):
        return 1.

    intv.updater = dx
    assert intv.update() == None
    assert intv == 1.
コード例 #2
0
def test_intvar_snapshots():
    f = Frame()
    intv = IntVar(f, 2.1)
    with pytest.raises(ValueError):
        intv.snapshots = [2., 1.]
    with pytest.raises(ValueError):
        intv.snapshots = [1., 1.]

    def dx(x):
        return 1.

    intv.updater = dx
    intv.snapshots = []
    with pytest.raises(ValueError):
        intv.nextsnapshot
    with pytest.raises(ValueError):
        intv.prevsnapshot
    intv.snapshots = [1., 2., 3.]
    assert intv.nextsnapshot == 3.
    assert intv.prevsnapshot == 2.