void () { final TemplateManager templateManager = TemplateManager.getInstance(myFixture.getProject()); final Template template = templateManager.createTemplate("pri", "Python", "print($SELECTION$)$END$"); TemplateContextType context = TemplateContextTypes.getByClass(PythonTemplateContextType.General.class); assertNotNull(context); ((TemplateImpl)template).getTemplateContext().setEnabled(context, true); CodeInsightTestUtil.addTemplate(template, myFixture.getTestRootDisposable()); myFixture.configureByText("abc.py", "'test'<caret>"); myFixture.getEditor().getSelectionModel().setSelection(0, 6); new InvokeTemplateAction((TemplateImpl)template, myFixture.getEditor(), myFixture.getProject(), new HashSet<>()).perform(); myFixture.checkResult("print('test')"); }