diff --git a/python/testData/inspections/PyRedeclarationInspection/conditional.py b/python/testData/inspections/PyRedeclarationInspection/conditional.py
new file mode 100644
index 000000000000..2636d0fd30b0
--- /dev/null
+++ b/python/testData/inspections/PyRedeclarationInspection/conditional.py
@@ -0,0 +1,13 @@
+def test_conditional(c):
+ def foo():
+ pass
+
+ if c:
+ def foo():
+ pass
+
+ try:
+ def foo():
+ pass
+ except:
+ pass
\ No newline at end of file
diff --git a/python/testData/inspections/PyRedeclarationInspection/decoratedFunction.py b/python/testData/inspections/PyRedeclarationInspection/decoratedFunction.py
new file mode 100644
index 000000000000..5f8a91b19095
--- /dev/null
+++ b/python/testData/inspections/PyRedeclarationInspection/decoratedFunction.py
@@ -0,0 +1,10 @@
+def test_decorated_function(decorator):
+ def foo():
+ pass
+
+ @decorator
+ def foo():
+ pass
+
+ def foo():
+ pass
\ No newline at end of file
diff --git a/python/testData/inspections/PyRedeclarationInspection/for.py b/python/testData/inspections/PyRedeclarationInspection/for.py
new file mode 100644
index 000000000000..c46629856671
--- /dev/null
+++ b/python/testData/inspections/PyRedeclarationInspection/for.py
@@ -0,0 +1,3 @@
+class TestForLoopNoRedeclaraion:
+ for foo in [1, 2, 3]:
+ x = 1
\ No newline at end of file
diff --git a/python/testData/inspections/PyRedeclarationInspection/forAndFunctionBefore.py b/python/testData/inspections/PyRedeclarationInspection/forAndFunctionBefore.py
new file mode 100644
index 000000000000..2662dfe77d4c
--- /dev/null
+++ b/python/testData/inspections/PyRedeclarationInspection/forAndFunctionBefore.py
@@ -0,0 +1,6 @@
+class TestForLoopTarget:
+ def foo():
+ pass
+
+ for foo in [1, 2, 3]:
+ x = 1
\ No newline at end of file
diff --git a/python/testData/inspections/PyRedeclarationInspection/forBody.py b/python/testData/inspections/PyRedeclarationInspection/forBody.py
new file mode 100644
index 000000000000..8d1331a81a84
--- /dev/null
+++ b/python/testData/inspections/PyRedeclarationInspection/forBody.py
@@ -0,0 +1,7 @@
+class TestForLoopBody:
+ def foo():
+ pass
+
+ for _ in [1, 2, 3]:
+ def foo():
+ pass
\ No newline at end of file
diff --git a/python/testData/inspections/PyRedeclarationInspection/localVariable.py b/python/testData/inspections/PyRedeclarationInspection/localVariable.py
new file mode 100644
index 000000000000..ee843121a125
--- /dev/null
+++ b/python/testData/inspections/PyRedeclarationInspection/localVariable.py
@@ -0,0 +1,3 @@
+def test_local_variable():
+ x = 1
+ x = 2
\ No newline at end of file
diff --git a/python/testData/inspections/PyRedeclarationInspection/nestedComprehension.py b/python/testData/inspections/PyRedeclarationInspection/nestedComprehension.py
new file mode 100644
index 000000000000..c8f52293500c
--- /dev/null
+++ b/python/testData/inspections/PyRedeclarationInspection/nestedComprehension.py
@@ -0,0 +1,4 @@
+# PY-10839
+class TestNestedComprehension:
+ x = [[n for _ in []] for n in []]
+ n = 2
\ No newline at end of file
diff --git a/python/testData/inspections/PyRedeclarationInspection/redeclaredClass.py b/python/testData/inspections/PyRedeclarationInspection/redeclaredClass.py
new file mode 100644
index 000000000000..c6be37f7693d
--- /dev/null
+++ b/python/testData/inspections/PyRedeclarationInspection/redeclaredClass.py
@@ -0,0 +1,6 @@
+def test_class():
+ class X:
+ pass
+
+ class X:
+ pass
\ No newline at end of file
diff --git a/python/testData/inspections/PyRedeclarationInspection/redeclaredFunction.py b/python/testData/inspections/PyRedeclarationInspection/redeclaredFunction.py
new file mode 100644
index 000000000000..a7da6b6e3be0
--- /dev/null
+++ b/python/testData/inspections/PyRedeclarationInspection/redeclaredFunction.py
@@ -0,0 +1,6 @@
+def test_function():
+ def foo():
+ pass
+
+ def foo():
+ pass
\ No newline at end of file
diff --git a/python/testData/inspections/PyRedeclarationInspection/redeclaredTopLevel.py b/python/testData/inspections/PyRedeclarationInspection/redeclaredTopLevel.py
new file mode 100644
index 000000000000..c5f73954cc89
--- /dev/null
+++ b/python/testData/inspections/PyRedeclarationInspection/redeclaredTopLevel.py
@@ -0,0 +1,10 @@
+def TopLevelBoo():
+ pass
+
+
+TopLevelBoo = 1
+TopLevelBoo = 2
+
+
+class TopLevelBoo:
+ pass
\ No newline at end of file
diff --git a/python/testData/inspections/PyRedeclarationInspection/test.py b/python/testData/inspections/PyRedeclarationInspection/test.py
deleted file mode 100644
index 2db37a00483e..000000000000
--- a/python/testData/inspections/PyRedeclarationInspection/test.py
+++ /dev/null
@@ -1,95 +0,0 @@
-def test_class():
- class X:
- pass
-
- class X:
- pass
-
-def test_function():
- def foo():
- pass
-
- def foo():
- pass
-
-
-# Top-level variable test
-def TopLevelBoo():
- pass
-
-
-TopLevelBoo = 1
-TopLevelBoo = 2
-
-
-class TopLevelBoo:
- pass
-
-
-def test_decorated_function(decorator):
- def foo():
- pass
-
- @decorator
- def foo():
- pass
-
- def foo():
- pass
-
-
-def test_local_variable():
- x = 1
- x = 2
-
-
-def test_conditional(c):
- def foo():
- pass
-
- if c:
- def foo():
- pass
-
- try:
- def foo():
- pass
- except:
- pass
-
-
-def test_while_loop(c):
- def foo():
- pass
-
- while c:
- def foo():
- pass
-
-
-class TestForLoopNoRedeclaraion:
- for foo in [1, 2, 3]:
- x = 1
-
-
-class TestForLoopTarget:
- def foo():
- pass
-
- for foo in [1, 2, 3]:
- x = 1
-
-
-class TestForLoopBody:
- def foo():
- pass
-
- for _ in [1, 2, 3]:
- def foo():
- pass
-
-
-# PY-10839
-class TestNestedComprehension:
- x = [[n for _ in []] for n in []]
- n = 2
diff --git a/python/testData/inspections/PyRedeclarationInspection/while.py b/python/testData/inspections/PyRedeclarationInspection/while.py
new file mode 100644
index 000000000000..eca7d219d3ad
--- /dev/null
+++ b/python/testData/inspections/PyRedeclarationInspection/while.py
@@ -0,0 +1,7 @@
+def test_while_loop(c):
+ def foo():
+ pass
+
+ while c:
+ def foo():
+ pass
\ No newline at end of file
diff --git a/python/testSrc/com/jetbrains/python/PythonInspectionsTest.java b/python/testSrc/com/jetbrains/python/PythonInspectionsTest.java
index 9c51e63c6079..9a5445ce1b15 100644
--- a/python/testSrc/com/jetbrains/python/PythonInspectionsTest.java
+++ b/python/testSrc/com/jetbrains/python/PythonInspectionsTest.java
@@ -79,10 +79,6 @@ public class PythonInspectionsTest extends PyTestCase {
doTest(getTestName(false), inspection);
}
- public void testPyRedeclarationInspection() {
- doHighlightingTest(PyRedeclarationInspection.class);
- }
-
public void testPyTrailingSemicolonInspection() {
LocalInspectionTool inspection = new PyTrailingSemicolonInspection();
doTest(getTestName(false), inspection);
diff --git a/python/testSrc/com/jetbrains/python/inspections/PyRedeclarationInspectionTest.java b/python/testSrc/com/jetbrains/python/inspections/PyRedeclarationInspectionTest.java
new file mode 100644
index 000000000000..e8fee694c710
--- /dev/null
+++ b/python/testSrc/com/jetbrains/python/inspections/PyRedeclarationInspectionTest.java
@@ -0,0 +1,73 @@
+/*
+ * Copyright 2000-2017 JetBrains s.r.o.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.jetbrains.python.inspections;
+
+import com.jetbrains.python.fixtures.PyTestCase;
+
+public class PyRedeclarationInspectionTest extends PyTestCase {
+
+ public void testRedeclaredClass() {
+ doTest();
+ }
+
+ public void testRedeclaredFunction() {
+ doTest();
+ }
+
+ public void testRedeclaredTopLevel() {
+ doTest();
+ }
+
+ public void testDecoratedFunction() {
+ doTest();
+ }
+
+ public void testLocalVariable() {
+ doTest();
+ }
+
+ public void testConditional() {
+ doTest();
+ }
+
+ public void testWhile() {
+ doTest();
+ }
+
+ public void testFor() {
+ doTest();
+ }
+
+ public void testForAndFunctionBefore() {
+ doTest();
+ }
+
+ public void testForBody() {
+ doTest();
+ }
+
+ public void testNestedComprehension() {
+ doTest();
+ }
+
+ private void doTest() {
+ final String path = "inspections/PyRedeclarationInspection/" + getTestName(true) + ".py";
+
+ myFixture.configureByFile(path);
+ myFixture.enableInspections(PyRedeclarationInspection.class);
+ myFixture.checkHighlighting(true, false, true);
+ }
+}