def test_calling_uptime_timeout_with_short_timeout(buffer_connection): uptime_cmd = Uptime(connection=buffer_connection.moler_connection) short_timeout = 7 uptime_cmd.terminating_timeout = 0.2 uptime_cmd.start(timeout=short_timeout) start_time = time.time() with pytest.raises(CommandTimeout): uptime_cmd.await_done() end_time = time.time() duration = end_time - start_time assert duration < short_timeout + 1 assert duration >= short_timeout
def test_calling_uptime_timeout_with_long_timeout(buffer_connection): uptime_cmd = Uptime(connection=buffer_connection.moler_connection) long_timeout = 300 uptime_cmd.terminating_timeout = 0.2 uptime_cmd.start(timeout=long_timeout) uptime_cmd.timeout = long_timeout start_time = time.time() with pytest.raises(CommandTimeout): uptime_cmd.await_done(timeout=1) end_time = time.time() duration = end_time - start_time assert duration < long_timeout/10