internal virtual ReplWindowProxy Prepare(
            bool enableAttach = false,
            bool useIPython   = false,
            bool addNewLineAtEndOfFullyTypedWord = false
            )
        {
            var s = Settings;

            if (s.Version == null)
            {
                Assert.Inconclusive("Interpreter missing for " + GetType().Name);
            }

            if (enableAttach != s.EnableAttach)
            {
                s = object.ReferenceEquals(s, Settings) ? s.Clone() : s;
                s.EnableAttach = enableAttach;
            }
            if (addNewLineAtEndOfFullyTypedWord != s.AddNewLineAtEndOfFullyTypedWord)
            {
                s = object.ReferenceEquals(s, Settings) ? s.Clone() : s;
                s.AddNewLineAtEndOfFullyTypedWord = addNewLineAtEndOfFullyTypedWord;
            }
            if (useIPython)
            {
                s = object.ReferenceEquals(s, Settings) ? s.Clone() : s;
                s.PrimaryPrompt         = ">>> ";
                s.UseInterpreterPrompts = false;
            }

            return(ReplWindowProxy.Prepare(s, useIPython: useIPython));
        }
Esempio n. 2
0
        private void RunOne(string filename, params SendToStep[] inputs)
        {
            using (var app = new PythonVisualStudioApp()) {
                var project = app.OpenProject(@"TestData\SendToInteractive.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(new ReplWindowPython35Tests().Settings, 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);
                }
            }
        }
Esempio n. 3
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);
            }
        }
        internal virtual ReplWindowProxy Prepare(
            bool enableAttach = false,
            bool useIPython   = false,
            bool addNewLineAtEndOfFullyTypedWord = false
            )
        {
            var s = Settings;

            if (s.Version == null)
            {
                Assert.Inconclusive("Interpreter missing for " + GetType().Name);
            }

            if (enableAttach != s.EnableAttach)
            {
                s = s.Clone();
                s.EnableAttach = enableAttach;
            }
            if (addNewLineAtEndOfFullyTypedWord != s.AddNewLineAtEndOfFullyTypedWord)
            {
                s = s.Clone();
                s.AddNewLineAtEndOfFullyTypedWord = addNewLineAtEndOfFullyTypedWord;
            }

            return(ReplWindowProxy.Prepare(s, useIPython: useIPython));
        }
Esempio n. 5
0
        private static void Run(PythonVisualStudioApp app, SendToStep[] inputs, ReplWindowProxySettings settings, EditorWindow doc, EnvDTE.Window window, string projectName = null, string workspaceName = null)
        {
            window.Activate();
            doc.MoveCaret(new SnapshotPoint(doc.TextView.TextBuffer.CurrentSnapshot, 0));
            app.WaitForCommandAvailable("Python.SendSelectionToInteractive", TimeSpan.FromSeconds(15));

            var interactive = ReplWindowProxy.Prepare(app, settings, projectName, workspaceName, 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);
            }
        }