14
14
// permissions and limitations under the License.
15
15
16
16
using System ;
17
+ using System . Collections . Generic ;
17
18
using System . Diagnostics ;
18
19
using System . IO ;
19
20
using System . Threading ;
@@ -42,7 +43,7 @@ public abstract class AnalysisTestBase {
42
43
43
44
protected virtual IDiagnosticsService GetDiagnosticsService ( IServiceContainer s ) => null ;
44
45
45
- protected virtual ServiceManager CreateServiceManager ( ) {
46
+ protected ServiceManager CreateServiceManager ( ) {
46
47
Services = new ServiceManager ( ) ;
47
48
48
49
var platform = new OSPlatform ( ) ;
@@ -55,26 +56,23 @@ protected virtual ServiceManager CreateServiceManager() {
55
56
return Services ;
56
57
}
57
58
58
- protected string GetAnalysisTestDataFilesPath ( ) => TestData . GetPath ( Path . Combine ( "TestData" , "AstAnalysis" ) ) ;
59
+ protected string GetAnalysisTestDataFilesPath ( ) => TestData . GetPath ( "TestData" , "AstAnalysis" ) ;
59
60
60
- protected Task < IServiceManager > CreateServicesAsync ( InterpreterConfiguration configuration , IServiceManager sm = null )
61
- => CreateServicesAsync ( TestData . GetTestSpecificRootUri ( ) . AbsolutePath , configuration , null , sm ) ;
61
+ protected Task < IServiceManager > CreateServicesAsync ( InterpreterConfiguration configuration , string [ ] searchPaths = null )
62
+ => CreateServicesAsync ( TestData . GetTestSpecificRootPath ( ) , configuration , null , null , searchPaths ) ;
62
63
63
- protected async Task < IServiceManager > CreateServicesAsync ( string root , InterpreterConfiguration configuration , string stubCacheFolderPath = null , IServiceManager sm = null ) {
64
+ protected async Task < IServiceManager > CreateServicesAsync ( string root , InterpreterConfiguration configuration , string stubCacheFolderPath = null , IServiceManager sm = null , string [ ] searchPaths = null ) {
64
65
configuration = configuration ?? PythonVersions . LatestAvailable ;
65
66
configuration . AssertInstalled ( ) ;
66
67
stubCacheFolderPath = stubCacheFolderPath ?? TestData . GetAstAnalysisCachePath ( configuration . Version , true ) ;
67
68
Trace . TraceInformation ( "Cache Path: " + stubCacheFolderPath ) ;
68
- configuration . SearchPaths = new [ ] { GetAnalysisTestDataFilesPath ( ) } ;
69
+ configuration . SearchPaths = searchPaths ?? new [ ] { GetAnalysisTestDataFilesPath ( ) } ;
69
70
configuration . TypeshedPath = TestData . GetDefaultTypeshedPath ( ) ;
70
71
71
72
sm = sm ?? CreateServiceManager ( ) ;
72
73
73
- var clientApp = Substitute . For < IClientApplication > ( ) ;
74
- sm . AddService ( clientApp ) ;
75
-
76
- var idle = Substitute . For < IIdleTimeService > ( ) ;
77
- sm . AddService ( idle ) ;
74
+ sm . AddService ( Substitute . For < IClientApplication > ( ) )
75
+ . AddService ( Substitute . For < IIdleTimeService > ( ) ) ;
78
76
79
77
var ds = GetDiagnosticsService ( Services ) ;
80
78
if ( ds != null ) {
@@ -90,8 +88,7 @@ protected async Task<IServiceManager> CreateServicesAsync(string root, Interpret
90
88
sm . AddService ( interpreter ) ;
91
89
92
90
TestLogger . Log ( TraceEventType . Information , "Create RunningDocumentTable" ) ;
93
- var documentTable = new RunningDocumentTable ( sm ) ;
94
- sm . AddService ( documentTable ) ;
91
+ sm . AddService ( new RunningDocumentTable ( sm ) ) ;
95
92
96
93
return sm ;
97
94
}
0 commit comments