Skip to content

Commit

Permalink
Add completion tests for several libraries of the Scientific Python s…
Browse files Browse the repository at this point in the history
…tack (#682)
  • Loading branch information
ccordoba12 authored Oct 27, 2019
1 parent 5850ac0 commit f619d3a
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 2 deletions.
3 changes: 2 additions & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,8 @@
'pylint': ['pylint'],
'rope': ['rope>0.10.5'],
'yapf': ['yapf'],
'test': ['versioneer', 'pylint', 'pytest', 'mock', 'pytest-cov', 'coverage'],
'test': ['versioneer', 'pylint', 'pytest', 'mock', 'pytest-cov',
'coverage', 'numpy', 'pandas', 'matplotlib'],
},

# To provide executable scripts, use entry points in preference to the
Expand Down
36 changes: 35 additions & 1 deletion test/plugins/test_completion.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ def test_rope_import_completion(config, workspace):


@pytest.mark.skipif(LooseVersion(jedi.__version__) < LooseVersion('0.14.0'),
reason='This test fails with previous versions of jedi')
reason='This test fails with previous versions of Jedi')
def test_jedi_completion(config):
# Over 'i' in os.path.isabs(...)
com_position = {'line': 1, 'character': 15}
Expand Down Expand Up @@ -118,3 +118,37 @@ def test_jedi_method_completion(config):

assert 'insertTextFormat' not in everyone_method
assert everyone_method['insertText'] == 'everyone'


@pytest.mark.skipif(LooseVersion('0.15.0') <= LooseVersion(jedi.__version__) < LooseVersion('0.16.0'),
reason='This test fails with Jedi 0.15')
def test_numpy_completions(config):
doc_numpy = "import numpy as np; np."
com_position = {'line': 0, 'character': len(doc_numpy)}
doc = Document(DOC_URI, doc_numpy)
items = pyls_jedi_completions(config, doc, com_position)

assert items
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')
def test_pandas_completions(config):
doc_pandas = "import pandas as pd; pd."
com_position = {'line': 0, 'character': len(doc_pandas)}
doc = Document(DOC_URI, doc_pandas)
items = pyls_jedi_completions(config, doc, com_position)

assert items
assert any(['DataFrame' in i['label'] for i in items])


def test_matplotlib_completions(config):
doc_mpl = "import matplotlib.pyplot as plt; plt."
com_position = {'line': 0, 'character': len(doc_mpl)}
doc = Document(DOC_URI, doc_mpl)
items = pyls_jedi_completions(config, doc, com_position)

assert items
assert any(['plot' in i['label'] for i in items])

0 comments on commit f619d3a

Please sign in to comment.