PsiElement (@NotNull String text, @NotNull String expected) { myFixture.configureByText(PythonFileType.INSTANCE, text); final InjectedLanguageManager languageManager = InjectedLanguageManager.getInstance(myFixture.getProject()); final PsiLanguageInjectionHost host = languageManager.getInjectionHost(getElementAtCaret()); assertNotNull(host); final List<Pair<PsiElement, TextRange>> files = languageManager.getInjectedPsiFiles(host); assertNotNull(files); assertFalse(files.isEmpty()); final PsiElement injected = files.get(0).getFirst(); assertEquals(expected, injected.getText()); return injected; }