Skip to content

Commit

Permalink
Merge pull request #324 from maralla/fix-ci
Browse files Browse the repository at this point in the history
Fix ci
  • Loading branch information
maralla committed Aug 18, 2024
2 parents c195f4e + 0758cfe commit 5cf8a49
Show file tree
Hide file tree
Showing 7 changed files with 29 additions and 9 deletions.
14 changes: 12 additions & 2 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@ on: [push, pull_request]

jobs:
build:
runs-on: ubuntu-18.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
Expand All @@ -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
6 changes: 4 additions & 2 deletions pythonx/completers/go.py
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down
4 changes: 2 additions & 2 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -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',
}

Expand Down
2 changes: 2 additions & 0 deletions tests/test_cpp.py
Original file line number Diff line number Diff line change
Expand Up @@ -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) == [
Expand Down
2 changes: 2 additions & 0 deletions tests/test_filename.py
Original file line number Diff line number Diff line change
Expand Up @@ -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']
Expand Down
5 changes: 3 additions & 2 deletions tests/test_go.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import pytest
import completor
from completers.go import Go # noqa
from completor.compat import to_unicode


class TestGetCmdInfo(object):
Expand All @@ -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'))
}
}

Expand Down
5 changes: 4 additions & 1 deletion tests/test_rust.py
Original file line number Diff line number Diff line change
Expand Up @@ -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<u16>',
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) == [
Expand Down

0 comments on commit 5cf8a49

Please sign in to comment.