void (@NotNull Sdk sdk) { // Check the builtin skeleton header final Project project = myFixture.getProject(); ApplicationManager.getApplication().runReadAction(() -> { PyFile builtins = PyBuiltinCache.getBuiltinsForSdk(project, sdk); if (builtins instanceof PyiFile) { builtins = (PyFile)PyiUtil.getOriginalElement(builtins); } assertNotNull(builtins); final VirtualFile virtualFile = builtins.getVirtualFile(); assertNotNull(virtualFile); assertTrue(virtualFile.isInLocalFileSystem()); final String path = virtualFile.getPath(); final PySkeletonHeader header = PySkeletonHeader.readSkeletonHeader(new File(path)); assertNotNull(header); final int version = header.getVersion(); assertTrue("Header version must be > 0, currently it is " + version, version > 0); assertEquals(PySkeletonHeader.BUILTIN_NAME, header.getBinaryFile()); }); // Run inspections on a file that uses builtins EdtTestUtil.runInEdtAndWait((() -> myFixture.configureByFile(getTestName(false) + ".py"))); ApplicationManager.getApplication().runReadAction(() -> { PsiFile expr = myFixture.getFile(); final Module module = ModuleUtilCore.findModuleForPsiElement(expr); final Sdk sdkFromModule = PythonSdkUtil.findPythonSdk(module); assertNotNull(sdkFromModule); final Sdk sdkFromPsi = PyBuiltinCache.findSdkForFile(expr.getContainingFile()); assertNotNull(sdkFromPsi); final PyFile builtinsFromSdkCache = PythonSdkPathCache.getInstance(project, sdkFromPsi).getBuiltins().getBuiltinsFile(); assertNotNull(builtinsFromSdkCache); final PyFile builtins = PyBuiltinCache.getBuiltinsForSdk(project, sdk); assertNotNull(builtins); assertEquals(builtins, builtinsFromSdkCache); final PyFile builtinsFromPsi = PyBuiltinCache.getInstance(expr).getBuiltinsFile(); assertNotNull(builtinsFromPsi); assertEquals(builtins, builtinsFromPsi); }); myFixture.enableInspections(PyUnresolvedReferencesInspection.class); EdtTestUtil.runInEdtAndWait((() -> myFixture.checkHighlighting(true, false, false))); }