public void DefaultBaseInterpreterSelection(PythonVisualStudioApp app) { // The project that will be loaded references these environments. PythonPaths.Python27.AssertInstalled(); PythonPaths.Python37.AssertInstalled(); using (var dis = InitPython3(app)) { var sln = app.CopyProjectForTest(@"TestData\Environments.sln"); var project = app.OpenProject(sln); app.OpenSolutionExplorer().SelectProject(project); app.Dte.ExecuteCommand("Python.ActivateEnvironment", "/env:\"Python 2.7 (32-bit)\""); var environmentsNode = app.OpenSolutionExplorer().FindChildOfProject(project, Strings.Environments); environmentsNode.Select(); using (var createVenv = AddVirtualEnvironmentDialogWrapper.FromDte(app)) { var baseInterp = createVenv.BaseInterpreter; Assert.AreEqual("Python 2.7 (32-bit)", baseInterp); createVenv.Cancel(); } app.Dte.ExecuteCommand("Python.ActivateEnvironment", "/env:\"Python 3.7 (32-bit)\""); environmentsNode = app.OpenSolutionExplorer().FindChildOfProject(project, Strings.Environments); environmentsNode.Select(); using (var createVenv = AddVirtualEnvironmentDialogWrapper.FromDte(app)) { var baseInterp = createVenv.BaseInterpreter; Assert.AreEqual("Python 3.7 (32-bit)", baseInterp); createVenv.Cancel(); } } }
private void ApplyVirtualEnvironmentDialog(out string baseInterp, out string location, out string envName) { var dlg = AddVirtualEnvironmentDialogWrapper.FromDte(this); try { baseInterp = dlg.BaseInterpreter; location = dlg.Location; envName = dlg.EnvName; Console.WriteLine("Creating virtual env"); Console.WriteLine(" Name: {0}", envName); Console.WriteLine(" Location: {0}", location); Console.WriteLine(" Base Interpreter: {0}", baseInterp); dlg.WaitForReady(); dlg.ClickAdd(); } catch (Exception) { dlg.CloseWindow(); throw; } }
public TreeNode CreateVirtualEnvironment(EnvDTE.Project project, out string envName, out string envPath) { var environmentsNode = OpenSolutionExplorer().FindChildOfProject(project, Strings.Environments); environmentsNode.Select(); var dlg = AddVirtualEnvironmentDialogWrapper.FromDte(this); try { var baseInterp = dlg.BaseInterpreter; var location = dlg.Location; var name = dlg.EnvName; envName = "{0} ({1})".FormatUI(name, baseInterp); envPath = Path.Combine(location, name); Console.WriteLine("Expecting environment named: {0}", envName); dlg.WaitForReady(); dlg.ClickAdd(); } catch (Exception) { dlg.CloseWindow(); throw; } try { return(OpenSolutionExplorer().WaitForChildOfProject(project, TimeSpan.FromMinutes(5), Strings.Environments, envName)); } finally { var text = GetOutputWindowText("General"); if (!string.IsNullOrEmpty(text)) { Console.WriteLine("** Output Window text"); Console.WriteLine(text); Console.WriteLine("***"); Console.WriteLine(); } } }