|
12 | 12 | import pytest
|
13 | 13 |
|
14 | 14 | from pylsp.python_lsp import start_io_lang_server, PythonLSPServer
|
15 |
| -from pylsp.lsp import NotebookCellKind |
16 | 15 |
|
17 | 16 | CALL_TIMEOUT = 10
|
18 | 17 | RUNNING_IN_CI = bool(os.environ.get('CI'))
|
@@ -119,285 +118,3 @@ def test_not_exit_without_check_parent_process_flag(client_server): # pylint: d
|
119 | 118 | def test_missing_message(client_server): # pylint: disable=redefined-outer-name
|
120 | 119 | with pytest.raises(JsonRpcMethodNotFound):
|
121 | 120 | client_server._endpoint.request('unknown_method').result(timeout=CALL_TIMEOUT)
|
122 |
| - |
123 |
| - |
124 |
| -# Run this test if you want to see the diagnostics messages of an LSP server |
125 |
| -def test_text_document__did_open(client_server): |
126 |
| - client_server._endpoint.request('initialize', { |
127 |
| - 'processId': 1234, |
128 |
| - 'rootPath': os.path.dirname(__file__), |
129 |
| - 'initializationOptions': {} |
130 |
| - }).result(timeout=CALL_TIMEOUT) |
131 |
| - client_server._endpoint.notify('textDocument/didOpen', { |
132 |
| - 'textDocument': { |
133 |
| - 'uri': os.path.join(os.path.dirname(__file__)), |
134 |
| - 'version': 1, |
135 |
| - 'text': 'import sys\nx=2\ny=x+2' |
136 |
| - } |
137 |
| - }) |
138 |
| - # TODO: assert on the content of diagnostics message |
139 |
| - |
140 |
| - |
141 |
| -# Run this test if you want to see the diagnostics messages of an LSP server |
142 |
| -def test_notebook_document__did_open(client_server): |
143 |
| - client_server._endpoint.request('initialize', { |
144 |
| - 'processId': 1234, |
145 |
| - 'rootPath': os.path.dirname(__file__), |
146 |
| - 'initializationOptions': {} |
147 |
| - }).result(timeout=CALL_TIMEOUT) |
148 |
| - client_server._endpoint.notify('notebookDocument/didOpen', { |
149 |
| - 'notebookDocument': { |
150 |
| - 'uri': 'notebook_uri', |
151 |
| - 'notebookType': 'jupyter-notebook', |
152 |
| - 'cells': [ |
153 |
| - { |
154 |
| - 'kind': NotebookCellKind.Code, |
155 |
| - 'document': "cell_1_uri", |
156 |
| - }, |
157 |
| - # TODO: add markdown cell support later |
158 |
| - # { |
159 |
| - # 'kind': NotebookCellKind.Markup, |
160 |
| - # 'document': "cell_2_uri", |
161 |
| - # }, |
162 |
| - { |
163 |
| - 'kind': NotebookCellKind.Code, |
164 |
| - 'document': "cell_3_uri", |
165 |
| - } |
166 |
| - ] |
167 |
| - }, |
168 |
| - 'cellTextDocuments': [ |
169 |
| - { |
170 |
| - 'uri': 'cell_1_uri', |
171 |
| - 'languageId': 'python', |
172 |
| - 'text': 'import sys', |
173 |
| - }, |
174 |
| - # { |
175 |
| - # 'uri': 'cell_2_uri', |
176 |
| - # 'languageId': 'markdown', |
177 |
| - # 'text': '# Title\n\n Some text', |
178 |
| - # }, |
179 |
| - { |
180 |
| - 'uri': 'cell_3_uri', |
181 |
| - 'languageId': 'python', |
182 |
| - 'text': 'x = 2\ny = x + 2\nprint(z)', |
183 |
| - } |
184 |
| - ] |
185 |
| - }) |
186 |
| - # TODO: assert on the content of diagnostics message |
187 |
| - |
188 |
| - |
189 |
| -# Run this test if you want to see the diagnostics messages of an LSP server |
190 |
| -def test_notebook_document__did_change__edit_content(client_server): |
191 |
| - client_server._endpoint.request('initialize', { |
192 |
| - 'processId': 1234, |
193 |
| - 'rootPath': os.path.dirname(__file__), |
194 |
| - 'initializationOptions': {} |
195 |
| - }).result(timeout=CALL_TIMEOUT) |
196 |
| - client_server._endpoint.notify('notebookDocument/didOpen', { |
197 |
| - 'notebookDocument': { |
198 |
| - 'uri': 'notebook_uri', |
199 |
| - 'notebookType': 'jupyter-notebook', |
200 |
| - 'cells': [ |
201 |
| - { |
202 |
| - 'kind': NotebookCellKind.Code, |
203 |
| - 'document': "cell_1_uri", |
204 |
| - }, |
205 |
| - { |
206 |
| - 'kind': NotebookCellKind.Code, |
207 |
| - 'document': "cell_2_uri", |
208 |
| - } |
209 |
| - ] |
210 |
| - }, |
211 |
| - 'cellTextDocuments': [ |
212 |
| - { |
213 |
| - 'uri': 'cell_1_uri', |
214 |
| - 'languageId': 'python', |
215 |
| - 'text': 'import sys', |
216 |
| - }, |
217 |
| - { |
218 |
| - 'uri': 'cell_2_uri', |
219 |
| - 'languageId': 'python', |
220 |
| - 'text': '', |
221 |
| - } |
222 |
| - ] |
223 |
| - }) |
224 |
| - time.sleep(1) |
225 |
| - # TODO: assert diagnostics complains about sys being imported but not used |
226 |
| - client_server._endpoint.notify('notebookDocument/didChange', { |
227 |
| - 'notebookDocument': { |
228 |
| - 'uri': 'notebook_uri', |
229 |
| - }, |
230 |
| - 'change': { |
231 |
| - 'cells': { |
232 |
| - 'textContent': [ |
233 |
| - { |
234 |
| - 'document': { |
235 |
| - 'uri': 'cell_2_uri', |
236 |
| - }, |
237 |
| - 'changes': [ |
238 |
| - { |
239 |
| - 'text': 'sys.path' |
240 |
| - } |
241 |
| - ] |
242 |
| - } |
243 |
| - ] |
244 |
| - } |
245 |
| - } |
246 |
| - }) |
247 |
| - time.sleep(1) |
248 |
| - # TODO: assert that diagnostics is gone |
249 |
| - # TODO: assert that the virtualized document has been removed to avoid memory leak |
250 |
| - |
251 |
| - |
252 |
| -def test_notebook_document__did_change__add_new_cell(client_server): |
253 |
| - client_server._endpoint.request('initialize', { |
254 |
| - 'processId': 1234, |
255 |
| - 'rootPath': os.path.dirname(__file__), |
256 |
| - 'initializationOptions': {} |
257 |
| - }).result(timeout=CALL_TIMEOUT) |
258 |
| - client_server._endpoint.notify('notebookDocument/didOpen', { |
259 |
| - 'notebookDocument': { |
260 |
| - 'uri': 'notebook_uri', |
261 |
| - 'notebookType': 'jupyter-notebook', |
262 |
| - 'cells': [ |
263 |
| - { |
264 |
| - 'kind': NotebookCellKind.Code, |
265 |
| - 'document': "cell_1_uri", |
266 |
| - }, |
267 |
| - ] |
268 |
| - }, |
269 |
| - 'cellTextDocuments': [ |
270 |
| - { |
271 |
| - 'uri': 'cell_1_uri', |
272 |
| - 'languageId': 'python', |
273 |
| - 'text': 'import sys', |
274 |
| - }, |
275 |
| - ] |
276 |
| - }) |
277 |
| - time.sleep(1) |
278 |
| - # TODO: assert diagnostics complains about sys being imported but not used |
279 |
| - client_server._endpoint.notify('notebookDocument/didChange', { |
280 |
| - 'notebookDocument': { |
281 |
| - 'uri': 'notebook_uri', |
282 |
| - }, |
283 |
| - 'change': { |
284 |
| - 'cells': { |
285 |
| - 'structure': { |
286 |
| - 'array': { |
287 |
| - 'start': 1, |
288 |
| - 'deleteCount': 0, |
289 |
| - 'cells': [ |
290 |
| - { |
291 |
| - 'kind': NotebookCellKind.Code, |
292 |
| - 'document': "cell_2_uri", |
293 |
| - } |
294 |
| - ] |
295 |
| - }, |
296 |
| - 'didOpen': [ |
297 |
| - { |
298 |
| - 'uri': 'cell_2_uri', |
299 |
| - 'languageId': 'python', |
300 |
| - 'text': 'sys.path', |
301 |
| - } |
302 |
| - ] |
303 |
| - }, |
304 |
| - } |
305 |
| - } |
306 |
| - }) |
307 |
| - time.sleep(1) |
308 |
| - # TODO: assert that diagnostics is gone |
309 |
| - # TODO: assert that the virtualized document has been removed to avoid memory leak |
310 |
| - # Inserting a cell between cell 1 and 2 |
311 |
| - client_server._endpoint.notify('notebookDocument/didChange', { |
312 |
| - 'notebookDocument': { |
313 |
| - 'uri': 'notebook_uri', |
314 |
| - }, |
315 |
| - 'change': { |
316 |
| - 'cells': { |
317 |
| - 'structure': { |
318 |
| - 'array': { |
319 |
| - 'start': 1, |
320 |
| - 'deleteCount': 0, |
321 |
| - 'cells': [ |
322 |
| - { |
323 |
| - 'kind': NotebookCellKind.Code, |
324 |
| - 'document': "cell_3_uri", |
325 |
| - } |
326 |
| - ] |
327 |
| - }, |
328 |
| - 'didOpen': [ |
329 |
| - { |
330 |
| - 'uri': 'cell_3_uri', |
331 |
| - 'languageId': 'python', |
332 |
| - 'text': 'x', |
333 |
| - } |
334 |
| - ] |
335 |
| - }, |
336 |
| - } |
337 |
| - } |
338 |
| - }) |
339 |
| - time.sleep(1) |
340 |
| - # TODO: assert that the cells are in the right order |
341 |
| - |
342 |
| - |
343 |
| -def test_notebook_document__did_change__delete_cell(client_server): |
344 |
| - client_server._endpoint.request('initialize', { |
345 |
| - 'processId': 1234, |
346 |
| - 'rootPath': os.path.dirname(__file__), |
347 |
| - 'initializationOptions': {} |
348 |
| - }).result(timeout=CALL_TIMEOUT) |
349 |
| - client_server._endpoint.notify('notebookDocument/didOpen', { |
350 |
| - 'notebookDocument': { |
351 |
| - 'uri': 'notebook_uri', |
352 |
| - 'notebookType': 'jupyter-notebook', |
353 |
| - 'cells': [ |
354 |
| - { |
355 |
| - 'kind': NotebookCellKind.Code, |
356 |
| - 'document': "cell_1_uri", |
357 |
| - }, |
358 |
| - { |
359 |
| - 'kind': NotebookCellKind.Code, |
360 |
| - 'document': "cell_2_uri", |
361 |
| - } |
362 |
| - ] |
363 |
| - }, |
364 |
| - 'cellTextDocuments': [ |
365 |
| - { |
366 |
| - 'uri': 'cell_1_uri', |
367 |
| - 'languageId': 'python', |
368 |
| - 'text': 'import sys', |
369 |
| - }, |
370 |
| - { |
371 |
| - 'uri': 'cell_2_uri', |
372 |
| - 'languageId': 'python', |
373 |
| - 'text': 'sys.path', |
374 |
| - } |
375 |
| - ] |
376 |
| - }) |
377 |
| - time.sleep(1) |
378 |
| - # TODO: assert diagnostics should not complain |
379 |
| - # Delete cell 2 |
380 |
| - client_server._endpoint.notify('notebookDocument/didChange', { |
381 |
| - 'notebookDocument': { |
382 |
| - 'uri': 'notebook_uri', |
383 |
| - }, |
384 |
| - 'change': { |
385 |
| - 'cells': { |
386 |
| - 'structure': { |
387 |
| - 'array': { |
388 |
| - 'start': 1, |
389 |
| - 'deleteCount': 1, |
390 |
| - }, |
391 |
| - 'didClose': [ |
392 |
| - { |
393 |
| - 'uri': 'cell_2_uri', |
394 |
| - } |
395 |
| - ] |
396 |
| - }, |
397 |
| - } |
398 |
| - } |
399 |
| - }) |
400 |
| - time.sleep(1) |
401 |
| - # TODO: assert that diagnostics comaplains about sys being imported but not used |
402 |
| - # TODO: assert that the CellDocument has been removed from workspace.documents and notebook.cells |
403 |
| - assert 0 |
0 commit comments