From 000b4473db535dd2173bb01d4159703556934429 Mon Sep 17 00:00:00 2001 From: Fabio Zadrozny Date: Sat, 14 Sep 2024 10:14:22 -0300 Subject: [PATCH] Fix test related to surround with try..except. --- .../heuristics/AssistSurroundWithTest.java | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/plugins/org.python.pydev/tests/org/python/pydev/editor/correctionassist/heuristics/AssistSurroundWithTest.java b/plugins/org.python.pydev/tests/org/python/pydev/editor/correctionassist/heuristics/AssistSurroundWithTest.java index ed6e6fc659..d23d6fcfa5 100644 --- a/plugins/org.python.pydev/tests/org/python/pydev/editor/correctionassist/heuristics/AssistSurroundWithTest.java +++ b/plugins/org.python.pydev/tests/org/python/pydev/editor/correctionassist/heuristics/AssistSurroundWithTest.java @@ -8,6 +8,7 @@ import java.util.List; +import org.eclipse.core.runtime.AssertionFailedException; import org.eclipse.jface.text.Document; import org.eclipse.jface.text.IAutoIndentStrategy; import org.eclipse.jface.text.IDocument; @@ -89,7 +90,7 @@ public void testSurround2() throws Exception { " #c\n" + " a = 10\n" + - " except:\n" + + " except Exception:\n" + " raise\n" + "\n" + "\n" + @@ -98,7 +99,13 @@ public void testSurround2() throws Exception { private void apply(ICompletionProposalHandle iCompletionProposalHandle, IDocument doc) { TemplateProposal p = (TemplateProposal) iCompletionProposalHandle; - p.apply(createViewerWithDoc(doc), ' ', 0, 0); + try { + p.apply(createViewerWithDoc(doc), ' ', 0, 0); + } catch (AssertionFailedException e) { + // Ignore (we have errors linking with the UI because it's not there and + // TemplateProposal isn't smart enough to work without it, but it can at least + // do the replacement before failing). + } } public void testSurround3() throws Exception { @@ -121,7 +128,7 @@ public void testSurround3() throws Exception { " #c\n" + " # a = 10\n" + - "except:\n" + + "except Exception:\n" + " raise\n" + "\n" + "\n" + @@ -138,7 +145,7 @@ public void testSurround() throws Exception { TestCaseUtils.assertContentsEqual("" + "try:\n" + " a = 10\n" + - "except:\n" + + "except Exception:\n" + " raise" + "", doc.get()); @@ -158,7 +165,7 @@ public void testSurround() throws Exception { + " \n" + " \n" + " a = 10\n" - + " except:\n" + + " except Exception:\n" + " raise", additionalProposalInfo); @@ -171,7 +178,7 @@ public void testSurround() throws Exception { " \n" + " a = 10\n" + - " except:\n" + + " except Exception:\n" + " raise\n" + "\n" + "\n" +