コード例 #1
0
def test_command():
    a = App()

    callback_event = Event()

    def callback():
        callback_event.set()

    c = Combo(a, ["foo", "bar"], command=callback)
    assert not callback_event.is_set()
    # you cant invoke a tk optionmenu - this is better than no tests!
    c._command_callback(c.value)
    assert callback_event.is_set()

    a.destroy()
コード例 #2
0
def test_command_with_parameter():
    a = App()

    callback_event = Event()

    def callback(value):
        assert value == "foo"
        callback_event.set()

    c = Combo(a, ["foo", "bar"], command=callback)
    assert not callback_event.is_set()

    c._command_callback(c.value)
    assert callback_event.is_set()

    a.destroy()
コード例 #3
0
def test_update_command():
    a = App()

    callback_event = Event()

    def callback():
        callback_event.set()

    c = Combo(a, ["foo", "bar"])

    c._command_callback(c.value)
    assert not callback_event.is_set()

    c.update_command(callback)
    c._command_callback(c.value)
    assert callback_event.is_set()
    callback_event.clear()

    c.update_command(None)
    c._command_callback(c.value)
    assert not callback_event.is_set()

    a.destroy()