diff --git a/.coveragerc b/.coveragerc new file mode 100644 index 0000000..69bf3e2 --- /dev/null +++ b/.coveragerc @@ -0,0 +1,5 @@ +[run] +branch = 1 + +[report] +include = pythonx/jedi_*.py,test/* diff --git a/.gitignore b/.gitignore index 77bd549..ebe3230 100644 --- a/.gitignore +++ b/.gitignore @@ -5,3 +5,4 @@ doc/tags .pytest-cache build +.coverage* diff --git a/.travis.yml b/.travis.yml index 3384f24..dbc79c5 100644 --- a/.travis.yml +++ b/.travis.yml @@ -5,7 +5,11 @@ env: matrix: - ENV=test - ENV=check - - ENV=test_nvim + - ENV=test_coverage +matrix: + include: + - env: ENV=test_coverage + python: 2.7 install: - | if [ "$ENV" = "test" ]; then @@ -13,12 +17,16 @@ install: fi - | # https://github.com/neovim/bot-ci#generated-builds - if [ "$ENV" = "test_nvim" ]; then + if [ "$ENV" = "test_coverage" ]; then eval "$(curl -Ss https://raw.githubusercontent.com/neovim/bot-ci/master/scripts/travis-setup.sh) nightly-x64" pip --version - pip install neovim + pip install neovim pytest-cov else vim --version fi script: - make --keep-going "$ENV" + +after_success: + - coverage xml + - bash <(curl -s https://codecov.io/bash) -X gcov -X coveragepy -X fix -X search -X xcode -f coverage.xml -F py${TRAVIS_PYTHON_VERSION//./} diff --git a/Makefile b/Makefile index bae7bc4..8c8fa4f 100644 --- a/Makefile +++ b/Makefile @@ -4,6 +4,9 @@ test: test_nvim: VSPEC_VIM=nvim pytest test_*.py +test_coverage: export PYTEST_ADDOPTS:=--cov pythonx --cov test --cov-report=term-missing:skip-covered +test_coverage: test_nvim + build: mkdir $@ diff --git a/conftest.py b/conftest.py index ebedc2f..32b49b3 100644 --- a/conftest.py +++ b/conftest.py @@ -1,6 +1,9 @@ import os import subprocess -import urllib.request +try: + from urllib.request import urlretrieve +except ImportError: + from urllib import urlretrieve import zipfile import pytest @@ -47,7 +50,7 @@ def pytest_configure(config): os.mkdir(CACHE_FOLDER) if not os.path.exists(VSPEC_FOLDER): - name, hdrs = urllib.request.urlretrieve(VSPEC_URL) + name, hdrs = urlretrieve(VSPEC_URL) z = zipfile.ZipFile(name) for n in z.namelist(): dest = os.path.join(CACHE_FOLDER, n) diff --git a/test/documentation.vim b/test/documentation.vim index e8d6a59..0d4172e 100644 --- a/test/documentation.vim +++ b/test/documentation.vim @@ -10,6 +10,7 @@ describe 'documentation docstrings' end it 'simple' + Expect maparg('K') == ':call jedi#show_documentation()' put = 'ImportError' normal GK Expect bufname('%') == "__doc__" diff --git a/test/vimrc b/test/vimrc new file mode 100644 index 0000000..82111f3 --- /dev/null +++ b/test/vimrc @@ -0,0 +1,8 @@ +" Minimal vimrc to use jedi-vim. +" +" Not used anywhere yet, but allows for easy testing. +let script_dir = fnamemodify(expand(''), ':h:h') +let &runtimepath = script_dir.','.&runtimepath.','.script_dir.'/after' + +syntax on +filetype plugin indent on