mirror of
https://github.com/davidhalter/jedi.git
synced 2026-02-03 12:22:42 +08:00
Merge branch 'master' of github.com:davidhalter/jedi
This commit is contained in:
@@ -13,14 +13,20 @@ else:
|
||||
TestCase = unittest.TestCase
|
||||
|
||||
import os
|
||||
import pytest
|
||||
from os.path import abspath, dirname, join
|
||||
import functools
|
||||
from functools import partial, wraps
|
||||
|
||||
test_dir = dirname(abspath(__file__))
|
||||
root_dir = dirname(test_dir)
|
||||
|
||||
sample_int = 1 # This is used in completion/imports.py
|
||||
|
||||
skip_if_windows = partial(pytest.param,
|
||||
marks=pytest.mark.skipif("sys.platform=='win32'"))
|
||||
skip_if_not_windows = partial(pytest.param,
|
||||
marks=pytest.mark.skipif("sys.platform!='win32'"))
|
||||
|
||||
|
||||
def get_example_dir(name):
|
||||
return join(test_dir, 'examples', name)
|
||||
@@ -34,7 +40,7 @@ def cwd_at(path):
|
||||
:arg path: relative path from repository root (e.g., ``'jedi'``).
|
||||
"""
|
||||
def decorator(func):
|
||||
@functools.wraps(func)
|
||||
@wraps(func)
|
||||
def wrapper(Script, **kwargs):
|
||||
with set_cwd(path):
|
||||
return func(Script, **kwargs)
|
||||
|
||||
@@ -357,9 +357,11 @@ def collect_dir_tests(base_dir, test_files, check_thirdparty=False):
|
||||
path = os.path.join(base_dir, f_name)
|
||||
|
||||
if is_py3:
|
||||
source = open(path, encoding='utf-8').read()
|
||||
with open(path, encoding='utf-8') as f:
|
||||
source = f.read()
|
||||
else:
|
||||
source = unicode(open(path).read(), 'UTF-8')
|
||||
with open(path) as f:
|
||||
source = unicode(f.read(), 'UTF-8')
|
||||
|
||||
for case in collect_file_tests(path, StringIO(source),
|
||||
lines_to_execute):
|
||||
|
||||
@@ -38,7 +38,9 @@ def test_find_module_not_package():
|
||||
assert is_package is False
|
||||
|
||||
|
||||
pkg_zip_path = os.path.join(os.path.dirname(__file__), 'zipped_imports/pkg.zip')
|
||||
pkg_zip_path = os.path.join(os.path.dirname(__file__),
|
||||
'zipped_imports',
|
||||
'pkg.zip')
|
||||
|
||||
|
||||
def test_find_module_package_zipped(Script, evaluator, environment):
|
||||
|
||||
@@ -4,6 +4,7 @@ import sys
|
||||
import shutil
|
||||
|
||||
import pytest
|
||||
from ..helpers import skip_if_windows, skip_if_not_windows
|
||||
|
||||
from jedi.evaluate import sys_path
|
||||
from jedi.api.environment import create_environment
|
||||
@@ -87,8 +88,12 @@ _s = ['/a', '/b', '/c/d/']
|
||||
|
||||
(['/foo'], '/foo/bar/__init__.py', ('bar',), True),
|
||||
(['/foo'], '/foo/bar/baz/__init__.py', ('bar', 'baz'), True),
|
||||
(['/foo'], '/foo/bar.so', ('bar',), False),
|
||||
(['/foo'], '/foo/bar/__init__.so', ('bar',), True),
|
||||
|
||||
skip_if_windows(['/foo'], '/foo/bar.so', ('bar',), False),
|
||||
skip_if_windows(['/foo'], '/foo/bar/__init__.so', ('bar',), True),
|
||||
skip_if_not_windows(['/foo'], '/foo/bar.pyd', ('bar',), False),
|
||||
skip_if_not_windows(['/foo'], '/foo/bar/__init__.pyd', ('bar',), True),
|
||||
|
||||
(['/foo'], '/x/bar.py', None, False),
|
||||
(['/foo'], '/foo/bar.xyz', ('bar.xyz',), False),
|
||||
|
||||
|
||||
Reference in New Issue
Block a user