From 77a7792afc935ab9b6e52d137ad5e36c7bfde6a6 Mon Sep 17 00:00:00 2001 From: micbou Date: Wed, 13 Mar 2019 01:48:10 +0100 Subject: [PATCH] Fix transform_path_to_dotted tests on Windows Convert paths to normalized absolute ones in transform_path_to_dotted tests. --- jedi/evaluate/sys_path.py | 3 ++- test/test_evaluate/test_sys_path.py | 3 +++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/jedi/evaluate/sys_path.py b/jedi/evaluate/sys_path.py index d6f41086..9eb420b6 100644 --- a/jedi/evaluate/sys_path.py +++ b/jedi/evaluate/sys_path.py @@ -200,7 +200,8 @@ def transform_path_to_dotted(sys_path, module_path): """ Returns the dotted path inside a sys.path as a list of names. e.g. - >>> transform_path_to_dotted(["/foo"], '/foo/bar/baz.py') + >>> from os.path import abspath + >>> transform_path_to_dotted([abspath("/foo")], abspath('/foo/bar/baz.py')) ['bar', 'baz'] Returns None if the path doesn't really resolve to anything. diff --git a/test/test_evaluate/test_sys_path.py b/test/test_evaluate/test_sys_path.py index 8f1d8934..ba37aac1 100644 --- a/test/test_evaluate/test_sys_path.py +++ b/test/test_evaluate/test_sys_path.py @@ -86,4 +86,7 @@ _s = ['/a', '/b', '/c/d/'] (_s, '/a/c/.py', None), ]) def test_calculate_dotted_from_path(sys_path_, module_path, result): + # tranform_path_to_dotted expects normalized absolute paths. + sys_path_ = [os.path.abspath(path) for path in sys_path_] + module_path = os.path.abspath(module_path) assert sys_path.transform_path_to_dotted(sys_path_, module_path) == result