public void BasicProjectTest() { var sln = new ProjectDefinition( "HelloWorld", PythonProject, Compile("server", "") ).Generate(); using (var vs = sln.ToMockVs()) { Assert.IsNotNull(vs.WaitForItem("HelloWorld", "Python Environments")); Assert.IsNotNull(vs.WaitForItem("HelloWorld", "References")); Assert.IsNotNull(vs.WaitForItem("HelloWorld", "Search Paths")); Assert.IsNotNull(vs.WaitForItem("HelloWorld", "server.py")); var view = vs.OpenItem("HelloWorld", "server.py"); view.Invoke(() => view.Type("import ")); using (var sh = view.WaitForSession<ICompletionSession>()) { AssertUtil.Contains(sh.Session.Completions(), "sys"); } } }
public void ShouldWarnOnRun() { var sln = new ProjectDefinition( "HelloWorld", PythonProject, Compile("app", "print \"hello\"") ).Generate(); using (var vs = sln.ToMockVs()) using (var analyzerChanged = new AutoResetEvent(false)) { var project = vs.GetProject("HelloWorld").GetPythonProject(); project.ProjectAnalyzerChanged += (s, e) => analyzerChanged.Set(); var uiThread = (UIThreadBase)project.GetService(typeof(UIThreadBase)); var interpreters = ((IComponentModel)project.GetService(typeof(SComponentModel))) .GetService<IInterpreterRegistryService>() .Interpreters; var v27 = interpreters.Where(x => x.Configuration.Id == "Global|PythonCore|2.7|x86").First(); var v34 = interpreters.Where(x => x.Configuration.Id == "Global|PythonCore|3.4|x86").First(); var interpOptions = (UIThreadBase)project.GetService(typeof(IComponentModel)); uiThread.Invoke(() => { project.AddInterpreter(v27.Configuration.Id); project.AddInterpreter(v34.Configuration.Id); }); project.SetInterpreterFactory(v27); Assert.IsTrue(analyzerChanged.WaitOne(10000), "Timed out waiting for analyzer change #1"); uiThread.Invoke(() => project.GetAnalyzer()).WaitForCompleteAnalysis(_ => true); Assert.IsFalse(project.ShouldWarnOnLaunch, "Should not warn on 2.7"); project.SetInterpreterFactory(v34); Assert.IsTrue(analyzerChanged.WaitOne(10000), "Timed out waiting for analyzer change #2"); uiThread.Invoke(() => project.GetAnalyzer()).WaitForCompleteAnalysis(_ => true); Assert.IsTrue(project.ShouldWarnOnLaunch, "Expected warning on 3.4"); project.SetInterpreterFactory(v27); Assert.IsTrue(analyzerChanged.WaitOne(10000), "Timed out waiting for analyzer change #3"); uiThread.Invoke(() => project.GetAnalyzer()).WaitForCompleteAnalysis(_ => true); Assert.IsFalse(project.ShouldWarnOnLaunch, "Expected warning to go away on 2.7"); } }
public void ShouldWarnOnRun() { var sln = new ProjectDefinition( "HelloWorld", PythonProject, Compile("app", "print \"hello\"") ).Generate(); using (var vs = sln.ToMockVs()) using (var analyzerChanged = new AutoResetEvent(false)) { var project = vs.GetProject("HelloWorld").GetPythonProject(); project.ProjectAnalyzerChanged += (s, e) => analyzerChanged.Set(); var v27 = InterpreterFactoryCreator.CreateInterpreterFactory(new InterpreterFactoryCreationOptions { LanguageVersion = new Version(2, 7), PrefixPath = "C:\\Python27", InterpreterPath = "C:\\Python27\\python.exe" }); var v34 = InterpreterFactoryCreator.CreateInterpreterFactory(new InterpreterFactoryCreationOptions { LanguageVersion = new Version(3, 4), PrefixPath = "C:\\Python34", InterpreterPath = "C:\\Python34\\python.exe" }); var uiThread = (UIThreadBase)project.GetService(typeof(UIThreadBase)); uiThread.Invoke(() => { project.Interpreters.AddInterpreter(v27); project.Interpreters.AddInterpreter(v34); }); project.SetInterpreterFactory(v27); Assert.IsTrue(analyzerChanged.WaitOne(10000), "Timed out waiting for analyzer change #1"); uiThread.Invoke(() => project.GetAnalyzer()).WaitForCompleteAnalysis(_ => true); Assert.IsFalse(project.ShouldWarnOnLaunch, "Should not warn on 2.7"); project.SetInterpreterFactory(v34); Assert.IsTrue(analyzerChanged.WaitOne(10000), "Timed out waiting for analyzer change #2"); uiThread.Invoke(() => project.GetAnalyzer()).WaitForCompleteAnalysis(_ => true); Assert.IsTrue(project.ShouldWarnOnLaunch, "Expected warning on 3.4"); project.SetInterpreterFactory(v27); Assert.IsTrue(analyzerChanged.WaitOne(10000), "Timed out waiting for analyzer change #3"); uiThread.Invoke(() => project.GetAnalyzer()).WaitForCompleteAnalysis(_ => true); Assert.IsFalse(project.ShouldWarnOnLaunch, "Expected warning to go away on 2.7"); } }