void (Disposable testDisposable) { final InjectedLanguageManager manager = InjectedLanguageManager.getInstance(myFixture.getProject()); MultiHostInjector multiHostInjector = new MultiHostInjector() { @Override public void getLanguagesToInject(@NotNull MultiHostRegistrar registrar, @NotNull PsiElement context) { TextRange range = new TextRange(4, context.getTextLength() - 4); registrar.startInjecting(PythonLanguage.INSTANCE) .addPlace(null, null, (PsiLanguageInjectionHost)context, range) .doneInjecting(); } @NotNull @Override public List<Class<? extends PsiElement>> elementsToInjectIn() { return List.of(PyStringLiteralExpression.class); } }; manager.registerMultiHostInjector(multiHostInjector, testDisposable); }