当前位置: 首页>>代码示例>>C#>>正文


C# PythonVisualStudioApp.SelectDefaultInterpreter方法代码示例

本文整理汇总了C#中TestUtilities.UI.Python.PythonVisualStudioApp.SelectDefaultInterpreter方法的典型用法代码示例。如果您正苦于以下问题:C# PythonVisualStudioApp.SelectDefaultInterpreter方法的具体用法?C# PythonVisualStudioApp.SelectDefaultInterpreter怎么用?C# PythonVisualStudioApp.SelectDefaultInterpreter使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在TestUtilities.UI.Python.PythonVisualStudioApp的用法示例。


在下文中一共展示了PythonVisualStudioApp.SelectDefaultInterpreter方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Init3

 static DefaultInterpreterSetter Init3(PythonVisualStudioApp app, bool installVirtualEnv = false) {
     return app.SelectDefaultInterpreter(
         PythonPaths.Python35 ?? PythonPaths.Python35_x64 ??
         PythonPaths.Python34 ?? PythonPaths.Python34_x64 ??
         PythonPaths.Python33 ?? PythonPaths.Python33_x64,
         installVirtualEnv ? "virtualenv" : null
     );
 }
开发者ID:KaushikCh,项目名称:PTVS,代码行数:8,代码来源:VirtualEnvTests.cs

示例2: Init

 static DefaultInterpreterSetter Init(PythonVisualStudioApp app) {
     var dis = app.SelectDefaultInterpreter(PythonPaths.Python27 ?? PythonPaths.Python27_x64);
     try {
         dis.CurrentDefault.PipInstall("-U virtualenv");
         var r = dis;
         dis = null;
         return r;
     } finally {
         dis?.Dispose();
     }
 }
开发者ID:jsschultz,项目名称:PTVS,代码行数:11,代码来源:VirtualEnvTests.cs

示例3: Init3

 static DefaultInterpreterSetter Init3(PythonVisualStudioApp app, bool installVirtualEnv = false) {
     var dis = app.SelectDefaultInterpreter(
         PythonPaths.Python35 ?? PythonPaths.Python35_x64 ??
         PythonPaths.Python34 ?? PythonPaths.Python34_x64 ??
         PythonPaths.Python33 ?? PythonPaths.Python33_x64
     );
     try {
         if (installVirtualEnv) {
             dis.CurrentDefault.PipInstall("-U virtualenv");
         }
         var r = dis;
         dis = null;
         return r;
     } finally {
         dis?.Dispose();
     }
 }
开发者ID:jsschultz,项目名称:PTVS,代码行数:17,代码来源:VirtualEnvTests.cs

示例4: CustomCommandsRequiredPackages

        public void CustomCommandsRequiredPackages() {
            using (var app = new PythonVisualStudioApp())
            using (var dis = app.SelectDefaultInterpreter(PythonVersion, "virtualenv")) {
                PythonProjectNode node;
                EnvDTE.Project proj;
                OpenProject(app, "CommandRequirePackages.sln", out node, out proj);

                string envName;
                var env = app.CreateVirtualEnvironment(proj, out envName);

                env.Select();
                app.Dte.ExecuteCommand("Python.ActivateEnvironment");
                // Ensure that no error dialog appears
                app.WaitForNoDialog(TimeSpan.FromSeconds(5.0));

                // First, execute the command and cancel it.
                var task = ExecuteAsync(node, "Require Packages");
                try {
                    var dialogHandle = app.WaitForDialog(task);
                    if (dialogHandle == IntPtr.Zero) {
                        if (task.IsFaulted && task.Exception != null) {
                            Assert.Fail("Unexpected exception in package install confirmation dialog:\n{0}", task.Exception);
                        } else {
                            Assert.AreNotEqual(IntPtr.Zero, dialogHandle);
                        }
                    }

                    using (var dialog = new AutomationDialog(app, AutomationElement.FromHandle(dialogHandle))) {
                        var label = dialog.FindByAutomationId("CommandLink_1000");
                        Assert.IsNotNull(label);

                        string expectedLabel =
                            "The following packages will be installed using pip:\r\n" +
                            "\r\n" +
                            "ptvsd\r\n" +
                            "azure==0.1"; ;
                        Assert.AreEqual(expectedLabel, label.Current.HelpText);

                        dialog.Cancel();
                        try {
                            task.Wait(1000);
                            Assert.Fail("Command was not canceled after dismissing the package install confirmation dialog");
                        } catch (AggregateException ex) {
                            if (!(ex.InnerException is TaskCanceledException)) {
                                throw;
                            }
                        }
                    }
                } finally {
                    if (!task.IsCanceled && !task.IsCompleted && !task.IsFaulted) {
                        if (task.Wait(10000)) {
                            task.Dispose();
                        }
                    } else {
                        task.Dispose();
                    }
                }

                // Then, execute command and allow it to proceed.
                task = ExecuteAsync(node, "Require Packages");
                try {
                    var dialogHandle = app.WaitForDialog(task);
                    if (dialogHandle == IntPtr.Zero) {
                        if (task.IsFaulted && task.Exception != null) {
                            Assert.Fail("Unexpected exception in package install confirmation dialog:\n{0}", task.Exception);
                        } else {
                            Assert.AreNotEqual(IntPtr.Zero, dialogHandle);
                        }
                    }

                    using (var dialog = new AutomationDialog(app, AutomationElement.FromHandle(dialogHandle))) {
                        dialog.ClickButtonAndClose("CommandLink_1000", nameIsAutomationId: true);
                    }
                    task.Wait();

                    var ver = PythonVersion.Version.ToVersion();
                    ExpectOutputWindowText(app, string.Format("pass {0}.{1}", ver.Major, ver.Minor));
                } finally {
                    if (!task.IsCanceled && !task.IsCompleted && !task.IsFaulted) {
                        if (task.Wait(10000)) {
                            task.Dispose();
                        }
                    } else {
                        task.Dispose();
                    }
                }
            }
        }
