fixed PY-11047 "Python version 3.3 does not have module exceptions" on relative import

do not run inspection on relative imports
This commit is contained in:
Ekaterina Tuzova
2013-10-08 19:57:50 +04:00
parent f44003d7ec
commit ef73535523
3 changed files with 7 additions and 0 deletions
@@ -239,6 +239,7 @@ public class PyCompatibilityInspection extends PyInspection {
@Override
public void visitPyFromImportStatement(PyFromImportStatement node) {
super.visitPyFromImportStatement(node);
if (node.getRelativeLevel() > 0) return;
int len = 0;
StringBuilder message = new StringBuilder("Python version ");
PyQualifiedName name = node.getImportSourceQName();
@@ -0,0 +1 @@
<warning descr="Python version 2.4 doesn't support this syntax.">from ..exceptions import ServiceDoesNotExists</warning>
@@ -130,6 +130,11 @@ public class PyCompatibilityInspectionTest extends PyTestCase {
doTest(LanguageLevel.PYTHON33);
}
// PY-11047
public void testRelativeImport() {
doTest();
}
private void doTest(@NotNull LanguageLevel level) {
runWithLanguageLevel(level, new Runnable() {
@Override