mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
Make the test data layout of extended completion tests more uniform
GitOrigin-RevId: 5ca54fd7ba3446c0548c38d81051968dc7dc4586
This commit is contained in:
committed by
intellij-monorepo-bot
parent
3518c9339d
commit
ce48522d8f
@@ -147,7 +147,7 @@ public class PyClassNameCompletionTest extends PyTestCase {
|
||||
runWithAdditionalFileInLibDir(
|
||||
"sys.py",
|
||||
"path = 10",
|
||||
(__) -> doTestCompletionOrder("main.path", "first.foo.path", "sys.path", "_second.bar.path")
|
||||
(__) -> doTestCompletionOrder("combinedOrdering.path", "first.foo.path", "sys.path", "_second.bar.path")
|
||||
);
|
||||
}
|
||||
|
||||
@@ -158,31 +158,23 @@ public class PyClassNameCompletionTest extends PyTestCase {
|
||||
|
||||
// PY-44586
|
||||
public void testNoDuplicatesForStubsAndOverrides() {
|
||||
final String path = "/completion/className/" + getTestName(true);
|
||||
myFixture.copyDirectoryToProject(path, "");
|
||||
myFixture.configureFromTempProjectFile(getTestName(true) + ".py");
|
||||
myFixture.complete(CompletionType.BASIC, 2);
|
||||
doExtendedCompletion();
|
||||
List<String> allVariants = myFixture.getLookupElementStrings();
|
||||
assertNotNull(allVariants);
|
||||
assertEquals(1, Collections.frequency(allVariants, "my_func"));
|
||||
}
|
||||
|
||||
private void doTest() {
|
||||
final String path = "/completion/className/" + getTestName(true);
|
||||
myFixture.copyDirectoryToProject(path, "");
|
||||
myFixture.configureFromTempProjectFile(getTestName(true) + ".py");
|
||||
myFixture.complete(CompletionType.BASIC, 2);
|
||||
if (myFixture.getLookupElements() != null) {
|
||||
LookupElement[] lookupElements = doExtendedCompletion();
|
||||
if (lookupElements != null) {
|
||||
myFixture.finishLookup(Lookup.NORMAL_SELECT_CHAR);
|
||||
}
|
||||
myFixture.checkResultByFile(path + "/" + getTestName(true) + ".after.py", true);
|
||||
myFixture.checkResultByFile(getTestName(true) + "/" + getTestName(true) + ".after.py", true);
|
||||
}
|
||||
|
||||
private void doTestCompletionOrder(String @NotNull ... expected) {
|
||||
myFixture.copyDirectoryToProject("/completion/className/" + getTestName(true), "");
|
||||
myFixture.configureByFile("main.py");
|
||||
myFixture.complete(CompletionType.BASIC, 2);
|
||||
List<String> qNames = StreamEx.of(myFixture.getLookupElements())
|
||||
LookupElement[] lookupElements = doExtendedCompletion();
|
||||
List<String> qNames = StreamEx.of(lookupElements)
|
||||
.map(LookupElement::getPsiElement)
|
||||
.nonNull()
|
||||
.map(PyClassNameCompletionTest::extractQualifiedName)
|
||||
@@ -190,6 +182,12 @@ public class PyClassNameCompletionTest extends PyTestCase {
|
||||
assertContainsInRelativeOrder(qNames, expected);
|
||||
}
|
||||
|
||||
private LookupElement @Nullable [] doExtendedCompletion() {
|
||||
myFixture.copyDirectoryToProject(getTestName(true), "");
|
||||
myFixture.configureFromTempProjectFile(getTestName(true) + ".py");
|
||||
return myFixture.complete(CompletionType.BASIC, 2);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
private static String extractQualifiedName(@NotNull PsiElement element) {
|
||||
if (element instanceof PyQualifiedNameOwner) {
|
||||
@@ -208,4 +206,9 @@ public class PyClassNameCompletionTest extends PyTestCase {
|
||||
private PyCodeStyleSettings getPythonCodeStyleSettings() {
|
||||
return getCodeStyleSettings().getCustomSettings(PyCodeStyleSettings.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getTestDataPath() {
|
||||
return super.getTestDataPath() + "/completion/className/";
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user