mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
PY-7376 Resolving of relative imports takes into account namespace packages
This commit is contained in:
@@ -95,7 +95,7 @@ public class ResolveImportUtil {
|
||||
base = base.getOriginalFile(); // just to make sure
|
||||
result = base.getContainingDirectory();
|
||||
int count = 1;
|
||||
while (result != null && result.findFile(PyNames.INIT_DOT_PY) != null) {
|
||||
while (result != null && PyUtil.isPackage(result, base)) {
|
||||
if (count >= depth) return result;
|
||||
result = result.getParentDirectory();
|
||||
count += 1;
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
from .nspkg2 import foo
|
||||
@@ -0,0 +1 @@
|
||||
from .nspkg2 import f<caret>
|
||||
@@ -0,0 +1 @@
|
||||
from . import foo
|
||||
@@ -0,0 +1 @@
|
||||
from . import f<caret>
|
||||
@@ -119,4 +119,21 @@ public class Py3CompletionTest extends PyTestCase {
|
||||
public void testImportNestedQualifiedNamespacePackage() {
|
||||
doMultiFileTest();
|
||||
}
|
||||
|
||||
// PY-7376
|
||||
public void testRelativeFromImportInNamespacePackage() {
|
||||
doMultiFileTestInsideNamespacePackage();
|
||||
}
|
||||
|
||||
// PY-7376
|
||||
public void testRelativeFromImportInNamespacePackage2() {
|
||||
doMultiFileTestInsideNamespacePackage();
|
||||
}
|
||||
|
||||
private void doMultiFileTestInsideNamespacePackage() {
|
||||
myFixture.copyDirectoryToProject("completion/" + getTestName(true), "");
|
||||
myFixture.configureByFile("nspkg1/a.py");
|
||||
myFixture.completeBasic();
|
||||
myFixture.checkResultByFile("completion/" + getTestName(true) + "/nspkg1/a.after.py");
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user