From 16b64f59b76c3553f91a9f1cb72387eee910ecd8 Mon Sep 17 00:00:00 2001 From: micbou Date: Mon, 20 May 2019 12:33:32 +0200 Subject: [PATCH] Fix transform_path_to_dotted tests on Windows Compiled modules end with the .pyd extension on Windows. --- test/helpers.py | 10 ++++++++-- test/test_evaluate/test_sys_path.py | 9 +++++++-- 2 files changed, 15 insertions(+), 4 deletions(-) diff --git a/test/helpers.py b/test/helpers.py index 54d4a2e0..f08af1a3 100644 --- a/test/helpers.py +++ b/test/helpers.py @@ -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) diff --git a/test/test_evaluate/test_sys_path.py b/test/test_evaluate/test_sys_path.py index 5885e112..deaa64ca 100644 --- a/test/test_evaluate/test_sys_path.py +++ b/test/test_evaluate/test_sys_path.py @@ -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),