public void BadInterpreterPath() { // http://pytools.codeplex.com/workitem/662 var replEval = new PythonInteractiveEvaluator(PythonToolsTestUtilities.CreateMockServiceProvider()) { DisplayName = "Test Interpreter", Configuration = new LaunchConfiguration(new VisualStudioInterpreterConfiguration("InvalidInterpreter", "Test Interpreter", pythonExePath: "C:\\Does\\Not\\Exist\\Some\\Interpreter.exe")) }; var replWindow = new MockReplWindow(replEval); replEval._Initialize(replWindow); var execute = replEval.ExecuteText("42"); var errorText = replWindow.Error; const string expected = "the associated Python environment could not be found."; if (!errorText.Contains(expected)) { Assert.Fail(string.Format( "Did not find:\n{0}\n\nin:\n{1}", expected, errorText )); } }
private static PythonInteractiveEvaluator MakeEvaluator() { var python = PythonPaths.Python27_x64 ?? PythonPaths.Python27; python.AssertInstalled(); var provider = new SimpleFactoryProvider(python.InterpreterPath, python.InterpreterPath); var eval = new PythonInteractiveEvaluator(PythonToolsTestUtilities.CreateMockServiceProvider()) { Configuration = new LaunchConfiguration(python.Configuration) }; Assert.IsTrue(eval._Initialize(new MockReplWindow(eval)).Result.IsSuccessful); return eval; }
public async Task NoInterpreterPath() { // http://pytools.codeplex.com/workitem/662 var replEval = new PythonInteractiveEvaluator(PythonToolsTestUtilities.CreateMockServiceProvider()) { DisplayName = "Test Interpreter" }; var replWindow = new MockReplWindow(replEval); await replEval._Initialize(replWindow); await replEval.ExecuteText("42"); Console.WriteLine(replWindow.Error); Assert.IsTrue( replWindow.Error.Contains("Test Interpreter cannot be started"), "Expected: <Test Interpreter cannot be started>\r\nActual: <" + replWindow.Error + ">" ); }