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


C# PythonVisualStudioApp.OpenProject方法代码示例

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


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

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

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

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

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

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

示例6: DefaultBaseInterpreterSelection

        public void DefaultBaseInterpreterSelection() {
            // The project that will be loaded references these environments.
            PythonPaths.Python27.AssertInstalled();
            PythonPaths.Python33.AssertInstalled();

            using (var app = new PythonVisualStudioApp())
            using (var dis = Init(app)) {
                var project = app.OpenProject(@"TestData\Environments.sln");

                app.OpenSolutionExplorer().SelectProject(project);
                app.Dte.ExecuteCommand("Python.ActivateEnvironment", "/env:\"Python 2.7\"");

                using (var createVenv = AutomationDialog.FromDte(app, "Python.AddVirtualEnvironment")) {
                    var baseInterp = new ComboBox(createVenv.FindByAutomationId("BaseInterpreter")).GetSelectedItemName();

                    Assert.AreEqual("Python 2.7", baseInterp);
                    createVenv.Cancel();
                }

                app.Dte.ExecuteCommand("Python.ActivateEnvironment", "/env:\"Python 3.3\"");

                using (var createVenv = AutomationDialog.FromDte(app, "Python.AddVirtualEnvironment")) {
                    var baseInterp = new ComboBox(createVenv.FindByAutomationId("BaseInterpreter")).GetSelectedItemName();

                    Assert.AreEqual("Python 3.3", baseInterp);
                    createVenv.Cancel();
                }
            }
        }
开发者ID:KaushikCh,项目名称:PTVS,代码行数:29,代码来源:VirtualEnvTests.cs

示例7: ExtensionReference

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

                app.OpenSolutionExplorer();
                var solutionTree = app.SolutionExplorerTreeView;

                var dbPath = Path.Combine(
                    Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData),
                    "Python Tools",
                    "ReferencesDB",
#if DEBUG
                    "Debug",
#endif
                    AssemblyVersionInfo.VSVersion
                );
                var existingFiles = Directory.GetFiles(dbPath, "spam*");

                // open the solution, add a reference to our spam.pyd Python extension module
                var folderNode = solutionTree.FindItem(
                    "Solution 'ExtensionReference' (1 project)",
                    "ExtensionReference",
                    SR.GetString(SR.ReferencesNodeName)
                );
                folderNode.Select();
                var dialog = new AddReferenceDialog(AutomationElement.FromHandle(app.OpenDialogWithDteExecuteCommand("Project.AddReference")));
                dialog.ActivateBrowseTab();

                dialog.BrowseFilename = TestData.GetPath(@"TestData\spam.pyd");
                dialog.ClickOK();

                app.WaitForDialogDismissed();

                // make sure the reference got added
                var spamItem = solutionTree.WaitForItem(
                    "Solution 'ExtensionReference' (1 project)",
                    "ExtensionReference",
                    SR.GetString(SR.ReferencesNodeName),
                    "spam.pyd"
                );
                Assert.IsNotNull(spamItem);

                // wait for scraping to complete
                for (int retries = 10;
                    Directory.GetFiles(dbPath, "spam*").Length == existingFiles.Length && retries > 0;
                    --retries) {
                    System.Threading.Thread.Sleep(1000);
                }

                Assert.AreNotEqual(existingFiles.Length, Directory.GetFiles(dbPath, "spam*").Length, "File was not scraped");

                // now open a file and make sure we get completions against the spam module
                var item = project.ProjectItems.Item("Program.py");
                var window = item.Open();
                window.Activate();

                var doc = app.GetDocument(item.Document.FullName);

                doc.MoveCaret(doc.TextView.TextBuffer.CurrentSnapshot.GetLineFromLineNumber(1).Start);

                Keyboard.Type("spam.");

                using (var sh = doc.WaitForSession<ICompletionSession>()) {
                    var completion = sh.Session.CompletionSets.First().Completions.Select(x => x.InsertionText).FirstOrDefault(x => x == "system");
                    Assert.IsNotNull(completion);
                }

                // now clear the text we just typed
                for (int i = 0; i < 5; i++) {
                    Keyboard.Type(Key.Back);
                }

                // remove the extension
                app.Dte.Solution.Projects.Item(1).ProjectItems.Item("References").ProjectItems.Item(@"spam.pyd").Remove();

                // make sure it got removed
                solutionTree.WaitForItemRemoved(
                    "Solution 'ExtensionReference' (1 project)",
                    "ExtensionReference",
                    SR.GetString(SR.ReferencesNodeName),
                    "spam.pyd"
                );

                window.Activate();

                // and make sure we no longer offer completions on the spam module.
                Keyboard.Type("spam.");

                using (var sh = doc.WaitForSession<ICompletionSession>()) {
                    var completion = sh.Session.CompletionSets.First().Completions.Select(x => x.DisplayText).Single();
                    Assert.AreEqual(SR.GetString(SR.NoCompletionsCompletion), completion);
                }
            }
        }
