• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C# Python.PythonVisualStudioApp类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



PythonVisualStudioApp类属于TestUtilities.UI.Python命名空间,在下文中一共展示了PythonVisualStudioApp类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。

示例1: AutomaticBraceCompletion

        public void AutomaticBraceCompletion() {
            using (var app = new PythonVisualStudioApp()) {
                var project = app.OpenProject(@"TestData\AutomaticBraceCompletion.sln");

                bool oldState = EnableAutoBraceCompletion(app, true);
                app.OnDispose(() => EnableAutoBraceCompletion(app, oldState));

                // check that braces get auto completed
                AutoBraceCompetionTest(app, project, "foo(", "foo()");
                AutoBraceCompetionTest(app, project, "foo[", "foo[]");
                AutoBraceCompetionTest(app, project, "foo{", "foo{}");
                AutoBraceCompetionTest(app, project, "\"foo", "\"foo\"");
                AutoBraceCompetionTest(app, project, "'foo", "'foo'");

                // check that braces get not autocompleted in comments and strings
                AutoBraceCompetionTest(app, project, "\"foo(\"", "\"foo(\"");
                AutoBraceCompetionTest(app, project, "#foo(", "#foo(");
                AutoBraceCompetionTest(app, project, "\"\"\"\rfoo(\r\"\"\"\"", "\"\"\"\r\nfoo(\r\n\"\"\"\"");

                // check that end braces gets skiped
                AutoBraceCompetionTest(app, project, "foo(bar)", "foo(bar)");
                AutoBraceCompetionTest(app, project, "foo[bar]", "foo[bar]");
                AutoBraceCompetionTest(app, project, "foo{bar}", "foo{bar}");
                AutoBraceCompetionTest(app, project, "\"foo\"", "\"foo\"");
                AutoBraceCompetionTest(app, project, "'foo'", "'foo'");
                AutoBraceCompetionTest(app, project, "foo({[\"\"]})", "foo({[\"\"]})");
            }
        }
开发者ID:jsschultz,项目名称:PTVS,代码行数:28,代码来源:EditorTests.cs


示例2: ToggleableOptionTest

        public void ToggleableOptionTest() {
            using (var app = new PythonVisualStudioApp()) {
                var pyService = app.ServiceProvider.GetPythonToolsService();
                pyService.SetFormattingOption("SpaceBeforeClassDeclarationParen", true);
                foreach (var expectedResult in new bool?[] { false, null, true }) {
                    using (var dialog = ToolsOptionsDialog.FromDte(app)) {
                        dialog.SelectedView = "Text Editor/Python/Formatting/Spacing";
                        var spacingView = FormattingOptionsTreeView.FromDialog(dialog);

                        var value = spacingView.WaitForItem(
                            "Class Definitions",
                            "Insert space between a class declaration's name and bases list"
                        );
                        Assert.IsNotNull(value, "Did not find item");

                        value.SetFocus();
                        Mouse.MoveTo(value.GetClickablePoint());
                        Mouse.Click(System.Windows.Input.MouseButton.Left);

                        dialog.OK();

                        Assert.AreEqual(
                            expectedResult,
                            pyService.GetFormattingOption("SpaceBeforeClassDeclarationParen")
                        );
                    }
                }
            }
        }
开发者ID:sadapple,项目名称:PTVS,代码行数:29,代码来源:FormattingUITests.cs


示例3: CheckCommandLineArgs

        private static void CheckCommandLineArgs(string setValue, string expectedValue = null) {
            using (var app = new PythonVisualStudioApp()) {
                var project = app.OpenProject(@"TestData\CheckCommandLineArgs.sln");

                var proj = project.GetCommonProject() as IPythonProject;
                Assert.IsNotNull(proj);

                var outFile = Path.Combine(Path.GetDirectoryName(project.FullName), "output.txt");

                foreach (var cmdName in new[] { "PythonRunWebServerCommand", "PythonDebugWebServerCommand" }) {
                    Console.WriteLine("Testing {0}, writing to {1}", cmdName, outFile);

                    if (File.Exists(outFile)) {
                        File.Delete(outFile);
                    }

                    app.ServiceProvider.GetUIThread().Invoke(() => {
                        proj.SetProperty("CommandLineArguments", string.Format("\"{0}\" \"{1}\"", setValue, outFile));
                        proj.FindCommand(cmdName).Execute(proj);
                    });

                    for (int retries = 10; retries > 0 && !File.Exists(outFile); --retries) {
                        Thread.Sleep(100);
                    }

                    Assert.AreEqual(expectedValue ?? setValue, File.ReadAllText(outFile).Trim());
                }
            }
        }
