public void TrueFalseNoneCompletions() { // http://pytools.codeplex.com/workitem/1905 foreach (var version in new[] { PythonLanguageVersion.V27, PythonLanguageVersion.V33 }) { using (var view = new PythonEditor(version: version)) { var completionList = view.GetCompletionList(0); var trueItems = completionList.Where(t => t.DisplayText == "True").ToArray(); var falseItems = completionList.Where(t => t.DisplayText == "False").ToArray(); var noneItems = completionList.Where(t => t.DisplayText == "None").ToArray(); Assert.AreEqual(1, trueItems.Count()); Assert.AreEqual(1, falseItems.Count()); Assert.AreEqual(1, noneItems.Count()); if (version.Is3x()) { Assert.AreEqual("Keyword", trueItems[0].IconAutomationText); Assert.AreEqual("Keyword", falseItems[0].IconAutomationText); } else { Assert.AreEqual("Constant", trueItems[0].IconAutomationText); Assert.AreEqual("Constant", falseItems[0].IconAutomationText); } Assert.AreEqual("Keyword", noneItems[0].IconAutomationText); } } }
public void NormalOverrideCompletions() { using (var view2 = new PythonEditor(version: PythonLanguageVersion.V27)) using (var view3 = new PythonEditor(version: PythonLanguageVersion.V33)) { foreach (var code in new[] { @"class Fob(object): def func_a(self, a=100): pass def func_b(self, b, *p, **kw): pass class Baz(Fob): def None ", @"class Fob(object): def func_a(self, a=100): pass class Oar(Fob): def func_b(self, b, *p, **kw): pass class Baz(Oar): def None ", @"class Fob(object): def func_a(self, a=100): pass class Oar(object): def func_b(self, b, *p, **kw): pass class Baz(Fob, Oar): def None ", @"class Fob(object): def func_a(self, a=100): pass def func_b(self, b, *p, **kw): pass def func_c(self): pass class Baz(Fob): def func_c(self): pass def None ", @"class Fob(object): def func_a(self, a=100): pass def func_c(self): pass class Oar(Fob): def func_b(self, b, *p, **kw): pass class Baz(Oar): def func_c(self): pass def None ", @"class Fob(object): def func_a(self, a=100): pass class Oar(object): def func_b(self, b, *p, **kw): pass def func_c(self): pass class Baz(Fob, Oar): def func_c(self): pass def None " }) { view2.Text = code; Console.WriteLine(code); AssertUtil.ContainsAtLeast( view2.GetCompletionList(code.IndexOf("None")).Select(c => c.InsertionText), @"func_a(self, a = 100): return super(Baz, self).func_a(a)", @"func_b(self, b, *p, **kw): return super(Baz, self).func_b(b, *p, **kw)" ); view3.Text = code; AssertUtil.ContainsAtLeast( view3.GetCompletionList(code.IndexOf("None")).Select(c => c.InsertionText), @"func_a(self, a = 100): return super().func_a(a)", @"func_b(self, b, *p, **kw): return super().func_b(b, *p, **kw)" ); } } }
private static List <Completion> GetCompletionList(MockVs vs, int index, string code, PythonLanguageVersion version = PythonLanguageVersion.V27) { using (var view = new PythonEditor(code, version, vs)) { return(view.GetCompletionList(index)); } }
public void NormalOverrideCompletions() { using (var view2 = new PythonEditor(version: PythonLanguageVersion.V27)) using (var view3 = new PythonEditor(version: PythonLanguageVersion.V33)) { foreach (var code in new[] { @"class Fob(object): def func_a(self, a=100): pass def func_b(self, b, *p, **kw): pass class Baz(Fob): def None ", @"class Fob(object): def func_a(self, a=100): pass class Oar(Fob): def func_b(self, b, *p, **kw): pass class Baz(Oar): def None ", @"class Fob(object): def func_a(self, a=100): pass class Oar(object): def func_b(self, b, *p, **kw): pass class Baz(Fob, Oar): def None ", @"class Fob(object): def func_a(self, a=100): pass def func_b(self, b, *p, **kw): pass def func_c(self): pass class Baz(Fob): def func_c(self): pass def None ", @"class Fob(object): def func_a(self, a=100): pass def func_c(self): pass class Oar(Fob): def func_b(self, b, *p, **kw): pass class Baz(Oar): def func_c(self): pass def None ", @"class Fob(object): def func_a(self, a=100): pass class Oar(object): def func_b(self, b, *p, **kw): pass def func_c(self): pass class Baz(Fob, Oar): def func_c(self): pass def None "}) { view2.Text = code; Console.WriteLine(code); AssertUtil.ContainsAtLeast( view2.GetCompletionList(code.IndexOf("None")).Select(c => c.InsertionText), @"func_a(self, a = 100): return super(Baz, self).func_a(a)", @"func_b(self, b, *p, **kw): return super(Baz, self).func_b(b, *p, **kw)" ); view3.Text = code; AssertUtil.ContainsAtLeast( view3.GetCompletionList(code.IndexOf("None")).Select(c => c.InsertionText), @"func_a(self, a = 100): return super().func_a(a)", @"func_b(self, b, *p, **kw): return super().func_b(b, *p, **kw)" ); } } }
private static List<Completion> GetCompletionList(MockVs vs, int index, string code, PythonLanguageVersion version = PythonLanguageVersion.V27) { using (var view = new PythonEditor(code, version, vs)) { return view.GetCompletionList(index); } }