boolean (@NotNull AbstractPythonLegacyTestRunConfiguration<T> configuration, @NotNull ConfigurationContext context, @NotNull Ref<PsiElement> sourceElement) { final Location location = context.getLocation(); if (location == null || !isAvailable(location)) return false; PsiElement element = location.getPsiElement(); if (element instanceof PsiWhiteSpace) { element = PyUtil.findNonWhitespaceAtOffset(element.getContainingFile(), element.getTextOffset()); } if (RunnableScriptFilter.isIfNameMain(location)) return false; final Module module = location.getModule(); if (!isPythonModule(module)) return false; if (element instanceof PsiDirectory) { return setupConfigurationFromFolder((PsiDirectory)element, configuration); } final PyFunction pyFunction = PsiTreeUtil.getParentOfType(element, PyFunction.class, false); if (pyFunction != null && isTestFunction(pyFunction, configuration)) { return setupConfigurationFromFunction(pyFunction, configuration); } final PyClass pyClass = PsiTreeUtil.getParentOfType(element, PyClass.class, false); if (pyClass != null && isTestClass(pyClass, configuration, TypeEvalContext.userInitiated(pyClass.getProject(), element.getContainingFile()))) { return setupConfigurationFromClass(pyClass, configuration); } if (element == null) return false; final PsiFile file = element.getContainingFile(); if (file instanceof PyFile && isTestFile((PyFile)file)) { return setupConfigurationFromFile((PyFile)file, configuration); } return false; }