@@ -118,6 +118,44 @@ def test_symbols_non_existing_file(config, workspace, tmpdir) -> None:
118118 helper_check_symbols_all_scope (symbols )
119119
120120
121+ @pytest .mark .parametrize ("all_scopes" , [False , True ])
122+ @pytest .mark .parametrize ("include_import_symbols" , [False , True ])
123+ def test_symbols_imported_namedtuple (
124+ config , temp_workspace_factory , all_scopes , include_import_symbols
125+ ) -> None :
126+ workspace = temp_workspace_factory (
127+ {
128+ "__init__.py" : "" ,
129+ "a.py" : 'from .b import MyNamedTuple\n a_symbol = "a_symbol"\n ' ,
130+ "b.py" : (
131+ "from collections import namedtuple\n "
132+ 'MyNamedTuple = namedtuple("MyNamedTuple", ["abc"])\n '
133+ ),
134+ }
135+ )
136+ doc = workspace .get_document (
137+ uris .from_fs_path (os .path .join (workspace .root_path , "a.py" ))
138+ )
139+ config .update (
140+ {
141+ "plugins" : {
142+ "jedi_symbols" : {
143+ "all_scopes" : all_scopes ,
144+ "include_import_symbols" : include_import_symbols ,
145+ }
146+ }
147+ }
148+ )
149+
150+ symbols = pylsp_document_symbols (config , doc )
151+
152+ expected = {"a_symbol" : SymbolKind .Variable }
153+ if include_import_symbols :
154+ expected ["MyNamedTuple" ] = SymbolKind .Class
155+ assert {symbol ["name" ]: symbol ["kind" ] for symbol in symbols } == expected
156+ assert all (symbol ["location" ]["uri" ] == doc .uri for symbol in symbols )
157+
158+
121159@pytest .mark .skipif (
122160 PY2 or not LINUX or not CI , reason = "tested on linux and python 3 only"
123161)
0 commit comments