@@ -17,10 +17,18 @@ class Test2(Test1):
17
17
pass
18
18
'''
19
19
20
+ DOC_NAME_EXTRA = 'test2.py'
21
+ DOC_EXTRA = '''from test1 import Test1
22
+ x = Test1()
23
+ '''
24
+
20
25
21
26
@pytest .fixture
22
27
def tmp_workspace (temp_workspace_factory ):
23
- return temp_workspace_factory ({DOC_NAME : DOC })
28
+ return temp_workspace_factory ({
29
+ DOC_NAME : DOC ,
30
+ DOC_NAME_EXTRA : DOC_EXTRA
31
+ })
24
32
25
33
26
34
@pytest .mark .skipif (LT_PY36 , reason = 'Jedi refactoring isnt supported on Python 2.x/3.5' )
@@ -34,10 +42,11 @@ def test_jedi_rename(tmp_workspace, config): # pylint: disable=redefined-outer-
34
42
assert len (result .keys ()) == 1
35
43
36
44
changes = result .get ('documentChanges' )
37
- assert len (changes ) == 1
38
- changes = changes [0 ]
45
+ assert len (changes ) == 2
39
46
40
- assert changes .get ('edits' ) == [
47
+ assert changes [0 ]['textDocument' ]['uri' ] == doc .uri
48
+ assert changes [0 ]['textDocument' ]['version' ] == doc .version
49
+ assert changes [0 ].get ('edits' ) == [
41
50
{
42
51
'range' : {
43
52
'start' : {'line' : 0 , 'character' : 0 },
@@ -46,3 +55,23 @@ def test_jedi_rename(tmp_workspace, config): # pylint: disable=redefined-outer-
46
55
'newText' : 'class ShouldBeRenamed():\n pass\n \n class Test2(ShouldBeRenamed):\n pass\n ' ,
47
56
}
48
57
]
58
+ path = os .path .join (tmp_workspace .root_path , DOC_NAME_EXTRA )
59
+ uri_extra = uris .from_fs_path (path )
60
+ assert changes [1 ]['textDocument' ]['uri' ] == uri_extra
61
+ # This also checks whether documents not yet added via textDocument/didOpen
62
+ # but that do need to be renamed in the project have a `null` version
63
+ # number.
64
+ assert changes [1 ]['textDocument' ]['version' ] is None
65
+ expected = 'from test1 import ShouldBeRenamed\n x = ShouldBeRenamed()\n '
66
+ if os .name == 'nt' :
67
+ # The .write method in the temp_workspace_factory functions writes
68
+ # Windows-style line-endings.
69
+ expected = expected .replace ('\n ' , '\r \n ' )
70
+ assert changes [1 ].get ('edits' ) == [
71
+ {
72
+ 'range' : {
73
+ 'start' : {'line' : 0 , 'character' : 0 },
74
+ 'end' : {'line' : 2 , 'character' : 0 }},
75
+ 'newText' : expected
76
+ }
77
+ ]
0 commit comments