开发者ID:wenh123,项目名称:PTVS,代码行数:94,代码来源:UITests.cs

示例8: TransferItem

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

                string filename, basename;
                int i = 0;
                do {
                    i++;
                    basename = "test" + i + " .py";
                    filename = Path.Combine(TestData.GetTempPath(), basename);
                } while (System.IO.File.Exists(filename));

                System.IO.File.WriteAllText(filename, "def f(): pass");

                var fileWindow = app.Dte.ItemOperations.OpenFile(filename);

                using (var dialog = ChooseLocationDialog.FromDte(app)) {
                    dialog.SelectProject("HelloWorld");
                    dialog.OK();
                }

                app.OpenSolutionExplorer().WaitForChildOfProject(project, basename);

                Assert.AreEqual(basename, fileWindow.Caption);

                System.IO.File.Delete(filename);
            }
        }
开发者ID:wenh123,项目名称:PTVS,代码行数:28,代码来源:UITests.cs

示例9: AddExistingItem

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

                app.OpenSolutionExplorer().SelectProject(project);

                using (var addExistingDlg = AddExistingItemDialog.FromDte(app)) {
                    addExistingDlg.FileName = TestData.GetPath(@"TestData\AddExistingItem\Program2.py");
                    addExistingDlg.Add();
                }
                app.OpenSolutionExplorer().WaitForChildOfProject(project, "Program2.py");
            }
        }
开发者ID:wenh123,项目名称:PTVS,代码行数:13,代码来源:UITests.cs

示例10: DjangoIncludeInProject

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

                app.OpenSolutionExplorer();
                var window = app.SolutionExplorerTreeView;

                app.Dte.ExecuteCommand("Project.ShowAllFiles"); // start showing all

                var folderNode = window.WaitForItem("Solution 'DjangoApplication' (1 project)", "DjangoApplication", "Folder");
                Mouse.MoveTo(folderNode.GetClickablePoint());
                Mouse.Click(MouseButton.Right);

                Keyboard.Type("j"); // Exclude from Project
                app.Dte.ExecuteCommand("Project.ShowAllFiles"); // stop showing all

                Assert.IsNull(window.WaitForItemRemoved("Solution 'DjangoApplication' (1 project)", "DjangoApplication", "notinproject.py"));
                Assert.IsNotNull(window.WaitForItem("Solution 'DjangoApplication' (1 project)", "DjangoApplication", "Folder", "test.py"));
            }
        }
开发者ID:wenh123,项目名称:PTVS,代码行数:20,代码来源:UITests.cs

示例11: MultiSelectCopyAndPaste

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

                app.OpenSolutionExplorer();
                var window = app.SolutionExplorerTreeView;

                var files = new[] { "BreakAllTest.py", "BreakpointTest.py", "BreakpointTest2.py" };
                bool anySelected = false;
                foreach (var f in files) {
                    var node = window.FindItem("Solution 'DebuggerProject' (1 project)", "DebuggerProject", f);
                    Assert.IsNotNull(node, f + " not found in DebuggerProject");
                    if (anySelected) {
                        ((SelectionItemPattern)node.GetCurrentPattern(SelectionItemPattern.Pattern)).AddToSelection();
                    } else {
                        node.Select();
                        anySelected = true;
                    }
                }
                Keyboard.ControlC();

                var projectNode = window.FindItem("Solution 'DebuggerProject' (1 project)", "DebuggerProject");

                AutomationWrapper.Select(projectNode);
                Keyboard.ControlV();

                foreach (var f in files.Select(f => f.Remove(f.LastIndexOf('.')) + " - Copy" + f.Substring(f.LastIndexOf('.')))) {
                    Assert.IsNotNull(
                        window.WaitForItem("Solution 'DebuggerProject' (1 project)", "DebuggerProject", f),
                        f + " not found after copying");
                }
            }
        }
开发者ID:wenh123,项目名称:PTVS,代码行数:33,代码来源:UITests.cs

