def test_vim(self): from powerline.vim import VimPowerline cfg_path = os.path.join(os.path.dirname(os.path.dirname(__file__)), 'powerline', 'config_files') buffers = ( (('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()) self.assertEqual(len(buffers), len(local_themes) - 1) outputs = {} i = 0 with vim_module._with('split'): with VimPowerline() as powerline: def check_output(mode, args, kwargs): if mode == 'nc': window = vim_module.windows[0] window_id = 2 else: vim_module._start_mode(mode) window = vim_module.current.window window_id = 1 winnr = window.number out = powerline.render(window, window_id, winnr) if out in outputs: self.fail('Duplicate in set #{0} ({1}) for mode {2!r} (previously defined in set #{3} ({4!r}) for mode {5!r})'.format(i, (args, kwargs), mode, *outputs[out])) outputs[out] = (i, (args, kwargs), mode) with vim_module._with('bufname', '/tmp/foo.txt'): out = powerline.render(vim_module.current.window, 1, vim_module.current.window.number, is_tabline=True) outputs[out] = (-1, (None, None), 'tab') with vim_module._with('globals', powerline_config_paths=[cfg_path]): exclude = set(('no', 'v', 'V', VBLOCK, 's', 'S', SBLOCK, 'R', 'Rv', 'c', 'cv', 'ce', 'r', 'rm', 'r?', '!')) try: for mode in ['n', 'nc', 'no', 'v', 'V', VBLOCK, 's', 'S', SBLOCK, 'i', 'R', 'Rv', 'c', 'cv', 'ce', 'r', 'rm', 'r?', '!']: check_output(mode, None, None) for args, kwargs in buffers: 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: vim_module._start_mode('n')
def test_vim(self): from powerline.vim import VimPowerline cfg_path = os.path.join(os.path.dirname(os.path.dirname(__file__)), 'powerline', 'config_files') buffers = ((('bufoptions', ), { 'buftype': 'help' }), (('bufname', '[Command Line]'), {}), (('bufoptions', ), { 'buftype': 'quickfix' })) with open(os.path.join(cfg_path, 'config.json'), 'r') as f: self.assertEqual(len(buffers), len(json.load(f)['ext']['vim']['local_themes'])) outputs = {} i = 0 with vim_module._with('split'): with VimPowerline() as powerline: def check_output(mode, args, kwargs): if mode == 'nc': window = vim_module.windows[0] window_id = 2 else: vim_module._start_mode(mode) window = vim_module.current.window window_id = 1 winnr = window.number out = powerline.render(window, window_id, winnr) if out in outputs: self.fail( 'Duplicate in set #{0} ({1}) for mode {2!r} (previously defined in set #{3} ({4!r}) for mode {5!r})' .format(i, (args, kwargs), mode, *outputs[out])) outputs[out] = (i, (args, kwargs), mode) with vim_module._with('bufname', '/tmp/foo.txt'): with vim_module._with('globals', powerline_config_path=cfg_path): exclude = set( ('no', 'v', 'V', VBLOCK, 's', 'S', SBLOCK, 'R', 'Rv', 'c', 'cv', 'ce', 'r', 'rm', 'r?', '!')) try: for mode in [ 'n', 'nc', 'no', 'v', 'V', VBLOCK, 's', 'S', SBLOCK, 'i', 'R', 'Rv', 'c', 'cv', 'ce', 'r', 'rm', 'r?', '!' ]: check_output(mode, None, None) for args, kwargs in buffers: i += 1 if mode in exclude: continue with vim_module._with(*args, **kwargs): check_output(mode, args, kwargs) finally: vim_module._start_mode('n')
def test_vim(self): from powerline.vim import VimPowerline cfg_path = os.path.join(os.path.dirname(os.path.dirname(__file__)), 'powerline', 'config_files') buffers = ((('bufoptions', ), { 'buftype': 'help' }), (('buffer', '[Command Line]'), {}), (('bufoptions', ), { 'buftype': 'quickfix' })) with open(os.path.join(cfg_path, 'config.json'), 'r') as f: self.assertEqual(len(buffers), len(json.load(f)['ext']['vim']['local_themes'])) outputs = {} i = 0 mode = None with VimPowerline() as powerline: def check_output(*args): out = powerline.render(*args + (0 if mode == 'nc' else 1, )) if out in outputs: self.fail( 'Duplicate in set #{0} for mode {1!r} (previously defined in set #{2} for mode {3!r})' .format(i, mode, *outputs[out])) outputs[out] = (i, mode) with vim_module._with('buffer', 'foo.txt'): with vim_module._with('globals', powerline_config_path=cfg_path): exclude = set( ('no', 'v', 'V', VBLOCK, 's', 'S', SBLOCK, 'R', 'Rv', 'c', 'cv', 'ce', 'r', 'rm', 'r?', '!')) try: for mode in [ 'n', 'nc', 'no', 'v', 'V', VBLOCK, 's', 'S', SBLOCK, 'i', 'R', 'Rv', 'c', 'cv', 'ce', 'r', 'rm', 'r?', '!' ]: if mode != 'nc': vim_module._start_mode(mode) check_output(1, 0) for args, kwargs in buffers: i += 1 if mode in exclude: continue with vim_module._with(*args, **kwargs): check_output(1, 0) finally: vim_module._start_mode('n')