diff --git a/python/testData/inspections/PyUnresolvedReferencesInspection/expected.xml b/python/testData/inspections/PyUnresolvedReferencesInspection/expected.xml deleted file mode 100644 index cc1a7bdd8004..000000000000 --- a/python/testData/inspections/PyUnresolvedReferencesInspection/expected.xml +++ /dev/null @@ -1,23 +0,0 @@ - - - - testcase.py - 2 - Unresolved reference 'testcase' - - - testcase.py - 4 - Unresolved reference 'wurm' - - - testcase.py - 30 - 'B' object has no attribute 'bar' - - - testcase.py - 36 - 'C' object has no attribute 'bar' - - diff --git a/python/testData/inspections/PyUnresolvedReferencesInspection/overridesGetAttr.py b/python/testData/inspections/PyUnresolvedReferencesInspection/overridesGetAttr.py new file mode 100644 index 000000000000..fe574aa79791 --- /dev/null +++ b/python/testData/inspections/PyUnresolvedReferencesInspection/overridesGetAttr.py @@ -0,0 +1,5 @@ +class B: + def __getattr__(self, name): + pass + +B().foo() diff --git a/python/testData/inspections/PyUnresolvedReferencesInspection/selfReference.py b/python/testData/inspections/PyUnresolvedReferencesInspection/selfReference.py new file mode 100644 index 000000000000..1a7b2d3e4489 --- /dev/null +++ b/python/testData/inspections/PyUnresolvedReferencesInspection/selfReference.py @@ -0,0 +1 @@ +selfReference diff --git a/python/testData/inspections/PyUnresolvedReferencesInspection/slots.py b/python/testData/inspections/PyUnresolvedReferencesInspection/slots.py new file mode 100644 index 000000000000..adc353f45f2c --- /dev/null +++ b/python/testData/inspections/PyUnresolvedReferencesInspection/slots.py @@ -0,0 +1,11 @@ +class B(object): + __slots__ = ['foo'] + +b = B() +b.bar = 1 + +class C(B): + pass + +c = C() +c.bar = 1 diff --git a/python/testData/inspections/PyUnresolvedReferencesInspection/staticMethodParameter.py b/python/testData/inspections/PyUnresolvedReferencesInspection/staticMethodParameter.py new file mode 100644 index 000000000000..267526b50093 --- /dev/null +++ b/python/testData/inspections/PyUnresolvedReferencesInspection/staticMethodParameter.py @@ -0,0 +1,4 @@ +class A: + @staticmethod + def foo(q): + q.bar() diff --git a/python/testData/inspections/PyUnresolvedReferencesInspection/undeclaredAttrAssign.py b/python/testData/inspections/PyUnresolvedReferencesInspection/undeclaredAttrAssign.py new file mode 100644 index 000000000000..d634eb536427 --- /dev/null +++ b/python/testData/inspections/PyUnresolvedReferencesInspection/undeclaredAttrAssign.py @@ -0,0 +1,2 @@ +x = object() +x.y = 5 diff --git a/python/testData/inspections/PyUnresolvedReferencesInspection/unresolvedImport.py b/python/testData/inspections/PyUnresolvedReferencesInspection/unresolvedImport.py new file mode 100644 index 000000000000..853423274bc8 --- /dev/null +++ b/python/testData/inspections/PyUnresolvedReferencesInspection/unresolvedImport.py @@ -0,0 +1 @@ +import wurm diff --git a/python/testSrc/com/jetbrains/python/PythonAllTestsSuite.java b/python/testSrc/com/jetbrains/python/PythonAllTestsSuite.java index d0367779a2fa..493985153e02 100644 --- a/python/testSrc/com/jetbrains/python/PythonAllTestsSuite.java +++ b/python/testSrc/com/jetbrains/python/PythonAllTestsSuite.java @@ -3,6 +3,7 @@ package com.jetbrains.python; import com.jetbrains.python.codeInsight.PyCompletionPatternsTest; import com.jetbrains.python.inspections.PyArgumentListInspectionTest; import com.jetbrains.python.inspections.PyCompatibilityInspectionTest; +import com.jetbrains.python.inspections.PyUnresolvedReferencesInspectionTest; import com.jetbrains.python.inspections.PyUnusedImportTest; import com.jetbrains.python.refactoring.*; import com.jetbrains.python.refactoring.classes.PyExtractSuperclassTest; @@ -78,6 +79,7 @@ public class PythonAllTestsSuite { PyBinaryModuleCompletionTest.class, PyCompletionPatternsTest.class, PyCompatibilityInspectionTest.class, + PyUnresolvedReferencesInspectionTest.class, PyUnusedImportTest.class }; diff --git a/python/testSrc/com/jetbrains/python/PythonInspectionsTest.java b/python/testSrc/com/jetbrains/python/PythonInspectionsTest.java index 6ada8f984433..5731053d2a98 100644 --- a/python/testSrc/com/jetbrains/python/PythonInspectionsTest.java +++ b/python/testSrc/com/jetbrains/python/PythonInspectionsTest.java @@ -47,11 +47,6 @@ public class PythonInspectionsTest extends PyLightFixtureTestCase { doTest(getTestName(false), inspection); } - public void testPyUnresolvedReferencesInspection() { - LocalInspectionTool inspection = new PyUnresolvedReferencesInspection(); - doTest(getTestName(false), inspection); - } - public void testPyArgumentListInspection() { LocalInspectionTool inspection = new PyArgumentListInspection(); doTest(getTestName(false), inspection); diff --git a/python/testSrc/com/jetbrains/python/inspections/PyUnresolvedReferencesInspectionTest.java b/python/testSrc/com/jetbrains/python/inspections/PyUnresolvedReferencesInspectionTest.java new file mode 100644 index 000000000000..f5a1036246a2 --- /dev/null +++ b/python/testSrc/com/jetbrains/python/inspections/PyUnresolvedReferencesInspectionTest.java @@ -0,0 +1,38 @@ +package com.jetbrains.python.inspections; + +import com.jetbrains.python.fixtures.PyLightFixtureTestCase; + +/** + * @author yole + */ +public class PyUnresolvedReferencesInspectionTest extends PyLightFixtureTestCase { + public void testSelfReference() { + doTest(); + } + + public void testUnresolvedImport() { + doTest(); + } + + public void testStaticMethodParameter() { // PY-663 + doTest(); + } + + public void testOverridesGetAttr() { // PY-574 + doTest(); + } + + public void testUndeclaredAttrAssign() { // PY-906 + doTest(); + } + + public void testSlots() { + doTest(); + } + + private void doTest() { + myFixture.configureByFile("inspections/PyUnresolvedReferencesInspection/" + getTestName(true) + ".py"); + myFixture.enableInspections(PyUnresolvedReferencesInspection.class); + myFixture.checkHighlighting(true, false, false); + } +}