Exemplo n.º 1
0
        public void TestUndoRedirectStdout()
        {
            // open python console
            PythonConsoleWindow.ShowWindow();

            var prevContents = PythonConsoleWindow.s_window.m_outputContents;

            PythonConsoleWindow.s_window.m_outputContents = "";

            var msg       = "hello world";
            var pythonCmd = string.Format("print ('{0}')", msg);

            PythonRunner.RunString(pythonCmd);
            var output = PythonConsoleWindow.s_window.m_outputContents;

            Assert.That(output, Is.EqualTo(msg + "\n"));

            PythonRunner.UndoRedirectStdout();


            PythonConsoleWindow.s_window.m_outputContents = "";

            // stdout should no longer be redirected
            PythonRunner.RunString(pythonCmd);
            output = PythonConsoleWindow.s_window.m_outputContents;

            Assert.That(output, Is.Null.Or.Empty);

            PythonConsoleWindow.s_window.m_outputContents = prevContents;
            PythonConsoleWindow.s_window.Close();

            // redo stdout redirection
            PythonRunner.RedirectStdout();
        }
Exemplo n.º 2
0
        protected override void OnStartup(StartupEventArgs e)
        {
            base.OnStartup(e);
            PythonConsoleWindow w = new PythonConsoleWindow();

            w.ConsoleInitialized += WOnConsoleInitialized;
            MainWindow            = w;
            w.Show();
        }