示例#1
0
        private void RunFromWorkspace(PythonVisualStudioApp app, string filename, params SendToStep[] inputs)
        {
            PythonPaths.Python27_x64.AssertInstalled();
            PythonPaths.Python37_x64.AssertInstalled();

            // Set global default to 2.7 (different than workspace setting) to avoid false positive
            using (var defaultInterpreterSetter = app.SelectDefaultInterpreter(PythonPaths.Python27_x64)) {
                // "SendToInteractiveWorkspace" workspace uses Python 3.7 64-bit
                var settings = ReplWindowSettings.FindSettingsForInterpreter("Python37_x64");

                // Create a directory structure where we have a search path
                // folder located outside of the workspace folder.
                var    parentFolder     = TestData.GetTempPath();
                string workspaceFolder  = Path.Combine(parentFolder, "SendToInteractiveWorkspace");
                string searchPathFolder = Path.Combine(parentFolder, "SendToInteractiveWorkspaceSearchPath");
                FileUtils.CopyDirectory(TestData.GetPath("TestData", "SendToInteractiveWorkspace"), workspaceFolder);
                FileUtils.CopyDirectory(TestData.GetPath("TestData", "SendToInteractiveWorkspaceSearchPath"), searchPathFolder);

                var provider = app.ComponentModel.GetService <IPythonWorkspaceContextProvider>();
                using (var initEvent = new AutoResetEvent(false)) {
                    provider.WorkspaceInitialized += (sender, e) => { initEvent.Set(); };

                    var documentFullPath = Path.Combine(workspaceFolder, filename);
                    app.OpenFolder(workspaceFolder);
                    var doc    = app.OpenDocument(documentFullPath);
                    var window = app.OpenDocumentWindows.SingleOrDefault(w => PathUtils.IsSamePath(w.Document.FullName, documentFullPath));
                    Assert.IsNotNull(window, $"Could not get DTE window for {documentFullPath }");
                    Assert.IsTrue(initEvent.WaitOne(5000), $"Expected {nameof(provider.WorkspaceOpening)}.");

                    Run(app, inputs, settings, doc, window, workspaceName: "SendToInteractiveWorkspace");
                }
            }
        }
示例#2
0
        private void RunOne(PythonVisualStudioApp app, string filename, params SendToStep[] inputs)
        {
            // SendToInteractive.pyproj uses Python 3.5 32-bit
            var settings = ReplWindowSettings.FindSettingsForInterpreter("Python35");
            var sln      = app.CopyProjectForTest(@"TestData\SendToInteractive.sln");
            var project  = app.OpenProject(sln);
            var program  = project.ProjectItems.Item(filename);
            var window   = program.Open();

            window.Activate();

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

            doc.MoveCaret(new SnapshotPoint(doc.TextView.TextBuffer.CurrentSnapshot, 0));

            var interactive = ReplWindowProxy.Prepare(app, settings, useIPython: false);

            interactive.ExecuteText("42").Wait();
            interactive.ClearScreen();

            WaitForText(interactive.TextView, ">>> ");

            var state = new StepState(interactive, app, doc, window);

            state.Content.Append(">>> ");

            foreach (var input in inputs)
            {
                input.Execute(state);
            }
        }
示例#3
0
        private void RunFromProject(PythonVisualStudioApp app, string filename, params SendToStep[] inputs)
        {
            PythonPaths.Python27_x64.AssertInstalled();
            PythonPaths.Python37_x64.AssertInstalled();

            // Set global default to 2.7 (different than workspace setting) to avoid false positive
            using (var defaultInterpreterSetter = app.SelectDefaultInterpreter(PythonPaths.Python27_x64)) {
                // SendToInteractive.pyproj uses Python 3.7 64-bit
                var settings = ReplWindowSettings.FindSettingsForInterpreter("Python37_x64");
                var sln      = app.CopyProjectForTest(@"TestData\SendToInteractive.sln");
                var project  = app.OpenProject(sln);
                var program  = project.ProjectItems.Item(filename);
                var window   = program.Open();
                window.Activate();
                var doc = app.GetDocument(program.Document.FullName);

                Run(app, inputs, settings, doc, window);
            }
        }