void () { String testName = getTestName(true); myFixture.copyDirectoryToProject(testName, ""); myFixture.configureByFile("main.py"); Collection<PyClass> pyClasses = PyClassNameIndex.find("MyClass", myFixture.getProject(), false); PyClass pyClass = assertOneElement(pyClasses); TypeEvalContext typeEvalContext = TypeEvalContext.codeAnalysis(myFixture.getProject(), myFixture.getFile()); PyFunction method = pyClass.findMethodByName("method", false, typeEvalContext); assertNotNull(method); Ref<Boolean> inserted = Ref.create(); WriteCommandAction.runWriteCommandAction(myFixture.getProject(), () -> { inserted.set(PyPsiRefactoringUtil.insertImport(myFixture.getFile(), method, null)); }); assertFalse(inserted.get()); myFixture.checkResultByFile(testName + "/main.py"); }