diff --git a/test/test_Autotrigger.py b/test/test_Autotrigger.py index 86a1e2b..bbac8b4 100644 --- a/test/test_Autotrigger.py +++ b/test/test_Autotrigger.py @@ -1,23 +1,10 @@ from test.vim_test_case import VimTestCase as _VimTest from test.constant import * -import subprocess - - -def has_patch(version, executable): - output = subprocess.check_output([executable, "--version"]) - patch = 1 - for line in output.decode('utf-8').split("\n"): - if line.startswith("Included patches:"): - patch = line.split('-')[1] - - return int(patch) >= version - - def check_required_vim_version(test): if test.vim_flavor == 'neovim': return None - if not has_patch(214, test.vim._vim_executable): + if not test.vim.has_patch(214): return 'Vim newer than 7.4.214 is required' else: return None @@ -58,7 +45,7 @@ class Autotrigger_CanExpandOnTriggerWithLengthMoreThanOne(_VimTest): class Autotrigger_WillProduceNoExceptionWithVimLowerThan214(_VimTest): skip_if = lambda self: 'Vim older than 7.4.214 is required' \ - if has_patch(214, self.vim._vim_executable) else None + if self.vim.has_patch(214) else None files = { 'us/all.snippets': r""" snippet abc "desc" A diff --git a/test/test_Editing.py b/test/test_Editing.py index c023a68..e200f0b 100644 --- a/test/test_Editing.py +++ b/test/test_Editing.py @@ -1,6 +1,16 @@ from test.vim_test_case import VimTestCase as _VimTest from test.constant import * + +def check_required_vim_version(test): + if test.vim_flavor == 'neovim': + return None + if not test.vim.has_patch(1): + return 'Vim newer than 7.4.1 is required' + else: + return None + + # Undo of Snippet insertion {{{# @@ -122,11 +132,13 @@ class Backspace_TabStop_NotZero(_VimTest): # End: Pressing BS in TabStop #}}} class UpdateModifiedSnippetWithoutCursorMove(_VimTest): + skip_if = check_required_vim_version snippets = ('test', '${1:one}(${2:xxx})${3:three}') keys = 'test' + EX + 'aaaaa' + JF + BS + JF + '3333' wanted = 'aaaaa()3333' class UpdateModifiedSnippetWithoutCursorMove2(_VimTest): + skip_if = check_required_vim_version snippets = ('test', '''\ private function ${1:functionName}(${2:arguments}):${3:Void} { diff --git a/test/vim_interface.py b/test/vim_interface.py index cff69ff..3c3c35a 100644 --- a/test/vim_interface.py +++ b/test/vim_interface.py @@ -91,6 +91,20 @@ class VimInterface(TempFileManager): def __init__(self, vim_executable, name): TempFileManager.__init__(self, name) self._vim_executable = vim_executable + self._patch_version = None + + def has_patch(self, version): + if self._patch_version is None: + output = subprocess.check_output([ + self._vim_executable, "--version" + ]) + + self._patch_version = 0 + for line in output.decode('utf-8').split("\n"): + if line.startswith("Included patches:"): + self._patch_version = line.split('-')[1] + + return int(self._patch_version) >= version def get_buffer_data(self): buffer_path = self.unique_name_temp(prefix='buffer_')