mirror of
https://github.com/davidhalter/jedi.git
synced 2025-12-06 14:04:26 +08:00
Merge branch 'master' of github.com:davidhalter/jedi
This commit is contained in:
@@ -78,7 +78,7 @@ class Script(object):
|
|||||||
:param sys_path: ``sys.path`` to use during analysis of the script
|
:param sys_path: ``sys.path`` to use during analysis of the script
|
||||||
:type sys_path: list
|
:type sys_path: list
|
||||||
:param environment: TODO
|
:param environment: TODO
|
||||||
:type sys_path: Environment
|
:type environment: Environment
|
||||||
"""
|
"""
|
||||||
def __init__(self, source=None, line=None, column=None, path=None,
|
def __init__(self, source=None, line=None, column=None, path=None,
|
||||||
encoding='utf-8', sys_path=None, environment=None):
|
encoding='utf-8', sys_path=None, environment=None):
|
||||||
|
|||||||
@@ -154,7 +154,11 @@ def _get_virtual_env_from_var():
|
|||||||
"""
|
"""
|
||||||
var = os.environ.get('VIRTUAL_ENV')
|
var = os.environ.get('VIRTUAL_ENV')
|
||||||
if var:
|
if var:
|
||||||
if var == sys.prefix:
|
# Under macOS in some cases - notably when using Pipenv - the
|
||||||
|
# sys.prefix of the virtualenv is /path/to/env/bin/.. instead of
|
||||||
|
# /path/to/env so we need to fully resolve the paths in order to
|
||||||
|
# compare them.
|
||||||
|
if os.path.realpath(var) == os.path.realpath(sys.prefix):
|
||||||
return _try_get_same_env()
|
return _try_get_same_env()
|
||||||
|
|
||||||
try:
|
try:
|
||||||
|
|||||||
@@ -133,13 +133,13 @@ def test_cache_works_with_sys_path_param(Script, tmpdir):
|
|||||||
def test_import_completion_docstring(Script):
|
def test_import_completion_docstring(Script):
|
||||||
import abc
|
import abc
|
||||||
s = Script('"""test"""\nimport ab')
|
s = Script('"""test"""\nimport ab')
|
||||||
completions = s.completions()
|
abc_completions = [c for c in s.completions() if c.name == 'abc']
|
||||||
assert len(completions) == 1
|
assert len(abc_completions) == 1
|
||||||
assert completions[0].docstring(fast=False) == abc.__doc__
|
assert abc_completions[0].docstring(fast=False) == abc.__doc__
|
||||||
|
|
||||||
# However for performance reasons not all modules are loaded and the
|
# However for performance reasons not all modules are loaded and the
|
||||||
# docstring is empty in this case.
|
# docstring is empty in this case.
|
||||||
assert completions[0].docstring() == ''
|
assert abc_completions[0].docstring() == ''
|
||||||
|
|
||||||
|
|
||||||
def test_goto_definition_on_import(Script):
|
def test_goto_definition_on_import(Script):
|
||||||
|
|||||||
Reference in New Issue
Block a user