mirror of
https://github.com/davidhalter/jedi.git
synced 2025-12-08 06:44:46 +08:00
Implement all remaining Path issues and use it instead of strings
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
import os
|
||||
from textwrap import dedent
|
||||
from pathlib import Path
|
||||
|
||||
from jedi.inference.sys_path import _get_parent_dir_with_file, \
|
||||
_get_buildout_script_paths, check_sys_path_modifications
|
||||
@@ -13,18 +14,18 @@ def check_module_test(Script, code):
|
||||
|
||||
|
||||
def test_parent_dir_with_file(Script):
|
||||
path = get_example_dir('buildout_project', 'src', 'proj_name')
|
||||
path = 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'))
|
||||
assert str(parent).endswith(os.path.join('test', 'examples', 'buildout_project'))
|
||||
|
||||
|
||||
def test_buildout_detection(Script):
|
||||
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
|
||||
path = Path(get_example_dir('buildout_project', 'src', 'proj_name'))
|
||||
paths = list(_get_buildout_script_paths(path.joinpath('module_name.py')))
|
||||
assert len(paths) == 1
|
||||
appdir_path = os.path.normpath(os.path.join(path, '../../bin/app'))
|
||||
assert scripts[0] == appdir_path
|
||||
assert str(paths[0]) == appdir_path
|
||||
|
||||
|
||||
def test_append_on_non_sys_path(Script):
|
||||
@@ -79,4 +80,4 @@ def test_path_from_sys_path_assignment(Script):
|
||||
|
||||
paths = check_module_test(Script, code)
|
||||
assert 1 not in paths
|
||||
assert '/home/test/.buildout/eggs/important_package.egg' in paths
|
||||
assert '/home/test/.buildout/eggs/important_package.egg' in map(str, paths)
|
||||
|
||||
Reference in New Issue
Block a user