mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-18 09:34:34 +07:00
PY-85270 [python] Update tests
GitOrigin-RevId: 11ae77f2d48fc6a09c935218e2ebd138e909346a
This commit is contained in:
committed by
intellij-monorepo-bot
parent
b4db1f83a9
commit
23a1cd15ce
+2
-1
@@ -21,6 +21,7 @@ import com.jetbrains.python.codeInsight.dataflow.scope.ScopeUtil
|
||||
import com.jetbrains.python.psi.PyClass
|
||||
import com.jetbrains.python.psi.PyFile
|
||||
import com.jetbrains.python.psi.PyFunction
|
||||
import com.jetbrains.python.psi.PyUtil
|
||||
import com.jetbrains.python.psi.icons.PythonPsiApiIcons
|
||||
import com.jetbrains.python.psi.resolve.QualifiedNameFinder
|
||||
import com.jetbrains.python.psi.types.TypeEvalContext
|
||||
@@ -166,7 +167,7 @@ fun computeCompletionWeight(element: PsiElement, elementName: String?, path: Qua
|
||||
}
|
||||
}
|
||||
|
||||
weight -= when(element) {
|
||||
weight -= when(PyUtil.turnInitIntoDir(element)) {
|
||||
is PsiDirectory -> ELEMENT_TYPE * 2
|
||||
is PyFile -> ELEMENT_TYPE
|
||||
else -> 0
|
||||
|
||||
+2
@@ -1 +1,3 @@
|
||||
import foobar
|
||||
|
||||
foobar
|
||||
@@ -4,6 +4,8 @@ package com.jetbrains.python;
|
||||
import com.intellij.codeInsight.completion.impl.CamelHumpMatcher;
|
||||
import com.intellij.codeInsight.lookup.Lookup;
|
||||
import com.intellij.codeInsight.lookup.LookupElement;
|
||||
import com.intellij.codeInsight.lookup.LookupElementPresentation;
|
||||
import com.intellij.codeInsight.lookup.LookupElementRenderer;
|
||||
import com.intellij.openapi.module.Module;
|
||||
import com.intellij.testFramework.PsiTestUtil;
|
||||
import com.intellij.testFramework.TestDataPath;
|
||||
@@ -567,32 +569,37 @@ public class Py3CompletionTest extends PyTestCase {
|
||||
|
||||
// PY-46056
|
||||
public void testImportCompletionHintForSameDirectoryModuleInOrdinaryPackage() {
|
||||
doTestVariantTailText("ordinaryPackage/sample.py", "logging", null);
|
||||
doTestVariantTypeText("ordinaryPackage/sample.py", "logging", "");
|
||||
}
|
||||
|
||||
// PY-46056
|
||||
public void testImportCompletionHintForSameDirectoryModuleInPlainDirectory() {
|
||||
doTestVariantTailText("plainDirectory/sample.py", "logging", " (plainDirectory)");
|
||||
doTestVariantTypeText("plainDirectory/sample.py", "logging1", "plainDirectory");
|
||||
}
|
||||
|
||||
// PY-46056
|
||||
public void testFromImportCompletionHintForSameDirectoryModuleInOrdinaryPackage() {
|
||||
doTestVariantTailText("ordinaryPackage/sample.py", "logging", null);
|
||||
doTestVariantTypeText("ordinaryPackage/sample.py", "logging", "");
|
||||
}
|
||||
|
||||
// PY-46056
|
||||
public void testFromImportCompletionHintForSameDirectoryModuleInPlainDirectory() {
|
||||
doTestVariantTailText("plainDirectory/sample.py", "logging", " (plainDirectory)");
|
||||
doTestVariantTypeText("plainDirectory/sample.py", "logging1", "plainDirectory");
|
||||
}
|
||||
|
||||
private void doTestVariantTailText(@NotNull String entryFilePath, @NotNull String variantName, @Nullable String tailText) {
|
||||
private void doTestVariantTypeText(@NotNull String entryFilePath, @NotNull String variantName, @Nullable String typeText) {
|
||||
myFixture.copyDirectoryToProject(getTestName(true), "");
|
||||
myFixture.configureByFile(entryFilePath);
|
||||
LookupElement[] variants = myFixture.completeBasic();
|
||||
assertNotNull(variants);
|
||||
LookupElement lookupElement = ContainerUtil.find(variants, v -> v.getLookupString().equals(variantName));
|
||||
assertNotNull(lookupElement);
|
||||
assertEquals(tailText, TestLookupElementPresentation.renderElement(lookupElement).getTailText());
|
||||
LookupElementPresentation presentation = TestLookupElementPresentation.renderElement(lookupElement);
|
||||
LookupElementRenderer<LookupElement> expensiveRenderer = (LookupElementRenderer<LookupElement>)lookupElement.getExpensiveRenderer();
|
||||
if (expensiveRenderer != null) {
|
||||
expensiveRenderer.renderElement(lookupElement, presentation);
|
||||
}
|
||||
assertEquals(typeText, presentation.getTypeText());
|
||||
}
|
||||
|
||||
// PY-46054
|
||||
|
||||
@@ -181,9 +181,7 @@ public class PyNotImportedQualifiedNameCompletionTest extends PyTestCase {
|
||||
|
||||
// PY-47962
|
||||
public void testNonImportedModulesSuggestedLast() {
|
||||
doBasicCompletion();
|
||||
myFixture.assertPreferredCompletionItems(0, "configuration=");
|
||||
assertContainsElements(myFixture.getLookupElementStrings(), "config", "contrib");
|
||||
assertNull(doBasicCompletion());
|
||||
}
|
||||
|
||||
// PY-47962
|
||||
|
||||
Reference in New Issue
Block a user