File tree Expand file tree Collapse file tree 2 files changed +12
-9
lines changed Expand file tree Collapse file tree 2 files changed +12
-9
lines changed Original file line number Diff line number Diff line change 2
2
# Copyright 2021- Python Language Server Contributors.
3
3
4
4
import logging
5
- import os
5
+ from pathlib import Path
6
6
7
7
from pylsp import hookimpl
8
8
from pylsp .lsp import SymbolKind
@@ -91,14 +91,7 @@ def pylsp_document_symbols(config, document):
91
91
else :
92
92
continue
93
93
94
- try :
95
- docismodule = os .path .samefile (document .path , d .module_path )
96
- except (TypeError , FileNotFoundError ):
97
- # Python 2 on Windows has no .samefile, but then these are
98
- # strings for sure
99
- docismodule = document .path == d .module_path
100
-
101
- if _include_def (d ) and docismodule :
94
+ if _include_def (d ) and Path (document .path ) == d .module_path :
102
95
tuple_range = _tuple_range (d )
103
96
if tuple_range in exclude :
104
97
continue
Original file line number Diff line number Diff line change @@ -80,6 +80,16 @@ def test_symbols_all_scopes(config, workspace):
80
80
helper_check_symbols_all_scope (symbols )
81
81
82
82
83
+ def test_symbols_non_existing_file (config , workspace , tmpdir ):
84
+ path = tmpdir .join ("foo.py" )
85
+ # Check pre-condition: file must not exist
86
+ assert not path .check (exists = 1 )
87
+
88
+ doc = Document (uris .from_fs_path (str (path )), workspace , DOC )
89
+ symbols = pylsp_document_symbols (config , doc )
90
+ helper_check_symbols_all_scope (symbols )
91
+
92
+
83
93
@pytest .mark .skipif (PY2 or not LINUX or not CI , reason = "tested on linux and python 3 only" )
84
94
def test_symbols_all_scopes_with_jedi_environment (workspace ):
85
95
doc = Document (DOC_URI , workspace , DOC )
You can’t perform that action at this time.
0 commit comments