Skip to content

Commit

Permalink
Fix tests for Jedi 0.15.2 (#723)
Browse files Browse the repository at this point in the history
  • Loading branch information
ccordoba12 authored Dec 24, 2019
1 parent 48eedea commit b862add
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 11 deletions.
2 changes: 1 addition & 1 deletion appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ install:
- "%PYTHON%/python.exe -m pip install .[all] .[test]"

test_script:
- "%PYTHON%/Scripts/pytest.exe test/"
- "%PYTHON%/Scripts/pytest.exe -v test/"

# on_finish:
# - ps: $blockRdp = $true; iex ((new-object net.webclient).DownloadString('https://raw.githubusercontent.com/appveyor/ci/master/scripts/enable-rdp.ps1'))
Expand Down
27 changes: 17 additions & 10 deletions test/plugins/test_completion.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@
import sys

from test.test_utils import MockWorkspace
import jedi
import pytest

from pyls import uris, lsp
from pyls._utils import JEDI_VERSION
from pyls.workspace import Document
from pyls.plugins.jedi_completion import pyls_completions as pyls_jedi_completions
from pyls.plugins.rope_completion import pyls_completions as pyls_rope_completions
Expand Down Expand Up @@ -124,20 +124,25 @@ def test_jedi_method_completion(config):
assert everyone_method['insertText'] == 'everyone'


@pytest.mark.skipif(PY2 or LooseVersion(jedi.__version__) >= LooseVersion('0.16.0'),
reason='Test only with Jedi <0.16 in Python 3. Check for a fix in future Jedi versions')
@pytest.mark.skipif(PY2 or (sys.platform.startswith('linux') and os.environ.get('CI') is not None),
reason="Test in Python 3 and not on CIs on Linux because wheels don't work on them.")
def test_pyqt_completion(config):
# Over 'QA' in 'from PyQt5.QtWidgets import QApplication'
doc_pyqt = "from PyQt5.QtWidgets import QA"
com_position = {'line': 0, 'character': len(doc_pyqt)}
doc = Document(DOC_URI, doc_pyqt)
completions = pyls_jedi_completions(config, doc, com_position)

# Test we don't throw importing elements from PyQt5
assert pyls_jedi_completions(config, doc, com_position) is None
# Test we don't throw an error for Jedi < 0.15.2 and get completions
# for Jedi 0.15.2+
if LooseVersion(JEDI_VERSION) < LooseVersion('0.15.2'):
assert completions is None
else:
assert completions is not None


@pytest.mark.skipif(LooseVersion('0.15.0') <= LooseVersion(jedi.__version__) < LooseVersion('0.16.0'),
reason='This test fails with Jedi 0.15')
@pytest.mark.skipif(LooseVersion('0.15.0') <= LooseVersion(JEDI_VERSION) < LooseVersion('0.15.2'),
reason='This test fails with Jedi 0.15.0 and 0.15.1')
def test_numpy_completions(config):
doc_numpy = "import numpy as np; np."
com_position = {'line': 0, 'character': len(doc_numpy)}
Expand All @@ -148,8 +153,8 @@ def test_numpy_completions(config):
assert any(['array' in i['label'] for i in items])


@pytest.mark.skipif(LooseVersion('0.15.0') <= LooseVersion(jedi.__version__) < LooseVersion('0.16.0'),
reason='This test fails with Jedi 0.15')
@pytest.mark.skipif(LooseVersion('0.15.0') <= LooseVersion(JEDI_VERSION) < LooseVersion('0.15.2'),
reason='This test fails with Jedi 0.15.0 and 0.15.1')
def test_pandas_completions(config):
doc_pandas = "import pandas as pd; pd."
com_position = {'line': 0, 'character': len(doc_pandas)}
Expand All @@ -170,6 +175,8 @@ def test_matplotlib_completions(config):
assert any(['plot' in i['label'] for i in items])


@pytest.mark.skipif(LooseVersion(JEDI_VERSION) < LooseVersion('0.15.2'),
reason='This test fails with Jedi 0.15.1 or less')
def test_snippets_completion(config):
doc_snippets = 'from collections import defaultdict \na=defaultdict'
com_position = {'line': 0, 'character': 35}
Expand All @@ -182,7 +189,7 @@ def test_snippets_completion(config):

com_position = {'line': 1, 'character': len(doc_snippets)}
completions = pyls_jedi_completions(config, doc, com_position)
out = 'defaultdict(${1:default_factory}, ${2:iterable}, ${3:kwargs})$0'
out = 'defaultdict(${1:kwargs})$0'
assert completions[0]['insertText'] == out


Expand Down

0 comments on commit b862add

Please sign in to comment.