當前位置: 首頁>>代碼示例>>C#>>正文


C# Python.PythonVisualStudioApp類代碼示例

本文整理匯總了C#中TestUtilities.UI.Python.PythonVisualStudioApp的典型用法代碼示例。如果您正苦於以下問題:C# PythonVisualStudioApp類的具體用法?C# PythonVisualStudioApp怎麽用?C# PythonVisualStudioApp使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


PythonVisualStudioApp類屬於TestUtilities.UI.Python命名空間,在下文中一共展示了PythonVisualStudioApp類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的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


注:本文中的TestUtilities.UI.Python.PythonVisualStudioApp類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。