mirror of
https://github.com/davidhalter/jedi.git
synced 2025-12-08 06:44:46 +08:00
Get rid of cwd modifications in tests
This commit is contained in:
@@ -5,7 +5,7 @@ from jedi._compatibility import force_unicode
|
||||
from jedi.inference.sys_path import _get_parent_dir_with_file, \
|
||||
_get_buildout_script_paths, check_sys_path_modifications
|
||||
|
||||
from ..helpers import cwd_at
|
||||
from ..helpers import get_example_dir
|
||||
|
||||
|
||||
def check_module_test(Script, code):
|
||||
@@ -13,20 +13,18 @@ def check_module_test(Script, code):
|
||||
return check_sys_path_modifications(module_context)
|
||||
|
||||
|
||||
@cwd_at('test/examples/buildout_project/src/proj_name')
|
||||
def test_parent_dir_with_file(Script):
|
||||
parent = _get_parent_dir_with_file(
|
||||
os.path.abspath(os.curdir), 'buildout.cfg')
|
||||
path = get_example_dir('buildout_project', 'src', 'proj_name')
|
||||
parent = _get_parent_dir_with_file(path, 'buildout.cfg')
|
||||
assert parent is not None
|
||||
assert parent.endswith(os.path.join('test', 'examples', 'buildout_project'))
|
||||
|
||||
|
||||
@cwd_at('test/examples/buildout_project/src/proj_name')
|
||||
def test_buildout_detection(Script):
|
||||
scripts = list(_get_buildout_script_paths(os.path.abspath('./module_name.py')))
|
||||
path = get_example_dir('buildout_project', 'src', 'proj_name')
|
||||
scripts = list(_get_buildout_script_paths(os.path.join(path, 'module_name.py')))
|
||||
assert len(scripts) == 1
|
||||
curdir = os.path.abspath(os.curdir)
|
||||
appdir_path = os.path.normpath(os.path.join(curdir, '../../bin/app'))
|
||||
appdir_path = os.path.normpath(os.path.join(path, '../../bin/app'))
|
||||
assert scripts[0] == appdir_path
|
||||
|
||||
|
||||
@@ -53,13 +51,12 @@ def test_path_from_invalid_sys_path_assignment(Script):
|
||||
assert 'invalid' not in paths
|
||||
|
||||
|
||||
@cwd_at('test/examples/buildout_project/src/proj_name/')
|
||||
def test_sys_path_with_modifications(Script):
|
||||
path = get_example_dir('buildout_project', 'src', 'proj_name', 'module_name.py')
|
||||
code = dedent("""
|
||||
import os
|
||||
""")
|
||||
|
||||
path = os.path.abspath(os.path.join(os.curdir, 'module_name.py'))
|
||||
paths = Script(code, path=path)._inference_state.get_sys_path()
|
||||
assert '/tmp/.buildout/eggs/important_package.egg' in paths
|
||||
|
||||
|
||||
Reference in New Issue
Block a user