开发者ID:jsschultz,项目名称:PTVS,代码行数:88,代码来源:BuildTasksUITests.cs

示例5: Init

 static DefaultInterpreterSetter Init(PythonVisualStudioApp app, PythonVersion interp, bool install) {
     return app.SelectDefaultInterpreter(interp, install ? "virtualenv" : null);
 }
开发者ID:KaushikCh,项目名称:PTVS,代码行数:3,代码来源:VirtualEnvTests.cs

示例6: WebProjectBuildWarnings

        public void WebProjectBuildWarnings() {
            using (var app = new PythonVisualStudioApp())
            using (app.SelectDefaultInterpreter(PythonPaths.Python33 ?? PythonPaths.Python33_x64)) {
                var project = app.CreateProject(
                    PythonVisualStudioApp.TemplateLanguageName,
                    PythonVisualStudioApp.EmptyWebProjectTemplate,
                    TestData.GetTempPath(),
                    "WebProjectBuildWarnings"
                );

                var proj = project.GetPythonProject();
                Assert.IsNotNull(proj);
                Assert.AreEqual(new Version(3, 3), app.ServiceProvider.GetUIThread().Invoke(() => proj.GetLaunchConfigurationOrThrow().Interpreter.Version));

                for (int iteration = 0; iteration <= 2; ++iteration) {
                    var warnings = app.ServiceProvider.GetUIThread().Invoke(() => {
                        var buildPane = app.GetOutputWindow("Build");
                        buildPane.Clear();

                        project.DTE.Solution.SolutionBuild.Clean(true);
                        project.DTE.Solution.SolutionBuild.Build(true);

                        var text = app.GetOutputWindowText("Build");
                        Console.WriteLine(text);
                        return text.Split('\r', '\n')
                            .Select(s => Regex.Match(s, @"warning\s*:\s*(?<msg>.+)"))
                            .Where(m => m.Success)
                            .Select(m => m.Groups["msg"].Value)
                            .ToList();
                    });

                    Console.WriteLine("Warnings:{0}{1}", Environment.NewLine, string.Join(Environment.NewLine, warnings));
                    if (iteration < 2) {
                        Assert.IsNotNull(
                            warnings.FirstOrDefault(s => Regex.IsMatch(s, @"Python( 64-bit)? 3\.3 is not natively supported.+")),
                            "Missing \"not natively supported\" warning"
                        );
                    } else {
                        // Third time through, we've fixed this warning.
                        Assert.IsNull(
                            warnings.FirstOrDefault(s => Regex.IsMatch(s, @"Python( 64-bit)? 3\.3 is not natively supported.+")),
                            "Still recieved \"not natively supported\" warning"
                        );
                    }

                    if (iteration < 1) {
                        Assert.IsNotNull(
                            warnings.FirstOrDefault(s => Regex.IsMatch(s, "Using old configuration tools.+")),
                            "Missing \"old configuration tools\" warning"
                        );
                    } else {
                        // Second time through, we've fixed this warning.
                        Assert.IsNull(
                            warnings.FirstOrDefault(s => Regex.IsMatch(s, "Using old configuration tools.+")),
                            "Still received \"old configuration tools\" warning"
                        );
                    }


                    switch (iteration) {
                        case 0:
                            app.AddItem(project, PythonVisualStudioApp.TemplateLanguageName, PythonVisualStudioApp.WebRoleSupportTemplate, "bin");
                            break;
                        case 1:
                            var model = app.GetService<IComponentModel>(typeof(SComponentModel));
                            var interpreterService = model.GetService<IInterpreterRegistryService>();
                            var optionsService = model.GetService<IInterpreterOptionsService>();
                            var newInterpreter = interpreterService.FindInterpreter("Global|PythonCore|3.4|x86")
                                ?? interpreterService.FindInterpreter("Global|PythonCore|2.7|x86");
                            Assert.IsNotNull(newInterpreter);
                            optionsService.DefaultInterpreter = newInterpreter;
                            break;
                    }
                }
            }
        }
开发者ID:jsschultz,项目名称:PTVS,代码行数:76,代码来源:WebProjectTests.cs

