merged dev and linter

This commit is contained in:
Dave Halter
2014-07-17 23:17:45 +02:00
16 changed files with 321 additions and 153 deletions

View File

@@ -127,6 +127,11 @@ def test_completion_docstring():
assert c.docstring(raw=True, fast=False) == cleandoc(Script.__doc__)
def test_completion_params():
c = Script('import string; string.capwords').completions()[0]
assert [p.name for p in c.params] == ['s', 'sep']
def test_signature_params():
def check(defs):
params = defs[0].params

View File

@@ -0,0 +1,12 @@
#!/usr/bin/python
import sys
sys.path[0:0] = [
'/usr/lib/python3.4/site-packages',
'/tmp/.buildout/eggs/important_package.egg'
]
import important_package
if __name__ == '__main__':
sys.exit(important_package.main())

View File

@@ -0,0 +1,71 @@
import os
from ..helpers import cwd_at
from jedi._compatibility import u
from jedi.parser import Parser
from jedi.evaluate.sys_path import (
_get_parent_dir_with_file,
_get_buildout_scripts,
_check_module
)
@cwd_at('test/test_evaluate/buildout_project/src/proj_name')
def test_parent_dir_with_file():
parent = _get_parent_dir_with_file(
os.path.abspath(os.curdir), 'buildout.cfg')
assert parent is not None
assert parent.endswith('test/test_evaluate/buildout_project')
@cwd_at('test/test_evaluate/buildout_project/src/proj_name')
def test_buildout_detection():
scripts = _get_buildout_scripts(os.path.abspath('./module_name.py'))
assert len(scripts) == 1
curdir = os.path.abspath(os.curdir)
appdir_path = os.path.normpath(os.path.join(curdir, '../../bin/app'))
assert scripts[0] == appdir_path
def test_append_on_non_sys_path():
SRC = u("""
class Dummy(object):
path = []
d = Dummy()
d.path.append('foo')""")
p = Parser(SRC)
paths = _check_module(p.module)
assert len(paths) > 0
assert 'foo' not in paths
def test_path_from_invalid_sys_path_assignment():
SRC = u("""
import sys
sys.path = 'invalid'""")
p = Parser(SRC)
paths = _check_module(p.module)
assert len(paths) > 0
assert 'invalid' not in paths
def test_path_from_sys_path_assignment():
SRC = u("""
#!/usr/bin/python
import sys
sys.path[0:0] = [
'/usr/lib/python3.4/site-packages',
'/home/test/.buildout/eggs/important_package.egg'
]
path[0:0] = [1]
import important_package
if __name__ == '__main__':
sys.exit(important_package.main())""")
p = Parser(SRC)
paths = _check_module(p.module)
assert 1 not in paths
assert '/home/test/.buildout/eggs/important_package.egg' in paths

View File

@@ -57,7 +57,7 @@ class TestRegression(TestCase):
self.assertRaises(jedi.NotFoundError, get_def, cls)
@pytest.mark.skip('Skip for now, test case is not really supported.')
@pytest.mark.skipif('True', reason='Skip for now, test case is not really supported.')
@cwd_at('jedi')
def test_add_dynamic_mods(self):
fname = '__main__.py'