mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-04-21 14:01:44 +07:00
Support for implicit namespace packages in Python 3.3 (PY-7156)
This commit is contained in:
@@ -648,6 +648,9 @@ public class PyUtil {
|
||||
if (turnDirIntoInit(directory) != null) {
|
||||
return true;
|
||||
}
|
||||
if (LanguageLevel.forFile(directory.getVirtualFile()).isAtLeast(LanguageLevel.PYTHON33)) {
|
||||
return true;
|
||||
}
|
||||
return hasNamespacePackageFile(directory);
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,4 @@
|
||||
from p1.m1 import foo
|
||||
|
||||
foo()
|
||||
#<ref>
|
||||
@@ -0,0 +1,2 @@
|
||||
def foo():
|
||||
pass
|
||||
@@ -0,0 +1,4 @@
|
||||
import p1
|
||||
|
||||
p1
|
||||
#<ref>
|
||||
@@ -0,0 +1,2 @@
|
||||
def foo():
|
||||
pass
|
||||
@@ -404,6 +404,29 @@ public class PyMultiFileResolveTest extends PyResolveTestCase {
|
||||
assertResolvesTo(PyFunction.class, "foo");
|
||||
}
|
||||
|
||||
// PY-7156
|
||||
public void testPython33NamespacePackage() {
|
||||
setLanguageLevel(LanguageLevel.PYTHON33);
|
||||
try {
|
||||
final PsiElement element = doResolve();
|
||||
assertInstanceOf(element, PyImportedModule.class);
|
||||
final PyImportedModule module = (PyImportedModule)element;
|
||||
assertEquals("p1", module.getImportedPrefix().toString());
|
||||
} finally {
|
||||
setLanguageLevel(null);
|
||||
}
|
||||
}
|
||||
|
||||
// PY-7156
|
||||
public void testFromPython33NamespacePackageImport() {
|
||||
setLanguageLevel(LanguageLevel.PYTHON33);
|
||||
try {
|
||||
assertResolvesTo(PyFunction.class, "foo");
|
||||
} finally {
|
||||
setLanguageLevel(null);
|
||||
}
|
||||
}
|
||||
|
||||
private void prepareTestDirectory() {
|
||||
final String testName = getTestName(true);
|
||||
myFixture.copyDirectoryToProject(testName, "");
|
||||
|
||||
Reference in New Issue
Block a user