for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
from threading import Timer
def test_interrupt_from_another_thread(vim):
timer = Timer(0.5, lambda: vim.async_call(lambda: vim.stop_loop()))
timer.start()
assert vim.next_message() is None
def test_exception_in_threadsafe_call(vim):
# an exception in a threadsafe_call shouldn't crash the entire host
msgs = []
vim.async_call(lambda: [vim.eval("3"), undefined_variable]) # noqa: F821
undefined_variable
vim.run_loop(None, None, err_cb=msgs.append)
assert len(msgs) == 1
msgs[0].index('NameError')
msgs[0].index('undefined_variable')