forked from replit/python-language-server
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_rope_rename.py
More file actions
44 lines (34 loc) · 1.25 KB
/
Copy pathtest_rope_rename.py
File metadata and controls
44 lines (34 loc) · 1.25 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
import os
import pytest
from pyls import uris
from pyls.plugins.rope_rename import pyls_rename
from pyls.workspace import Document
DOC_NAME = "test1.py"
DOC = """class Test1():
pass
class Test2(Test1):
pass
"""
@pytest.fixture
def tmp_workspace(temp_workspace_factory):
return temp_workspace_factory({DOC_NAME: DOC})
def test_rope_rename(tmp_workspace, config): # pylint: disable=redefined-outer-name
position = {"line": 0, "character": 6}
DOC_URI = uris.from_fs_path(os.path.join(tmp_workspace.root_path, DOC_NAME))
doc = Document(DOC_URI, tmp_workspace)
result = pyls_rename(config, tmp_workspace, doc, position, "ShouldBeRenamed")
assert len(result.keys()) == 1
changes = result.get("documentChanges")
assert len(changes) == 1
changes = changes[0]
# Note that this test differs from test_jedi_rename, because rope does not
# seem to modify files that haven't been opened with textDocument/didOpen.
assert changes.get("edits") == [
{
"range": {
"start": {"line": 0, "character": 0},
"end": {"line": 5, "character": 0},
},
"newText": "class ShouldBeRenamed():\n pass\n\nclass Test2(ShouldBeRenamed):\n pass\n",
}
]