-
Notifications
You must be signed in to change notification settings - Fork 124
/
Copy pathtest_host.py
37 lines (30 loc) · 1.2 KB
/
test_host.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
# -*- coding: utf-8 -*-
from pynvim.plugin.host import Host, host_method_spec
from pynvim.plugin.script_host import ScriptHost
def test_host_imports(vim):
h = ScriptHost(vim)
assert h.module.__dict__['vim']
assert h.module.__dict__['vim'] == h.legacy_vim
assert h.module.__dict__['sys']
def test_host_clientinfo(vim):
h = Host(vim)
assert h._request_handlers.keys() == host_method_spec.keys()
assert 'remote' == vim.api.get_chan_info(vim.channel_id)['client']['type']
h._load([])
assert 'host' == vim.api.get_chan_info(vim.channel_id)['client']['type']
# Smoke test for Host._on_error_event(). #425
def test_host_async_error(vim):
h = Host(vim)
h._load([])
# Invoke a bogus Ex command via notify (async).
vim.command("lolwut", async_=True)
event = vim.next_message()
assert event[1] == 'nvim_error_event'
assert 'rplugin-host: Async request caused an error:\nboom\n' \
in h._on_error_event(None, 'boom')
def test_legacy_vim_eval(vim):
h = ScriptHost(vim)
assert h.legacy_vim.eval('1') == '1'
assert h.legacy_vim.eval('v:null') == None
assert h.legacy_vim.eval('v:true') == True
assert h.legacy_vim.eval('v:false') == False