示例7: FormattingTest

        /// <summary>
        /// Runs a single formatting test
        /// </summary>
        /// <param name="filename">The filename of the document to perform formatting in (lives in FormattingTests.sln)</param>
        /// <param name="selection">The selection to format, or null if formatting the entire document</param>
        /// <param name="expectedText">The expected source code after the formatting</param>
        /// <param name="changedSpans">The spans which should be marked as changed in the buffer after formatting</param>
        private static void FormattingTest(
            string filename,
            Span? selection,
            string expectedText,
            Span[] changedSpans,
            Func<PythonToolsService, object> updateSettings,
            Action<PythonToolsService, object> revertSettings,
            Version version = null
        ) {
            using (var app = new PythonVisualStudioApp())
            using (version == null ? null : app.SelectDefaultInterpreter(PythonPaths.Versions.FirstOrDefault(v => v.Version.ToVersion() >= version))) {
                var o = updateSettings?.Invoke(app.PythonToolsService);
                if (revertSettings != null) {
                    app.OnDispose(() => revertSettings(app.PythonToolsService, o));
                }

                var project = app.OpenProject(@"TestData\FormattingTests\FormattingTests.sln");
                var item = project.ProjectItems.Item(filename);
                var window = item.Open();
                window.Activate();
                var doc = app.GetDocument(item.Document.FullName);

                var aggFact = app.ComponentModel.GetService<IViewTagAggregatorFactoryService>();
                var changeTags = aggFact.CreateTagAggregator<ChangeTag>(doc.TextView);

                // format the selection or document
                if (selection == null) {
                    DoFormatDocument();
                } else {
                    doc.Invoke(() => doc.TextView.Selection.Select(new SnapshotSpan(doc.TextView.TextBuffer.CurrentSnapshot, selection.Value), false));
                    DoFormatSelection();
                }

                // verify the contents are correct
                string actual = null;
                int steady = 50;
                for (int i = 0; i < 100; i++) {
                    actual = doc.TextView.TextBuffer.CurrentSnapshot.GetText();

                    if (expectedText == actual) {
                        if (--steady <= 0) {
                            break;
                        }
                    } else {
                        steady = 50;
                    }
                    System.Threading.Thread.Sleep(100);
                }
                Assert.AreEqual(expectedText, actual);

                // verify the change tags are correct
                var snapshot = doc.TextView.TextBuffer.CurrentSnapshot;
                var tags = changeTags.GetTags(
                    new SnapshotSpan(
                        doc.TextView.TextBuffer.CurrentSnapshot,
                        new Span(0, doc.TextView.TextBuffer.CurrentSnapshot.Length)
                    )
                );
                List<Span> result = new List<Span>();
                foreach (var tag in tags) {
                    result.Add(
                        new Span(
                            tag.Span.Start.GetPoint(doc.TextView.TextBuffer.CurrentSnapshot, PositionAffinity.Successor).Value.Position,
                            tag.Span.End.GetPoint(doc.TextView.TextBuffer.CurrentSnapshot, PositionAffinity.Successor).Value.Position
                        )
                    );
                }

                // dump the spans for creating tests easier
                foreach (var span in result) {
                    Console.WriteLine(span);
                }

                Assert.AreEqual(result.Count, changedSpans.Length);
                for (int i = 0; i < result.Count; i++) {
                    Assert.AreEqual(result[i], changedSpans[i]);
                }
            }
        }
开发者ID:jsschultz,项目名称:PTVS,代码行数:86,代码来源:FormattingUITests.cs

示例8: ImportPresentThenAddThenRemoveReference

        public void ImportPresentThenAddThenRemoveReference() {
            var python = PythonPaths.Versions.LastOrDefault(p => p.Version.Is3x() && !p.Isx64);
            python.AssertInstalled();

            var vcproj = TestData.GetPath(@"TestData\ProjectReference\NativeModule\NativeModule.vcxproj");
            File.WriteAllText(vcproj, File.ReadAllText(vcproj)
                .Replace("$(PYTHON_INCLUDE)", Path.Combine(python.PrefixPath, "include"))
                .Replace("$(PYTHON_LIB)", Path.Combine(python.PrefixPath, "libs"))
            );

            using (var app = new PythonVisualStudioApp())
            using (app.SelectDefaultInterpreter(python)) {
                var project = app.OpenProject(@"TestData\ProjectReference\CProjectReference.sln", projectName: "PythonApplication2", expectedProjects: 2);

                var wnd = project.ProjectItems.Item("Program.py").Open();
                wnd.Activate();
                try {
                    app.Dte.Solution.SolutionBuild.Clean(true);

                    string text;
                    var items = app.WaitForErrorListItems(1);
                    Assert.AreEqual(1, items.Count);
                    Assert.AreEqual(0, items[0].get_Text(out text));
                    Assert.IsTrue(text.Contains("native_module"), text);

                    app.Dte.Solution.SolutionBuild.Build(true);

                    items = app.WaitForErrorListItems(0);
                    Assert.AreEqual(0, items.Count);
                } finally {
                    wnd.Close();
                }
            }
        }
开发者ID:omnimark,项目名称:PTVS,代码行数:34,代码来源:EditorTests.cs


注:本文中的TestUtilities.UI.Python.PythonVisualStudioApp.SelectDefaultInterpreter方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。