4
4
import sys
5
5
6
6
from test .test_utils import MockWorkspace
7
- import jedi
8
7
import pytest
9
8
10
9
from pyls import uris , lsp
10
+ from pyls ._utils import JEDI_VERSION
11
11
from pyls .workspace import Document
12
12
from pyls .plugins .jedi_completion import pyls_completions as pyls_jedi_completions
13
13
from pyls .plugins .rope_completion import pyls_completions as pyls_rope_completions
@@ -124,20 +124,25 @@ def test_jedi_method_completion(config):
124
124
assert everyone_method ['insertText' ] == 'everyone'
125
125
126
126
127
- @pytest .mark .skipif (PY2 or LooseVersion ( jedi . __version__ ) >= LooseVersion ( '0.16.0' ),
128
- reason = ' Test only with Jedi <0.16 in Python 3. Check for a fix in future Jedi versions' )
127
+ @pytest .mark .skipif (PY2 or ( sys . platform . startswith ( 'linux' ) and os . environ . get ( 'CI' ) is not None ),
128
+ reason = " Test in Python 3 and not on CIs on Linux because wheels don't work on them." )
129
129
def test_pyqt_completion (config ):
130
130
# Over 'QA' in 'from PyQt5.QtWidgets import QApplication'
131
131
doc_pyqt = "from PyQt5.QtWidgets import QA"
132
132
com_position = {'line' : 0 , 'character' : len (doc_pyqt )}
133
133
doc = Document (DOC_URI , doc_pyqt )
134
+ completions = pyls_jedi_completions (config , doc , com_position )
134
135
135
- # Test we don't throw importing elements from PyQt5
136
- assert pyls_jedi_completions (config , doc , com_position ) is None
136
+ # Test we don't throw an error for Jedi < 0.15.2 and get completions
137
+ # for Jedi 0.15.2+
138
+ if LooseVersion (JEDI_VERSION ) < LooseVersion ('0.15.2' ):
139
+ assert completions is None
140
+ else :
141
+ assert completions is not None
137
142
138
143
139
- @pytest .mark .skipif (LooseVersion ('0.15.0' ) <= LooseVersion (jedi . __version__ ) < LooseVersion ('0.16.0 ' ),
140
- reason = 'This test fails with Jedi 0.15' )
144
+ @pytest .mark .skipif (LooseVersion ('0.15.0' ) <= LooseVersion (JEDI_VERSION ) < LooseVersion ('0.15.2 ' ),
145
+ reason = 'This test fails with Jedi 0.15.0 and 0.15.1 ' )
141
146
def test_numpy_completions (config ):
142
147
doc_numpy = "import numpy as np; np."
143
148
com_position = {'line' : 0 , 'character' : len (doc_numpy )}
@@ -148,8 +153,8 @@ def test_numpy_completions(config):
148
153
assert any (['array' in i ['label' ] for i in items ])
149
154
150
155
151
- @pytest .mark .skipif (LooseVersion ('0.15.0' ) <= LooseVersion (jedi . __version__ ) < LooseVersion ('0.16.0 ' ),
152
- reason = 'This test fails with Jedi 0.15' )
156
+ @pytest .mark .skipif (LooseVersion ('0.15.0' ) <= LooseVersion (JEDI_VERSION ) < LooseVersion ('0.15.2 ' ),
157
+ reason = 'This test fails with Jedi 0.15.0 and 0.15.1 ' )
153
158
def test_pandas_completions (config ):
154
159
doc_pandas = "import pandas as pd; pd."
155
160
com_position = {'line' : 0 , 'character' : len (doc_pandas )}
@@ -170,6 +175,8 @@ def test_matplotlib_completions(config):
170
175
assert any (['plot' in i ['label' ] for i in items ])
171
176
172
177
178
+ @pytest .mark .skipif (LooseVersion (JEDI_VERSION ) < LooseVersion ('0.15.2' ),
179
+ reason = 'This test fails with Jedi 0.15.1 or less' )
173
180
def test_snippets_completion (config ):
174
181
doc_snippets = 'from collections import defaultdict \n a=defaultdict'
175
182
com_position = {'line' : 0 , 'character' : 35 }
@@ -182,7 +189,7 @@ def test_snippets_completion(config):
182
189
183
190
com_position = {'line' : 1 , 'character' : len (doc_snippets )}
184
191
completions = pyls_jedi_completions (config , doc , com_position )
185
- out = 'defaultdict(${1:default_factory}, ${2:iterable}, ${3: kwargs})$0'
192
+ out = 'defaultdict(${1:kwargs})$0'
186
193
assert completions [0 ]['insertText' ] == out
187
194
188
195
0 commit comments