From c1985c7eab1bc82c4754d418ed1c2f04377eba19 Mon Sep 17 00:00:00 2001 From: Marcus Mews Date: Thu, 25 Sep 2025 08:37:20 +0200 Subject: [PATCH] [python][tests] Fix NPE in test infrastructure GitOrigin-RevId: 11f2761ca46771402c9c7ab32dba266ff62fe5e7 --- .../com/jetbrains/python/fixtures/PyTestCase.java | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/python/testSrc/com/jetbrains/python/fixtures/PyTestCase.java b/python/testSrc/com/jetbrains/python/fixtures/PyTestCase.java index 843b18675e26..af4ea776e435 100644 --- a/python/testSrc/com/jetbrains/python/fixtures/PyTestCase.java +++ b/python/testSrc/com/jetbrains/python/fixtures/PyTestCase.java @@ -18,6 +18,7 @@ import com.intellij.openapi.editor.CaretModel; import com.intellij.openapi.editor.Editor; import com.intellij.openapi.editor.ex.EditorEx; import com.intellij.openapi.module.Module; +import com.intellij.openapi.project.Project; import com.intellij.openapi.projectRoots.Sdk; import com.intellij.openapi.projectRoots.SdkModificator; import com.intellij.openapi.roots.OrderRootType; @@ -59,7 +60,6 @@ import com.jetbrains.python.psi.search.PySearchUtilBase; import com.jetbrains.python.psi.types.PyType; import com.jetbrains.python.psi.types.TypeEvalContext; import com.jetbrains.python.sdk.PythonSdkUtil; -import kotlin.Pair; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import org.junit.Assert; @@ -325,8 +325,11 @@ public abstract class PyTestCase extends UsefulTestCase { } private void setLanguageLevel(@Nullable LanguageLevel languageLevel) { - PythonLanguageLevelPusher.setForcedLanguageLevel(myFixture.getProject(), languageLevel); - IndexingTestUtil.waitUntilIndexesAreReady(myFixture.getProject()); + Project project = myFixture.getProject(); + if (project != null) { + PythonLanguageLevelPusher.setForcedLanguageLevel(project, languageLevel); + IndexingTestUtil.waitUntilIndexesAreReady(project); + } } protected void runWithLanguageLevel(@NotNull LanguageLevel languageLevel, @NotNull Runnable runnable) {