mirror of
https://github.com/davidhalter/jedi.git
synced 2025-12-06 22:14:27 +08:00
Fix transform_path_to_dotted tests on Windows
Compiled modules end with the .pyd extension on Windows.
This commit is contained in:
@@ -13,14 +13,20 @@ else:
|
|||||||
TestCase = unittest.TestCase
|
TestCase = unittest.TestCase
|
||||||
|
|
||||||
import os
|
import os
|
||||||
|
import pytest
|
||||||
from os.path import abspath, dirname, join
|
from os.path import abspath, dirname, join
|
||||||
import functools
|
from functools import partial, wraps
|
||||||
|
|
||||||
test_dir = dirname(abspath(__file__))
|
test_dir = dirname(abspath(__file__))
|
||||||
root_dir = dirname(test_dir)
|
root_dir = dirname(test_dir)
|
||||||
|
|
||||||
sample_int = 1 # This is used in completion/imports.py
|
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):
|
def get_example_dir(name):
|
||||||
return join(test_dir, 'examples', 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'``).
|
:arg path: relative path from repository root (e.g., ``'jedi'``).
|
||||||
"""
|
"""
|
||||||
def decorator(func):
|
def decorator(func):
|
||||||
@functools.wraps(func)
|
@wraps(func)
|
||||||
def wrapper(Script, **kwargs):
|
def wrapper(Script, **kwargs):
|
||||||
with set_cwd(path):
|
with set_cwd(path):
|
||||||
return func(Script, **kwargs)
|
return func(Script, **kwargs)
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ import sys
|
|||||||
import shutil
|
import shutil
|
||||||
|
|
||||||
import pytest
|
import pytest
|
||||||
|
from ..helpers import skip_if_windows, skip_if_not_windows
|
||||||
|
|
||||||
from jedi.evaluate import sys_path
|
from jedi.evaluate import sys_path
|
||||||
from jedi.api.environment import create_environment
|
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/__init__.py', ('bar',), True),
|
||||||
(['/foo'], '/foo/bar/baz/__init__.py', ('bar', 'baz'), 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'], '/x/bar.py', None, False),
|
||||||
(['/foo'], '/foo/bar.xyz', ('bar.xyz',), False),
|
(['/foo'], '/foo/bar.xyz', ('bar.xyz',), False),
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user