From 2e110fdd2ce9e71b6e069f1812928e361772460a Mon Sep 17 00:00:00 2001 From: "Ilya.Kazakevich" Date: Tue, 21 Jan 2014 00:45:02 +0400 Subject: [PATCH] PY-6955 Unused import not greyed out if also failing (test refactored) --- .../python/fixtures/PyInspectionTestCase.java | 16 ++++++++++- .../PyUnresolvedReferencesInspectionTest.java | 27 +++++++------------ 2 files changed, 24 insertions(+), 19 deletions(-) diff --git a/python/testSrc/com/jetbrains/python/fixtures/PyInspectionTestCase.java b/python/testSrc/com/jetbrains/python/fixtures/PyInspectionTestCase.java index 96fca13931a9..4769b09c808e 100644 --- a/python/testSrc/com/jetbrains/python/fixtures/PyInspectionTestCase.java +++ b/python/testSrc/com/jetbrains/python/fixtures/PyInspectionTestCase.java @@ -24,11 +24,25 @@ public abstract class PyInspectionTestCase extends PyTestCase { * Launches test. To be called by test author */ protected void doTest() { - myFixture.configureByFile("inspections/" + getInspectionClass().getSimpleName() + "/" + getTestName(true) + ".py"); + myFixture.configureByFile(getTestDirectory(true) + ".py"); + configureInspection(); + } + + protected void doMultiFileTest(@NotNull String filename) { + myFixture.copyDirectoryToProject(getTestDirectory(false), ""); + myFixture.configureFromTempProjectFile(filename); + configureInspection(); + } + + private void configureInspection() { myFixture.enableInspections(getInspectionClass()); myFixture.checkHighlighting(isWarning(), isInfo(), isWeakWarning()); } + private String getTestDirectory(boolean lowercaseFirstLetter) { + return "inspections/" + getInspectionClass().getSimpleName() + "/" + getTestName(lowercaseFirstLetter); + } + protected boolean isWeakWarning() { return true; diff --git a/python/testSrc/com/jetbrains/python/inspections/PyUnresolvedReferencesInspectionTest.java b/python/testSrc/com/jetbrains/python/inspections/PyUnresolvedReferencesInspectionTest.java index 53bcbc34d60e..7ef9511b0ea2 100644 --- a/python/testSrc/com/jetbrains/python/inspections/PyUnresolvedReferencesInspectionTest.java +++ b/python/testSrc/com/jetbrains/python/inspections/PyUnresolvedReferencesInspectionTest.java @@ -15,15 +15,14 @@ */ package com.jetbrains.python.inspections; -import com.jetbrains.python.fixtures.PyTestCase; +import com.jetbrains.python.fixtures.PyInspectionTestCase; import com.jetbrains.python.psi.LanguageLevel; import org.jetbrains.annotations.NotNull; /** * @author yole */ -public class PyUnresolvedReferencesInspectionTest extends PyTestCase { - private static final String TEST_DIRECTORY = "inspections/PyUnresolvedReferencesInspection/"; +public class PyUnresolvedReferencesInspectionTest extends PyInspectionTestCase { public void testSelfReference() { doTest(); @@ -77,11 +76,11 @@ public class PyUnresolvedReferencesInspectionTest extends PyTestCase { public void testTypeAssertions() { doTest(); } - + public void testUnresolvedImportedModule() { // PY-2075 doTest(); } - + public void testSuperType() { // PY-2320 doTest(); } @@ -89,7 +88,7 @@ public class PyUnresolvedReferencesInspectionTest extends PyTestCase { public void testImportFunction() { // PY-1896 doTest(); } - + public void testSuperclassAsLocal() { // PY-5427 doTest(); } @@ -336,17 +335,9 @@ public class PyUnresolvedReferencesInspectionTest extends PyTestCase { doTest(); } - private void doTest() { - myFixture.configureByFile(TEST_DIRECTORY + getTestName(true) + ".py"); - 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); + @NotNull + @Override + protected Class getInspectionClass() { + return PyUnresolvedReferencesInspection.class; } }