diff --git a/python/testData/inspections/PyUnreachableCodeInspection/Unreachable.py b/python/testData/inspections/PyUnreachableCodeInspection/Unreachable.py
new file mode 100644
index 000000000000..3bc2b9b0b780
--- /dev/null
+++ b/python/testData/inspections/PyUnreachableCodeInspection/Unreachable.py
@@ -0,0 +1,140 @@
+def f():
+ return
+ a = 1
+
+
+def f():
+ if 0:
+ return
+ a = 1 # pass
+
+
+def f():
+ raise Exception()
+ a = 1
+
+
+def f():
+ for x in []:
+ break
+ a = x
+
+
+def f():
+ for x in []:
+ if x == 0:
+ break
+ a = 1 # pass
+
+
+def f():
+ for x in []:
+ continue
+ a = 1
+
+
+def f():
+ for x in []:
+ raise Exception()
+ if 1:
+ pass
+
+
+def f():
+ if 1:
+ return
+ print "x"
+
+
+def f():
+ try:
+ raise KeyboardInterrupt
+ finally:
+ print 'test'
+
+
+class MyTestCase(unittest.TestCase):
+ def test_something(self):
+ with self.assertRaises():
+ raise Foo
+ foo() # pass
+
+
+# PY-3532
+def f():
+ import sys
+ f = lambda: sys.exit() #pass
+ foo = 3
+ return f, foo
+
+
+# PY-3886
+def f():
+ from unittest import TestCase
+ class C(TestCase):
+ def test_1(self):
+ self.fail()
+ return -42
+
+
+# PY-4149
+def f():
+ try:
+ pass
+ finally: #pass
+ pass
+
+
+# PY-4208
+def f(g):
+ try:
+ raise
+ finally:
+ g()
+ g()
+
+
+# PY-5266
+def f(g):
+ x = 0
+ try:
+ x = g()
+ except Exception:
+ try:
+ x = 2
+ return
+ except Exception:
+ raise
+ print(x) #pass
+
+
+# PY-6159
+def f(c):
+ while c:
+ break #pass
+ else:
+ x = 1
+
+
+# PY-6062
+def f(x):
+ for _ in [1, 2]:
+ for _ in [3, 4]:
+ pass
+ else:
+ break
+ else:
+ return
+ print(x) #pass
+
+
+# PY-6062
+def f(x):
+ for _ in [1, 2]:
+ while x:
+ pass
+ else:
+ break
+ else:
+ return
+ print(x) #pass
diff --git a/python/testData/inspections/PyUnreachableCodeInspection/expected.xml b/python/testData/inspections/PyUnreachableCodeInspection/expected.xml
deleted file mode 100644
index adbc160735df..000000000000
--- a/python/testData/inspections/PyUnreachableCodeInspection/expected.xml
+++ /dev/null
@@ -1,49 +0,0 @@
-
-
-
- unreachable.py
- 4
- This code is unreachable
-
-
-
- unreachable.py
- 13
- This code is unreachable
-
-
- unreachable.py
- 17
- This code is unreachable
-
-
- unreachable.py
- 26
- This code is unreachable
-
-
- unreachable.py
- 30
- This code is unreachable
-
-
- unreachable.py
- 36
- This code is unreachable
-
-
- unreachable.py
- 46
- This code is unreachable
-
-
- unreachable.py
- 69
- This code is unreachable
-
-
- unreachable.py
- 86
- This code is unreachable
-
-
diff --git a/python/testSrc/com/jetbrains/python/PythonAllTestsSuite.java b/python/testSrc/com/jetbrains/python/PythonAllTestsSuite.java
index cd0523dc0efb..802685465a28 100644
--- a/python/testSrc/com/jetbrains/python/PythonAllTestsSuite.java
+++ b/python/testSrc/com/jetbrains/python/PythonAllTestsSuite.java
@@ -48,6 +48,7 @@ public class PythonAllTestsSuite {
PyQuickDocTest.class,
PythonInspectionsTest.class,
PyTypeCheckerInspectionTest.class,
+ PyUnreachableCodeInspectionTest.class,
PyArgumentListInspectionTest.class,
CythonInspectionsTest.class,
PythonDemorganLawIntentionTest.class,
diff --git a/python/testSrc/com/jetbrains/python/PythonInspectionsTest.java b/python/testSrc/com/jetbrains/python/PythonInspectionsTest.java
index 8d3549a72bf9..1c475fbe8e1a 100644
--- a/python/testSrc/com/jetbrains/python/PythonInspectionsTest.java
+++ b/python/testSrc/com/jetbrains/python/PythonInspectionsTest.java
@@ -43,11 +43,6 @@ public class PythonInspectionsTest extends PyTestCase {
doTest(getTestName(false), inspection);
}
- public void testPyUnreachableCodeInspection() {
- LocalInspectionTool inspection = new PyUnreachableCodeInspection();
- doTest(getTestName(false), inspection);
- }
-
public void testPyMethodParametersInspection() {
doHighlightingTest(PyMethodParametersInspection.class);
}
diff --git a/python/testSrc/com/jetbrains/python/inspections/PyUnreachableCodeInspectionTest.java b/python/testSrc/com/jetbrains/python/inspections/PyUnreachableCodeInspectionTest.java
new file mode 100644
index 000000000000..5c651b687d14
--- /dev/null
+++ b/python/testSrc/com/jetbrains/python/inspections/PyUnreachableCodeInspectionTest.java
@@ -0,0 +1,27 @@
+package com.jetbrains.python.inspections;
+
+import com.jetbrains.python.fixtures.PyTestCase;
+import com.jetbrains.python.psi.LanguageLevel;
+
+/**
+ * @author vlan
+ */
+public class PyUnreachableCodeInspectionTest extends PyTestCase {
+ private static final String TEST_DIRECTORY = "inspections/PyUnreachableCodeInspection/";
+
+ // All previous unreachable tests
+ public void testUnreachable() {
+ doTest();
+ }
+
+ private void doTest() {
+ runWithLanguageLevel(LanguageLevel.PYTHON27, new Runnable() {
+ @Override
+ public void run() {
+ myFixture.configureByFile(TEST_DIRECTORY + getTestName(false) + ".py");
+ myFixture.enableInspections(PyUnreachableCodeInspection.class);
+ myFixture.checkHighlighting(true, false, false);
+ }
+ });
+ }
+}