mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
Refactored multi-file tests for PyUnresolvedReferencesInspection
This commit is contained in:
+6
@@ -0,0 +1,6 @@
|
||||
from p1 import <warning descr="Import resolves to its containing file">m1</warning>
|
||||
|
||||
def foo():
|
||||
pass
|
||||
|
||||
m1.foo()
|
||||
+4
@@ -0,0 +1,4 @@
|
||||
<warning descr="Unused import statement">from <warning descr="Import resolves to its containing file">m1</warning> import xyzzy</warning>
|
||||
|
||||
def xyzzy():
|
||||
pass
|
||||
+1
@@ -0,0 +1 @@
|
||||
from importSource import <warning descr="Unresolved reference 'len'">len</warning>
|
||||
+6
@@ -0,0 +1,6 @@
|
||||
import <warning descr="Import resolves to its containing file">p1.m1</warning>
|
||||
|
||||
def foo():
|
||||
pass
|
||||
|
||||
p1.m1.foo()
|
||||
-5
@@ -1,5 +0,0 @@
|
||||
from PyUnresolvedReferencesInspection import <warning descr="Import resolves to its containing file">fromImportToContainingFile</warning>
|
||||
|
||||
def foo(): pass
|
||||
|
||||
fromImportToContainingFile.foo()
|
||||
-3
@@ -1,3 +0,0 @@
|
||||
<warning descr="Unused import statement">from <warning descr="Import resolves to its containing file">fromImportToContainingFile2</warning> import xyzzy</warning>
|
||||
|
||||
def xyzzy(): pass
|
||||
@@ -1,5 +0,0 @@
|
||||
import <warning descr="Import resolves to its containing file">PyUnresolvedReferencesInspection.importToContainingFile</warning>
|
||||
|
||||
def foo(): pass
|
||||
|
||||
PyUnresolvedReferencesInspection.importToContainingFile.foo()
|
||||
+14
-21
@@ -1,6 +1,7 @@
|
||||
package com.jetbrains.python.inspections;
|
||||
|
||||
import com.jetbrains.python.fixtures.PyTestCase;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
/**
|
||||
* @author yole
|
||||
@@ -45,11 +46,7 @@ public class PyUnresolvedReferencesInspectionTest extends PyTestCase {
|
||||
}
|
||||
|
||||
public void testConditionalImports() { // PY-983
|
||||
myFixture.configureByFiles(TEST_DIRECTORY + getTestName(true) + ".py",
|
||||
TEST_DIRECTORY + "lib1.py",
|
||||
TEST_DIRECTORY + "lib2.py");
|
||||
myFixture.enableInspections(PyUnresolvedReferencesInspection.class);
|
||||
myFixture.checkHighlighting(true, false, false);
|
||||
doMultiFileTest("a.py");
|
||||
}
|
||||
|
||||
public void testHasattrGuard() { // PY-2309
|
||||
@@ -86,15 +83,15 @@ public class PyUnresolvedReferencesInspectionTest extends PyTestCase {
|
||||
}
|
||||
|
||||
public void testImportToContainingFile() { // PY-4372
|
||||
doMultiFileTest();
|
||||
doMultiFileTest("p1/m1.py");
|
||||
}
|
||||
|
||||
public void testFromImportToContainingFile() { // PY-4371
|
||||
doMultiFileTest();
|
||||
doMultiFileTest("p1/m1.py");
|
||||
}
|
||||
|
||||
public void testFromImportToContainingFile2() { // PY-5945
|
||||
doMultiFileTest();
|
||||
doMultiFileTest("p1/m1.py");
|
||||
}
|
||||
|
||||
public void testPropertyType() { // PY-5915
|
||||
@@ -110,20 +107,8 @@ public class PyUnresolvedReferencesInspectionTest extends PyTestCase {
|
||||
doTest();
|
||||
}
|
||||
|
||||
private void doMultiFileTest() {
|
||||
myFixture.copyFileToProject("inspections/PyUnresolvedReferencesInspection/__init__.py", "PyUnresolvedReferencesInspection/__init__.py");
|
||||
myFixture.copyFileToProject("inspections/PyUnresolvedReferencesInspection/" + getTestName(true) + ".py",
|
||||
"PyUnresolvedReferencesInspection/" + getTestName(true) + ".py");
|
||||
myFixture.configureFromTempProjectFile("PyUnresolvedReferencesInspection/" + getTestName(true) + ".py");
|
||||
myFixture.enableInspections(PyUnresolvedReferencesInspection.class);
|
||||
myFixture.checkHighlighting(true, false, false);
|
||||
}
|
||||
|
||||
public void testFromPackageImportBuiltin() {
|
||||
myFixture.copyDirectoryToProject("inspections/PyUnresolvedReferencesInspection/fromPackageImportBuiltin", "");
|
||||
myFixture.configureFromTempProjectFile("fromPackageImportBuiltin.py");
|
||||
myFixture.enableInspections(PyUnresolvedReferencesInspection.class);
|
||||
myFixture.checkHighlighting(true, false, false);
|
||||
doMultiFileTest("a.py");
|
||||
}
|
||||
|
||||
private void doTest() {
|
||||
@@ -131,4 +116,12 @@ public class PyUnresolvedReferencesInspectionTest extends PyTestCase {
|
||||
myFixture.enableInspections(PyUnresolvedReferencesInspection.class);
|
||||
myFixture.checkHighlighting(true, false, false);
|
||||
}
|
||||
|
||||
private void doMultiFileTest(@NotNull String filename) {
|
||||
final String testName = getTestName(false);
|
||||
myFixture.copyDirectoryToProject(TEST_DIRECTORY + testName, "");
|
||||
myFixture.configureFromTempProjectFile(filename);
|
||||
myFixture.enableInspections(PyUnresolvedReferencesInspection.class);
|
||||
myFixture.checkHighlighting(true, false, false);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user