Esempio n. 1
0
def test_debounce_max_wait():
    def func(): return _.now()

    wait = 250
    max_wait = 300
    debounced = _.debounce(func, wait, max_wait=max_wait)

    start = _.now()
    present = _.now()

    expected = debounced()

    while (present - start) <= (max_wait + 5):
        result = debounced()
        present = _.now()

    assert result > expected
Esempio n. 2
0
def test_debounce():
    def func(): return _.now()

    wait = 250
    debounced = _.debounce(func, wait)

    start = _.now()
    present = _.now()

    expected = debounced()

    while (present - start) <= wait + 100:
        result = debounced()
        present = _.now()

    assert result == expected

    time.sleep(wait / 1000.0)
    result = debounced()

    assert result > expected