Add functional tests for plugin themes
This commit is contained in:
parent
e8b2054868
commit
73d7b0db08
|
@ -23,11 +23,15 @@ class TestConfig(TestCase):
|
|||
(('bufoptions',), {'buftype': 'help'}),
|
||||
(('bufname', '[Command Line]'), {}),
|
||||
(('bufoptions',), {'buftype': 'quickfix'}),
|
||||
(('bufname', 'NERD_tree_1'), {}),
|
||||
(('bufname', '__Gundo__'), {}),
|
||||
(('bufname', '__Gundo_Preview__'), {}),
|
||||
(('bufname', 'ControlP'), {}),
|
||||
)
|
||||
with open(os.path.join(cfg_path, 'config.json'), 'r') as f:
|
||||
local_themes_raw = json.load(f)['ext']['vim']['local_themes']
|
||||
# Don't run tests on external/plugin segments
|
||||
local_themes = dict((k, v) for (k, v) in local_themes_raw.items() if not '.' in k)
|
||||
local_themes = dict((k, v) for (k, v) in local_themes_raw.items())
|
||||
self.assertEqual(len(buffers), len(local_themes))
|
||||
outputs = {}
|
||||
i = 0
|
||||
|
@ -58,6 +62,10 @@ class TestConfig(TestCase):
|
|||
i += 1
|
||||
if mode in exclude:
|
||||
continue
|
||||
if mode == 'nc' and args == ('bufname', 'ControlP'):
|
||||
# ControlP window is not supposed to not
|
||||
# be in the focus
|
||||
continue
|
||||
with vim_module._with(*args, **kwargs):
|
||||
check_output(mode, args, kwargs)
|
||||
finally:
|
||||
|
|
17
tests/vim.py
17
tests/vim.py
|
@ -171,9 +171,13 @@ def eval(expr):
|
|||
return options[expr[1:]]
|
||||
elif expr.startswith('PowerlineRegisterCachePurgerEvent'):
|
||||
_buf_purge_events.add(expr[expr.find('"') + 1:expr.rfind('"') - 1])
|
||||
return "0"
|
||||
return '0'
|
||||
elif expr.startswith('exists('):
|
||||
return '0'
|
||||
elif expr == 'getbufvar("%", "NERDTreeRoot").path.str()':
|
||||
import os
|
||||
assert os.path.basename(buffers[_buffer()].name).startswith('NERD_tree_')
|
||||
return '/usr/include'
|
||||
raise NotImplementedError
|
||||
|
||||
|
||||
|
@ -205,6 +209,7 @@ def _emul_mode(*args):
|
|||
@_vim
|
||||
@_str_func
|
||||
def _emul_getbufvar(bufnr, varname):
|
||||
import re
|
||||
if varname[0] == '&':
|
||||
if bufnr == '%':
|
||||
bufnr = buffers[_buffer()].number
|
||||
|
@ -217,6 +222,12 @@ def _emul_getbufvar(bufnr, varname):
|
|||
return options[varname[1:]]
|
||||
except KeyError:
|
||||
return ''
|
||||
elif re.match('^[a-zA-Z_]+$', varname):
|
||||
if bufnr == '%':
|
||||
bufnr = buffers[_buffer()].number
|
||||
if bufnr not in buffers:
|
||||
return ''
|
||||
return buffers[bufnr].vars[varname]
|
||||
raise NotImplementedError
|
||||
|
||||
|
||||
|
@ -625,10 +636,14 @@ class _WithBufName(object):
|
|||
self.new = new
|
||||
|
||||
def __enter__(self):
|
||||
import os
|
||||
buffer = buffers[_buffer()]
|
||||
self.buffer = buffer
|
||||
self.old = buffer.name
|
||||
buffer.name = self.new
|
||||
if buffer.name and os.path.basename(buffer.name) == 'ControlP':
|
||||
buffer.vars['powerline_ctrlp_type'] = 'main'
|
||||
buffer.vars['powerline_ctrlp_args'] = ['focus', 'byfname', '0', 'prev', 'item', 'next', 'marked']
|
||||
|
||||
def __exit__(self, *args):
|
||||
self.buffer.name = self.old
|
||||
|
|
Loading…
Reference in New Issue