use of com.python.pydev.analysis.additionalinfo.AdditionalSystemInterpreterInfo in project Pydev by fabioz.
the class InterpreterInfoBuilderTest method testInterpreterInfoBuilder.
public void testInterpreterInfoBuilder() throws Exception {
Collection<String> pythonpath = new ArrayList<String>();
pythonpath.add(libDir.toString());
final InterpreterInfo info = new InterpreterInfo("2.6", TestDependent.PYTHON2_EXE, pythonpath);
IEclipsePreferences preferences = new InMemoryEclipsePreferences();
final PythonInterpreterManager manager = new PythonInterpreterManager(preferences);
InterpreterManagersAPI.setPythonInterpreterManager(manager);
manager.setInfos(new IInterpreterInfo[] { info }, null, null);
final AdditionalSystemInterpreterInfo additionalInfo = new AdditionalSystemInterpreterInfo(manager, info.getExecutableOrJar());
AdditionalSystemInterpreterInfo.setAdditionalSystemInfo(manager, info.getExecutableOrJar(), additionalInfo);
// Don't load it (otherwise it'll get the 'proper' info).
// AdditionalSystemInterpreterInfo.loadAdditionalSystemInfo(manager, info.getExecutableOrJar());
final ISystemModulesManager modulesManager = info.getModulesManager();
assertEquals(0, modulesManager.getSize(false));
assertEquals(0, additionalInfo.getAllTokens().size());
InterpreterInfoBuilder builder = new InterpreterInfoBuilder();
builder.syncInfoToPythonPath(null, info);
int size = modulesManager.getSize(false);
if (size != 3) {
fail("Expected size = 3, found: " + size);
}
try {
AbstractAdditionalDependencyInfo additionalSystemInfo = AdditionalSystemInterpreterInfo.getAdditionalSystemInfo(manager, manager.getInterpreterInfos()[0].getExecutableOrJar(), true);
if (additionalInfo != additionalSystemInfo) {
throw new RuntimeException("Expecting it to be the same instance.");
}
} catch (MisconfigurationException e) {
throw new RuntimeException(e);
}
Collection<IInfo> allTokens = additionalInfo.getAllTokens();
size = allTokens.size();
if (size != 3) {
FastStringBuffer buf = new FastStringBuffer();
for (IInfo i : allTokens) {
buf.append(i.toString());
}
fail("Expected size = 3, found: " + size + "\nTokens: " + buf);
}
}
Aggregations