void (@NotNull String hintPrefix, @Nullable Processor<? super AutoImportQuickFix> checkQuickfix) { configureMultiFileProject(); final PsiElement hostUnderCaret = myFixture.getFile().findElementAt(myFixture.getCaretOffset()); final PyReferenceExpression hostRefExpr = PsiTreeUtil.getParentOfType(hostUnderCaret, PyReferenceExpression.class); final InjectedLanguageManager injectionManager = InjectedLanguageManager.getInstance(myFixture.getProject()); final PsiElement injectedUnderCaret = injectionManager.findInjectedElementAt(myFixture.getFile(), myFixture.getCaretOffset()); final PyReferenceExpression injectionRefExpr = PsiTreeUtil.getParentOfType(injectedUnderCaret, PyReferenceExpression.class); final PyReferenceExpression unresolvedRefExpr = ObjectUtils.chooseNotNull(injectionRefExpr, hostRefExpr); assertNotNull(unresolvedRefExpr); final AutoImportQuickFix quickfix = PythonImportUtils.proposeImportFix(unresolvedRefExpr, unresolvedRefExpr.getReference()); assertNotNull(quickfix); final boolean applyFix = checkQuickfix == null || checkQuickfix.process(quickfix); if (applyFix) { myFixture.launchAction(myFixture.findSingleIntention(hintPrefix)); myFixture.checkResultByFile(getTestName(true) + "/main_after.py", true); } }