From 03fe14a9dc5e9d6508d8810a47e376ded126d456 Mon Sep 17 00:00:00 2001 From: maralla Date: Sun, 18 Aug 2024 10:14:08 +0000 Subject: [PATCH 1/4] Change ci runner to ubuntu-22.04 --- .github/workflows/test.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index d69d847..4a37d30 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -4,7 +4,7 @@ on: [push, pull_request] jobs: build: - runs-on: ubuntu-18.04 + runs-on: ubuntu-20.04 strategy: matrix: python-version: ['2.7', '3.5', '3.6', '3.7', '3.8'] From 389d8d302356ef30b0daa9aba53d4792c80a9ed3 Mon Sep 17 00:00:00 2001 From: maralla Date: Sun, 18 Aug 2024 10:28:09 +0000 Subject: [PATCH 2/4] Use container for old python build --- .github/workflows/test.yml | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 4a37d30..f319686 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -4,10 +4,10 @@ on: [push, pull_request] jobs: build: - runs-on: ubuntu-20.04 + runs-on: ubuntu-22.04 strategy: matrix: - python-version: ['2.7', '3.5', '3.6', '3.7', '3.8'] + python-version: ['3.7', '3.8', '3.9', '3.10', '3.11', '3.12'] name: ${{ matrix.python-version }} steps: - uses: actions/checkout@master @@ -19,3 +19,13 @@ jobs: run: pip install 'pytest>=3.0.3' mock requests jedi - name: Run tests run: py.test + + legacy: + runs-on: ubuntu-22.04 + container: python:2.7 + steps: + - uses: actions/checkout@master + - name: Install dependencies + run: pip install 'pytest>=3.0.3' mock requests jedi + - name: Run tests + run: py.test From 8b60afa549cea2dba03982629390b11663e51a3f Mon Sep 17 00:00:00 2001 From: maralla Date: Sun, 18 Aug 2024 10:58:54 +0000 Subject: [PATCH 3/4] Fixed tests --- tests/conftest.py | 4 ++-- tests/test_cpp.py | 2 ++ tests/test_filename.py | 2 ++ tests/test_rust.py | 5 ++++- 4 files changed, 10 insertions(+), 3 deletions(-) diff --git a/tests/conftest.py b/tests/conftest.py index 9a5615c..b61fb72 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -42,13 +42,13 @@ def reset(self): self._vars = {} self.var_map = {} self.eval_map = {'&encoding': b'utf-8'} - self.current = mock.Mock() + self.current = mock.MagicMock() self.current.buffer.options = {'fileencoding': b'utf-8'} self.funcs = { 'getbufvar': lambda nr, var: b'', 'completor#utils#in_comment_or_string': lambda: 0, 'completor#support_popup': lambda: 0, - 'expand': lambda x: x, + 'expand': lambda x: self.current.buffer.name, 'completor#utils#tempname': lambda: '/tmp/xxx-vim', } diff --git a/tests/test_cpp.py b/tests/test_cpp.py index d7112f2..6d376b1 100644 --- a/tests/test_cpp.py +++ b/tests/test_cpp.py @@ -15,6 +15,8 @@ def test_parse(vim_mod): b'COMPLETION: Pattern: fake hello', ] + vim_mod.current.window.cursor = (1, 5) + cpp = completor.get('cpp') cpp.input_data = to_unicode('b->', 'utf-8') assert cpp.on_data(b'complete', items) == [ diff --git a/tests/test_filename.py b/tests/test_filename.py index 3b5f5be..48d83d2 100644 --- a/tests/test_filename.py +++ b/tests/test_filename.py @@ -9,6 +9,8 @@ def test_on_data(vim_mod): filename = completor.get('filename') + vim_mod.current.window.cursor = (1, 5) + vim_mod.vars = {} vim_mod.funcs['expand'] = lambda _: os.path.join(os.getcwd(), 'tests') data = list(set([item['menu'] diff --git a/tests/test_rust.py b/tests/test_rust.py index 613fbf1..c51a1f3 100644 --- a/tests/test_rust.py +++ b/tests/test_rust.py @@ -7,12 +7,15 @@ from completers.rust import Racer # noqa -def test_parse(): +def test_parse(vim_mod): items = [ b'MATCH FrameHandler,155,7,./src/event.rs,Struct,struct FrameHandler', b'MATCH tcp_port,1075,4,./src/event.rs,StructField,Option', b'MATCH run,1092,11,./src/event.rs,Function,pub fn run(&mut self)' ] + + vim_mod.current.window.cursor = (1, 2) + racer = completor.get('rust') racer.input_data = to_unicode('self.', 'utf-8') assert racer.on_data(b'complete', items) == [ From 0758cfe57ec66fe70f685673e4d29ceb58146d97 Mon Sep 17 00:00:00 2001 From: maralla Date: Sun, 18 Aug 2024 11:29:21 +0000 Subject: [PATCH 4/4] Compat for py2 --- pythonx/completers/go.py | 6 ++++-- tests/test_go.py | 5 +++-- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/pythonx/completers/go.py b/pythonx/completers/go.py index 9ffb4c6..a51c732 100644 --- a/pythonx/completers/go.py +++ b/pythonx/completers/go.py @@ -25,8 +25,10 @@ def _gen_archive(self): if not vim.current.buffer.options['modified']: return '' content = '\n'.join(vim.current.buffer[:]) - n = len(to_bytes(content, get_encoding())) - return '\n'.join([self.filename, str(n), content]) + encoding = get_encoding() + n = len(to_bytes(content, encoding)) + return '\n'.join([ + self.filename, str(n), to_unicode(content, encoding)]) def _complete_cmd(self): binary = self.get_option('gocode_binary') or 'gocode' diff --git a/tests/test_go.py b/tests/test_go.py index e630c60..5d9f3d5 100644 --- a/tests/test_go.py +++ b/tests/test_go.py @@ -4,6 +4,7 @@ import pytest import completor from completers.go import Go # noqa +from completor.compat import to_unicode class TestGetCmdInfo(object): @@ -24,8 +25,8 @@ class TestGetCmdInfo(object): '/home/vagrant/bench.vim:#24'], 'ftype': 'go', 'is_daemon': False, - 'input_content': ('/home/vagrant/bench.vim\n26\n' - 'package main\nvar _ = "哦"') + 'input_content': ('/home/vagrant/bench.vim\n26\n' + + to_unicode('package main\nvar _ = "哦"', 'utf-8')) } }