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


C# PythonVisualStudioApp.GetOutputWindowText方法代码示例

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


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

示例1: 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


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