mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-04-19 04:51:24 +07:00
PY-34617 Support version check
GitOrigin-RevId: 3318ff79cdcc5ba0ce5e4feb65abad5ad0f4acfa
This commit is contained in:
committed by
intellij-monorepo-bot
parent
16a7fb4b3e
commit
93b9066edf
@@ -1918,4 +1918,80 @@ public abstract class PyCommonResolveTest extends PyCommonResolveTestCase {
|
||||
PyFunction containingMethod = assertInstanceOf(ScopeUtil.getScopeOwner(classAttr), PyFunction.class);
|
||||
assertEquals("next", containingMethod.getName());
|
||||
}
|
||||
|
||||
// PY-34617
|
||||
public void testFileAttributeMatchingVersionCheck() {
|
||||
myFixture.copyDirectoryToProject("resolve/FileAttributeUnderVersionCheck", "");
|
||||
runWithLanguageLevel(LanguageLevel.PYTHON310, () -> {
|
||||
myFixture.configureByText(
|
||||
PythonFileType.INSTANCE,
|
||||
"""
|
||||
import mod
|
||||
mod.foo
|
||||
<ref>"""
|
||||
);
|
||||
final PsiElement element = PyCommonResolveTestCase.findReferenceByMarker(myFixture.getFile()).resolve();
|
||||
assertResolveResult(element, PyTargetExpression.class, "foo", "mod.py");
|
||||
});
|
||||
assertFilesNotParsed();
|
||||
}
|
||||
|
||||
// PY-34617
|
||||
public void testFileAttributeNotMatchingVersionCheck() {
|
||||
myFixture.copyDirectoryToProject("resolve/FileAttributeUnderVersionCheck", "");
|
||||
runWithLanguageLevel(LanguageLevel.PYTHON310, () -> {
|
||||
myFixture.configureByText(
|
||||
PythonFileType.INSTANCE,
|
||||
"""
|
||||
import mod
|
||||
mod.bar
|
||||
<ref>"""
|
||||
);
|
||||
final PsiElement element = PyCommonResolveTestCase.findReferenceByMarker(myFixture.getFile()).resolve();
|
||||
assertNull(element);
|
||||
});
|
||||
assertFilesNotParsed();
|
||||
}
|
||||
|
||||
// PY-34617
|
||||
public void testClassAttributeMatchingVersionCheck() {
|
||||
myFixture.copyDirectoryToProject("resolve/ClassAttributeUnderVersionCheck", "");
|
||||
runWithLanguageLevel(LanguageLevel.PYTHON27, () -> {
|
||||
myFixture.configureByText(
|
||||
PythonFileType.INSTANCE,
|
||||
"""
|
||||
from mod import MyClass
|
||||
m = MyClass()
|
||||
m.buz()
|
||||
<ref>"""
|
||||
);
|
||||
final PsiElement element = PyCommonResolveTestCase.findReferenceByMarker(myFixture.getFile()).resolve();
|
||||
assertResolveResult(element, PyFunction.class, "buz", "mod.py");
|
||||
});
|
||||
assertFilesNotParsed();
|
||||
}
|
||||
|
||||
// PY-34617
|
||||
public void testClassAttributeNotMatchingVersionCheck() {
|
||||
myFixture.copyDirectoryToProject("resolve/ClassAttributeUnderVersionCheck", "");
|
||||
runWithLanguageLevel(LanguageLevel.PYTHON27, () -> {
|
||||
myFixture.configureByText(
|
||||
PythonFileType.INSTANCE,
|
||||
"""
|
||||
from mod import MyClass
|
||||
m = MyClass()
|
||||
m.foo()
|
||||
<ref>"""
|
||||
);
|
||||
final PsiElement element = PyCommonResolveTestCase.findReferenceByMarker(myFixture.getFile()).resolve();
|
||||
assertNull(element);
|
||||
});
|
||||
assertFilesNotParsed();
|
||||
}
|
||||
|
||||
private void assertFilesNotParsed() {
|
||||
final PsiFile file = myFixture.getFile();
|
||||
assertProjectFilesNotParsed(file);
|
||||
assertSdkRootsNotParsed(file);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2101,6 +2101,33 @@ public abstract class PythonCommonCompletionTest extends PythonCommonTestCase {
|
||||
doTest();
|
||||
}
|
||||
|
||||
// PY-34617
|
||||
public void testVersionCheckAtFileLevel() {
|
||||
runWithLanguageLevel(LanguageLevel.PYTHON27, () -> {
|
||||
List<String> suggested = doTestByFile();
|
||||
assertContainsElements(suggested, "attr0", "attr3", "f0", "f3", "MyClass0", "MyClass3");
|
||||
assertDoesntContain(suggested, "attr1", "attr2", "f1", "f2", "MyClass1", "MyClass2");
|
||||
});
|
||||
}
|
||||
|
||||
// PY-34617
|
||||
public void testVersionCheckAtClassLevel() {
|
||||
runWithLanguageLevel(LanguageLevel.PYTHON25, () -> {
|
||||
List<String> suggested = doTestByFile();
|
||||
assertContainsElements(suggested, "attr0", "attr2", "f0", "f2", "MyClass0", "MyClass2");
|
||||
assertDoesntContain(suggested, "attr1", "attr3", "f1", "f3", "MyClass1", "MyClass3");
|
||||
});
|
||||
}
|
||||
|
||||
// PY-34617
|
||||
public void testVersionCheckInClassInsideMethod() {
|
||||
runWithLanguageLevel(LanguageLevel.PYTHON310, () -> {
|
||||
List<String> suggested = doTestByFile();
|
||||
assertContainsElements(suggested, "f0", "f1");
|
||||
assertDoesntContain(suggested, "f2", "f3");
|
||||
});
|
||||
}
|
||||
|
||||
private void doTestHasattrContributor(String[] inList, String[] notInList) {
|
||||
doTestHasattrContributor("hasattrCompletion/" + getTestName(true) + ".py", inList, notInList);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user