PsiElement (PsiFile psiFile) { final PsiReference ref = PyResolveTestCase.findReferenceByMarker(psiFile); final PsiManagerEx psiManager = (PsiManagerEx)myFixture.getPsiManager(); psiManager.setAssertOnFileLoadingFilter(file -> { FileType fileType = file.getFileType(); return fileType == PythonFileType.INSTANCE; }, myFixture.getTestRootDisposable()); final PsiElement result; if (ref instanceof PsiPolyVariantReference) { final ResolveResult[] resolveResults = ((PsiPolyVariantReference)ref).multiResolve(false); result = resolveResults.length == 0 || !resolveResults[0].isValidResult() ? null : resolveResults[0].getElement(); } else { result = ref.resolve(); } psiManager.setAssertOnFileLoadingFilter(VirtualFileFilter.NONE, myFixture.getTestRootDisposable()); return result; }