@@ -113,3 +113,49 @@ def test_eager_lsp_completion() -> None:
113
113
],
114
114
}
115
115
assert_that (actual , is_ (expected ))
116
+
117
+
118
+ def test_lsp_completion_class_method () -> None :
119
+ """Checks whether completion returns self unnecessarily.
120
+
121
+ References: https://github.com/pappasam/jedi-language-server/issues/121
122
+
123
+ Note: I resolve eagerly to make test simpler
124
+ """
125
+ with session .LspSession () as ls_session :
126
+ # Initialize, asking for eager resolution.
127
+ initialize_params = copy .deepcopy (VSCODE_DEFAULT_INITIALIZE )
128
+ initialize_params ["initializationOptions" ] = {
129
+ "completion" : {"resolveEagerly" : True }
130
+ }
131
+ ls_session .initialize (initialize_params )
132
+
133
+ uri = as_uri (COMPLETION_TEST_ROOT / "completion_test_class_self.py" )
134
+ actual = ls_session .text_document_completion (
135
+ {
136
+ "textDocument" : {"uri" : uri },
137
+ "position" : {"line" : 7 , "character" : 13 },
138
+ "context" : {"triggerKind" : 1 },
139
+ }
140
+ )
141
+
142
+ # pylint: disable=line-too-long
143
+ expected = {
144
+ "isIncomplete" : False ,
145
+ "items" : [
146
+ {
147
+ "label" : "some_method" ,
148
+ "kind" : 3 ,
149
+ "detail" : "def some_method" ,
150
+ "documentation" : {
151
+ "kind" : "markdown" ,
152
+ "value" : "```\n some_method(x)\n \n Great method.\n ```\n " ,
153
+ },
154
+ "sortText" : "z" ,
155
+ "filterText" : "some_method" ,
156
+ "insertText" : "some_method(${1:x})$0" ,
157
+ "insertTextFormat" : 2 ,
158
+ }
159
+ ],
160
+ }
161
+ assert_that (actual , is_ (expected ))
0 commit comments