internal async Task CompareBaselineAndRestoreAsync(ModuleModel model, IPythonModule m) { //var json = ToJson(model); //Baseline.CompareToFile(BaselineFileName, json); // In real case dependency analysis will restore model dependencies. // Here we don't go through the dependency analysis so we have to // manually restore dependent modules. var dc = new DependencyCollector(m); dc.AddImports(model.Imports); dc.AddFromImports(model.FromImports); foreach (var dep in dc.Dependencies) { m.Interpreter.ModuleResolution.GetOrLoadModule(dep.Name); } var dcs = new DependencyCollector(m, true); dcs.AddImports(model.StubImports); dcs.AddFromImports(model.StubFromImports); foreach (var dep in dcs.Dependencies) { m.Interpreter.TypeshedResolution.GetOrLoadModule(dep.Name); } var analyzer = Services.GetService <IPythonAnalyzer>(); await analyzer.WaitForCompleteAnalysisAsync(); using (var dbModule = CreateDbModule(model, m.FilePath)) { dbModule.Should().HaveSameMembersAs(m); } }
public DependencyProvider(IPythonModule module, ModuleModel model) { var dc = new DependencyCollector(module); dc.AddImports(model.Imports); dc.AddFromImports(model.FromImports); _dependencies = dc.Dependencies; }