开发者ID:jsschultz,项目名称:PTVS,代码行数:29,代码来源:WebProjectTests.cs


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


示例5: ExecuteInReplSysArgv

        public virtual void ExecuteInReplSysArgv() {
            using (var app = new PythonVisualStudioApp()) {
                var project = app.OpenProject(@"TestData\SysArgvRepl.sln");

                using (var interactive = app.ExecuteInInteractive(project)) {
                    interactive.WaitForTextEnd("Program.py']", ">");
                }
            }
        }
开发者ID:zooba,项目名称:PTVS,代码行数:9,代码来源:ReplWindowPythonSmokeTests.cs


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


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


示例8: UnregisteredFileExtensionEditor

        public void UnregisteredFileExtensionEditor() {
            using (var app = new PythonVisualStudioApp()) {
                var project = app.OpenProject(@"TestData\UnregisteredFileExtension.sln");

                var item = project.ProjectItems.Item("Fob.unregfileext");
                var window = item.Open();
                window.Activate();

                var doc = app.GetDocument(item.Document.FullName);
                var snapshot = doc.TextView.TextBuffer.CurrentSnapshot;

                // we shouldn't have opened this as a .py file, so we should have no classifications.
                var classifier = doc.Classifier;
                var spans = classifier.GetClassificationSpans(new SnapshotSpan(snapshot, 0, snapshot.Length));
                Assert.AreEqual(spans.Count, 0);
            }
        }
开发者ID:omnimark,项目名称:PTVS,代码行数:17,代码来源:EditorTests.cs


示例9: DefaultInterpreterSelected

        public void DefaultInterpreterSelected() {
            using (var app = new PythonVisualStudioApp()) {
                var service = app.InterpreterService;
                var originalDefault = service.DefaultInterpreter;

                try {
                    foreach (var interpreter in service.Interpreters) {
                        service.DefaultInterpreter = interpreter;
                        using (var dialog = app.LaunchPythonProfiling()) {
                            Assert.AreEqual(interpreter.Description, dialog.SelectedInterpreter);
                        }
                        app.WaitForDialogDismissed();
                    }
                } finally {
                    service.DefaultInterpreter = originalDefault;
                }
            }
        }
开发者ID:wenh123,项目名称:PTVS,代码行数:18,代码来源:ProfilingTests.cs


示例10: LoadWebFlavoredProject

        public void LoadWebFlavoredProject() {
            using (var app = new PythonVisualStudioApp()) {
                var project = app.OpenProject(@"TestData\EmptyWebProject.sln");
                Assert.AreEqual("EmptyWebProject.pyproj", Path.GetFileName(project.FileName), "Wrong project file name");

                var catids = app.Dte.ObjectExtenders.GetContextualExtenderCATIDs();
                dynamic extender = project.Extender["WebApplication"];
                Assert.IsNotNull(extender, "No WebApplication extender");
                extender.StartWebServerOnDebug = true;
                extender.StartWebServerOnDebug = false;

                var proj = project.GetCommonProject();
                var ccp = proj as IPythonProject;
                Assert.IsNotNull(ccp);
                Assert.IsNotNull(ccp.FindCommand("PythonRunWebServerCommand"), "No PythonRunWebServerCommand");
                Assert.IsNotNull(ccp.FindCommand("PythonDebugWebServerCommand"), "No PythonDebugWebServerCommand");
            }
        }
开发者ID:jsschultz,项目名称:PTVS,代码行数:18,代码来源:WebProjectTests.cs