示例12: LoadSearchPath

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

                // Ensure we complete analysis. VS may crash if the invalid
                // path is not handled correctly.
                project.GetPythonProject().GetAnalyzer().WaitForCompleteAnalysis(_ => true);

                var tree = app.OpenSolutionExplorer();

                const string sln = "Solution 'LoadSearchPaths' (1 project)";
                const string proj = "LoadSearchPaths";
                var sp = SR.GetString(SR.SearchPaths);

                // Entered in file as ..\AddSearchPaths\
                var path1 = tree.WaitForItem(sln, proj, sp, "..\\AddSearchPaths");
                Assert.IsNotNull(path1, "Could not find ..\\AddSearchPaths");

                // Entered in file as ..\HelloWorld
                var path2 = tree.WaitForItem(sln, proj, sp, "..\\HelloWorld");
                Assert.IsNotNull(path2, "Could not find ..\\HelloWorld");

                // Entered in file as ..\LoadSearchPaths\NotHere\..\ - resolves to .\
                var path3 = tree.WaitForItem(sln, proj, sp, ".");
                Assert.IsNotNull(path3, "Could not find .");

                // Entered in file as .\NotHere\
                var path4 = tree.WaitForItem(sln, proj, sp, "NotHere");
                Assert.IsNotNull(path4, "Could not find NotHere");
                Assert.AreEqual("NotHere", path4.Current.Name);

                AutomationWrapper.Select(path4);
                app.ExecuteCommand("Edit.Delete"); // should not prompt, https://pytools.codeplex.com/workitem/1233
                Assert.IsNull(tree.WaitForItemRemoved(sln, proj, sp, "NotHere"));

                // Entered in file as Invalid*Search?Path
                var path5 = tree.WaitForItem(sln, proj, sp, "Invalid*Search?Path");
                Assert.IsNotNull(path5, "Could not find Invalid*Search?Path");
                Assert.AreEqual(path5.Current.Name, "Invalid*Search?Path");

                AutomationWrapper.Select(path5);
                app.ExecuteCommand("Edit.Delete");
                Assert.IsNull(tree.WaitForItemRemoved(sln, proj, sp, "Invalid*Search?Path"));

                // Ensure NotHere hasn't come back
                path4 = tree.WaitForItem(sln, proj, sp, "NotHere");
                Assert.IsNull(path4, "NotHere came back");
            }
        }
开发者ID:wenh123,项目名称:PTVS,代码行数:49,代码来源:UITests.cs

示例13: AddSearchPathRelativePath

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

                app.OpenSolutionExplorer().SelectProject(project);

                using (var dialog = SelectFolderDialog.AddFolderToSearchPath(app)) {
                    dialog.FolderName = TestData.GetPath(@"TestData\Outlining");
                    dialog.SelectFolder();
                }

                app.ExecuteCommand("File.SaveAll");

                var text = File.ReadAllText(TestData.GetPath(@"TestData\AddSearchPaths\AddSearchPaths.pyproj"));
                string actual = Regex.Match(text, @"<SearchPath>.*</SearchPath>", RegexOptions.Singleline).Value;
                Assert.AreEqual("<SearchPath>..\\Outlining\\</SearchPath>", actual);
            }
        }
开发者ID:wenh123,项目名称:PTVS,代码行数:18,代码来源:UITests.cs

示例14: AddNewFolder

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

                app.OpenSolutionExplorer().SelectProject(project);

                app.ExecuteCommand("Project.NewFolder");
                Keyboard.Type("MyNewFolder");
                Keyboard.PressAndRelease(Key.Enter);

                app.OpenSolutionExplorer().WaitForChildOfProject(project, "MyNewFolder");
            }
        }
开发者ID:wenh123,项目名称:PTVS,代码行数:13,代码来源:UITests.cs

示例15: DragLeaveFolderTest

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

                // click on SubItem.py
                var point = window.FindChildOfProject(project, "TestFolder2", "SubFolder").Element.GetClickablePoint();
                Mouse.MoveTo(point);
                Mouse.Down(MouseButton.Left);

                // move to project and hover
                Mouse.MoveTo(window.FindChildOfProject(project).Element.GetClickablePoint());
                System.Threading.Thread.Sleep(500);

                // move back and release
                Mouse.MoveTo(point);
                Mouse.Up(MouseButton.Left);

                window.WaitForChildOfProject(project, "TestFolder2", "SubFolder");
            }
        }
开发者ID:wenh123,项目名称:PTVS,代码行数:21,代码来源:UITests.cs


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