@@ -98,6 +98,67 @@ import package.sub_package.module2
98
98
completionModule2 . Should ( ) . HaveLabels ( "Y" ) . And . NotContainLabels ( "X" ) ;
99
99
}
100
100
101
+ [ ServerTestMethod ( LatestAvailable3X = true , TestSpecificRootUri = true ) , Priority ( 0 ) ]
102
+ public async Task Completions_ImportResolution_UserSearchPathsInsideWorkspace ( Server server ) {
103
+ var folder1 = TestData . GetTestSpecificPath ( "folder1" ) ;
104
+ var folder2 = TestData . GetTestSpecificPath ( "folder2" ) ;
105
+ var packageInFolder1 = Path . Combine ( folder1 , "package" ) ;
106
+ var packageInFolder2 = Path . Combine ( folder2 , "package" ) ;
107
+ var module1Path = Path . Combine ( packageInFolder1 , "module1.py" ) ;
108
+ var module2Path = Path . Combine ( packageInFolder2 , "module2.py" ) ;
109
+ var module1Content = @"class A():
110
+ @staticmethod
111
+ def method1():
112
+ pass" ;
113
+ var module2Content = @"class B():
114
+ @staticmethod
115
+ def method2():
116
+ pass" ;
117
+ var mainContent = @"from package import module1 as mod1, module2 as mod2
118
+ mod1.
119
+ mod2.
120
+ mod1.A.
121
+ mod2.B." ;
122
+
123
+ server . Analyzer . SetSearchPaths ( new [ ] { folder1 , folder2 } ) ;
124
+
125
+ await server . OpenDocumentAndGetUriAsync ( module1Path , module1Content ) ;
126
+ await server . OpenDocumentAndGetUriAsync ( module2Path , module2Content ) ;
127
+ var uri = await server . OpenDocumentAndGetUriAsync ( "main.py" , mainContent ) ;
128
+
129
+ await server . WaitForCompleteAnalysisAsync ( CancellationToken . None ) ;
130
+
131
+ var completionMod1 = await server . SendCompletion ( uri , 1 , 5 ) ;
132
+ var completionMod2 = await server . SendCompletion ( uri , 2 , 5 ) ;
133
+ var completionA = await server . SendCompletion ( uri , 3 , 7 ) ;
134
+ var completionB = await server . SendCompletion ( uri , 4 , 7 ) ;
135
+ completionMod1 . Should ( ) . HaveLabels ( "A" ) . And . NotContainLabels ( "B" ) ;
136
+ completionMod2 . Should ( ) . HaveLabels ( "B" ) . And . NotContainLabels ( "A" ) ;
137
+ completionA . Should ( ) . HaveLabels ( "method1" ) ;
138
+ completionB . Should ( ) . HaveLabels ( "method2" ) ;
139
+ }
140
+
141
+ [ ServerTestMethod ( LatestAvailable3X = true , TestSpecificRootUri = true ) , Priority ( 0 ) ]
142
+ [ Ignore ( "https://github.com/Microsoft/python-language-server/issues/468" ) ]
143
+ public async Task Completions_ImportResolution_ModuleInWorkspaceAndInUserSearchPath ( Server server ) {
144
+ var extraSearchPath = TestData . GetTestSpecificPath ( Path . Combine ( "some" , "other" ) ) ;
145
+ var module1Path = TestData . GetTestSpecificPath ( "module.py" ) ;
146
+ var module2Path = Path . Combine ( extraSearchPath , "module.py" ) ;
147
+ var module1Content = "A = 1" ;
148
+ var module2Content = "B = 2" ;
149
+ var mainContent = @"import module as mod; mod." ;
150
+
151
+ server . Analyzer . SetSearchPaths ( new [ ] { extraSearchPath } ) ;
152
+
153
+ await server . OpenDocumentAndGetUriAsync ( module1Path , module1Content ) ;
154
+ await server . OpenDocumentAndGetUriAsync ( module2Path , module2Content ) ;
155
+ var uri = await server . OpenDocumentAndGetUriAsync ( "main.py" , mainContent ) ;
156
+
157
+ await server . WaitForCompleteAnalysisAsync ( CancellationToken . None ) ;
158
+ var completion = await server . SendCompletion ( uri , 0 , 26 ) ;
159
+ completion . Should ( ) . HaveLabels ( "A" ) . And . NotContainLabels ( "B" ) ;
160
+ }
161
+
101
162
[ Ignore ( "https://github.com/Microsoft/python-language-server/issues/443" ) ]
102
163
[ ServerTestMethod ( LatestAvailable3X = true , TestSpecificRootUri = true ) , Priority ( 0 ) ]
103
164
public async Task Completions_ImportResolution_OneSearchPathInsideAnother ( Server server ) {
0 commit comments