示例11: DeferredSaveWithDot

        public void DeferredSaveWithDot() {
            string fullname;
            using (var app = new PythonVisualStudioApp()) {
                // http://pytools.codeplex.com/workitem/623
                // enable deferred saving on projects
                var props = app.Dte.get_Properties("Environment", "ProjectsAndSolution");
                var prevValue = props.Item("SaveNewProjects").Value;
                props.Item("SaveNewProjects").Value = false;
                app.OnDispose(() => { props.Item("SaveNewProjects").Value = prevValue; });


                using (var newProjDialog = app.FileNewProject()) {
                    newProjDialog.FocusLanguageNode();

                    var consoleApp = newProjDialog.ProjectTypes.FindItem("Python Application");
                    consoleApp.Select();
                    newProjDialog.ProjectName = "Fob.Oar";
                    newProjDialog.OK();
                }

                // wait for new solution to load...
                for (int i = 0; i < 100 && app.Dte.Solution.Projects.Count == 0; i++) {
                    System.Threading.Thread.Sleep(1000);
                }

                using (var saveDialog = AutomationDialog.FromDte(app, "File.SaveAll")) {
                    saveDialog.ClickButtonAndClose("Save");
                }

                fullname = app.Dte.Solution.FullName;
            }

            try {
                // Delete the created directory after the solution has been
                // closed.
                Directory.Delete(Path.GetDirectoryName(fullname), true);
            } catch {
            }
        }
开发者ID:wenh123,项目名称:PTVS,代码行数:39,代码来源:UITests.cs


示例12: InstallUninstallPackage

        public void InstallUninstallPackage() {
            using (var app = new PythonVisualStudioApp())
            using (var dis = Init(app)) {
                var project = CreateTemporaryProject(app);

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

                using (var installPackage = AutomationDialog.FromDte(app, "Python.InstallPackage")) {
                    var packageName = new TextBox(installPackage.FindByAutomationId("Name"));
                    packageName.SetValue("azure==0.6.2");
                    installPackage.ClickButtonAndClose("OK", nameIsAutomationId: true);
                }

                var azure = app.SolutionExplorerTreeView.WaitForChildOfProject(
                    project,
                    SR.GetString(SR.Environments),
                    envName,
                    "azure (0.6.2)"
                );

                azure.Select();

                using (var confirmation = AutomationDialog.FromDte(app, "Edit.Delete")) {
                    confirmation.OK();
                }

                app.SolutionExplorerTreeView.WaitForChildOfProjectRemoved(
                    project,
                    SR.GetString(SR.Environments),
                    envName,
                    "azure (0.6.2)"
                );
            }
        }
开发者ID:KaushikCh,项目名称:PTVS,代码行数:36,代码来源:VirtualEnvTests.cs


示例13: DjangoCollectStaticFilesCommand

        public void DjangoCollectStaticFilesCommand() {
            using (var app = new PythonVisualStudioApp()) {
                var service = app.GetService<IComponentModel>(typeof(SComponentModel)).GetService<IInterpreterOptionsService>();

                var envWithDjango = service.Interpreters.LastOrDefault(env => env.FindModulesAsync("django").WaitAndUnwrapExceptions().Contains("django"));
                if (envWithDjango == null) {
                    Assert.Inconclusive("No available environments have Django installed");
                }

                using (var dis = new DefaultInterpreterSetter(envWithDjango)) {
                    var project = app.OpenProject("TestData\\DjangoApplication1\\DjangoApplication1.sln");
                    app.SolutionExplorerTreeView.SelectProject(project);

                    app.Dte.ExecuteCommand("Project.CollectStaticFiles");

                    var console = app.GetInteractiveWindow("Django Management Console - " + project.Name);
                    Assert.IsNotNull(console);

                    console.WaitForTextEnd("The Python REPL process has exited", ">>> ");

                    Assert.IsTrue(console.Text.Contains("0 static files copied"));
                }
            }
        }
开发者ID:wenh123,项目名称:PTVS,代码行数:24,代码来源:DjangoProjectTests.cs


示例14: CustomCommandsRunProcessInOutput

        public void CustomCommandsRunProcessInOutput() {
            using (var app = new PythonVisualStudioApp()) {
                PythonProjectNode node;
                EnvDTE.Project proj;
                OpenProject(app, "Commands3.sln", out node, out proj);

                Execute(node, "Write to Output");

                var outputWindow = app.Element.FindFirst(TreeScope.Descendants,
                    new AndCondition(
                        new PropertyCondition(AutomationElement.ClassNameProperty, "GenericPane"),
                        new PropertyCondition(AutomationElement.NameProperty, "Output")
                    )
                );
                Assert.IsNotNull(outputWindow, "Output Window was not opened");

                ExpectOutputWindowText(app, string.Format("({0}, {1})", PythonVersion.Configuration.Version.Major, PythonVersion.Configuration.Version.Minor));
            }
        }
