boolean (@Nullable String expectedError) { try { final PsiElement element = TargetElementUtil.findTargetElement(myFixture.getEditor(), TargetElementUtil.getInstance().getReferenceSearchFlags()); final PyInlineLocalHandler handler = PyInlineLocalHandler.getInstance(); handler.inlineElement(myFixture.getProject(), myFixture.getEditor(), element); if (expectedError != null) fail("expected error: '" + expectedError + "', got none"); } catch (Exception e) { if (!Objects.equals(e.getMessage(), expectedError)) { e.printStackTrace(); } assertEquals(expectedError, e.getMessage()); return false; } return true; }