From 73d7b0db08288d0576a59721f450f2bf34e336a5 Mon Sep 17 00:00:00 2001 From: ZyX Date: Sat, 11 Jan 2014 11:51:58 +0400 Subject: [PATCH] Add functional tests for plugin themes --- tests/test_configuration.py | 10 +++++++++- tests/vim.py | 17 ++++++++++++++++- 2 files changed, 25 insertions(+), 2 deletions(-) diff --git a/tests/test_configuration.py b/tests/test_configuration.py index 93857ec4..672c31b7 100644 --- a/tests/test_configuration.py +++ b/tests/test_configuration.py @@ -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: diff --git a/tests/vim.py b/tests/vim.py index 91a94886..bcc549b6 100644 --- a/tests/vim.py +++ b/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