开发者ID:jsschultz,项目名称:PTVS,代码行数:19,代码来源:BuildTasksUITests.cs


示例15: CustomCommandsRunProcessInRepl

        public void CustomCommandsRunProcessInRepl() {
            using (var app = new PythonVisualStudioApp()) {
                PythonProjectNode node;
                EnvDTE.Project proj;
                OpenProject(app, "Commands3.sln", out node, out proj);

                Execute(node, "Write to Repl");

                using (var repl = app.GetInteractiveWindow("Test Repl")) {
                    Assert.IsNotNull(repl, "Could not find repl window");
                    repl.WaitForTextEnd(
                        string.Format("({0}, {1})", PythonVersion.Configuration.Version.Major, PythonVersion.Configuration.Version.Minor),
                        ">"
                    );
                }
            }
        }
开发者ID:jsschultz,项目名称:PTVS,代码行数:17,代码来源:BuildTasksUITests.cs


示例16: CustomCommandsRunInRepl

        public void CustomCommandsRunInRepl() {
            using (var app = new PythonVisualStudioApp()) {
                PythonProjectNode node;
                EnvDTE.Project proj;
                OpenProject(app, "Commands1.sln", out node, out proj);

                Execute(node, "Test Command 2");

                using (var repl = app.GetInteractiveWindow("Test Repl")) {
                    Assert.IsNotNull(repl, "Could not find repl window");
                    repl.WaitForTextEnd(
                        "Program.py completed",
                        ">"
                    );
                }

                app.Dte.Solution.Close();

                using (var repl = app.GetInteractiveWindow("Test Repl")) {
                    Assert.IsNull(repl, "Repl window was not closed");
                }
            }
        }
开发者ID:jsschultz,项目名称:PTVS,代码行数:23,代码来源:BuildTasksUITests.cs


示例17: CustomCommandsReplWithResourceLabel

        public void CustomCommandsReplWithResourceLabel() {
            using (var app = new PythonVisualStudioApp()) {
                PythonProjectNode node;
                EnvDTE.Project proj;
                OpenProject(app, "Commands2.sln", out node, out proj);

                Execute(node, "Command from Resource");

                using (var repl = app.GetInteractiveWindow("Repl from Resource")) {
                    Assert.IsNotNull(repl, "Could not find repl window");
                    repl.WaitForTextEnd(
                        "Program.py completed",
                        ">"
                    );
                }

                using (var repl = app.GetInteractiveWindow("resource:PythonToolsUITests;PythonToolsUITests.Resources;ReplName")) {
                    Assert.IsNull(repl);
                }
            }
        }
开发者ID:jsschultz,项目名称:PTVS,代码行数:21,代码来源:BuildTasksUITests.cs


示例18: VirtualEnvironmentReplWorkingDirectory

        public void VirtualEnvironmentReplWorkingDirectory() {
            using (var app = new PythonVisualStudioApp())
            using (var dis = Init(app)) {
                var project = CreateTemporaryProject(app);

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

                EnvironmentReplWorkingDirectoryTest(app, project, env, envName);
            }
        }
开发者ID:KaushikCh,项目名称:PTVS,代码行数:11,代码来源:VirtualEnvTests.cs


示例19: EnvironmentReplWorkingDirectory

        public void EnvironmentReplWorkingDirectory() {
            using (var app = new PythonVisualStudioApp())
            using (var dis = Init(app)) {
                var project = CreateTemporaryProject(app);

                app.ServiceProvider.GetUIThread().Invoke(() => {
                    var pp = project.GetPythonProject();
                    pp.Interpreters.AddInterpreter(dis.CurrentDefault);
                });

                var envName = dis.CurrentDefault.Description;
                var sln = app.OpenSolutionExplorer();
                var env = sln.FindChildOfProject(project, SR.GetString(SR.Environments), envName);

                EnvironmentReplWorkingDirectoryTest(app, project, env, envName);
            }
        }
开发者ID:KaushikCh,项目名称:PTVS,代码行数:17,代码来源:VirtualEnvTests.cs


示例20: Init

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



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# Tests.DnaTestURLRequest类代码示例发布时间:2022-05-26
下一篇:
C# SharedProject.ProjectDefinition类代码示例发布时间:2022-05-26
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap