示例#1
0
def test_time_left():
    """test '_time_left' routine returns correct positive delta difference."""
    from blessed.keyboard import _time_left

    # given stime =~ "10 seconds ago"
    stime = (time.time() - 10)

    # timeleft(now, 15s) = 5s remaining
    timeout = 15
    result = _time_left(stime=stime, timeout=timeout)

    # we expect roughly 4.999s remain
    assert math.ceil(result) == 5.0
示例#2
0
def test_time_left():
    """test '_time_left' routine returns correct positive delta difference."""
    from blessed.keyboard import _time_left

    # given stime =~ "10 seconds ago"
    stime = (time.time() - 10)

    # timeleft(now, 15s) = 5s remaining
    timeout = 15
    result = _time_left(stime=stime, timeout=timeout)

    # we expect roughly 4.999s remain
    assert math.ceil(result) == 5.0
示例#3
0
def test_time_left_infinite_None():
    """keyboard '_time_left' routine returns None when given None."""
    from blessed.keyboard import _time_left
    assert _time_left(stime=time.time(), timeout=None) is None
示例#4
0
def test_time_left_infinite_None():
    """keyboard '_time_left' routine returns None when given None."""
    from blessed.keyboard import _time_left
    assert _time_left(stime=time.time(), timeout=None) is None