mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
Converted unreachable inspection tests to highlighting tests
This commit is contained in:
@@ -0,0 +1,140 @@
|
||||
def f():
|
||||
return
|
||||
<warning descr="This code is unreachable">a = 1</warning>
|
||||
|
||||
|
||||
def f():
|
||||
if 0:
|
||||
return
|
||||
a = 1 # pass
|
||||
|
||||
|
||||
def f():
|
||||
raise Exception()
|
||||
<warning descr="This code is unreachable">a = 1</warning>
|
||||
|
||||
|
||||
def f():
|
||||
for x in []:
|
||||
break
|
||||
<warning descr="This code is unreachable">a = x</warning>
|
||||
|
||||
|
||||
def f():
|
||||
for x in []:
|
||||
if x == 0:
|
||||
break
|
||||
a = 1 # pass
|
||||
|
||||
|
||||
def f():
|
||||
for x in []:
|
||||
continue
|
||||
<warning descr="This code is unreachable">a = 1</warning>
|
||||
|
||||
|
||||
def f():
|
||||
for x in []:
|
||||
raise Exception()
|
||||
<warning descr="This code is unreachable">if 1:
|
||||
pass</warning>
|
||||
|
||||
|
||||
def f():
|
||||
if 1:
|
||||
return
|
||||
<warning descr="This code is unreachable">print "x"</warning>
|
||||
|
||||
|
||||
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()
|
||||
<warning descr="This code is unreachable">return -42</warning>
|
||||
|
||||
|
||||
# PY-4149
|
||||
def f():
|
||||
try:
|
||||
pass
|
||||
finally: #pass
|
||||
pass
|
||||
|
||||
|
||||
# PY-4208
|
||||
def f(g):
|
||||
try:
|
||||
raise
|
||||
finally:
|
||||
g()
|
||||
<warning descr="This code is unreachable">g()</warning>
|
||||
|
||||
|
||||
# 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
|
||||
@@ -1,49 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<problems>
|
||||
<problem>
|
||||
<file>unreachable.py</file>
|
||||
<line>4</line>
|
||||
<description>This code is unreachable</description>
|
||||
</problem>
|
||||
|
||||
<problem>
|
||||
<file>unreachable.py</file>
|
||||
<line>13</line>
|
||||
<description>This code is unreachable</description>
|
||||
</problem>
|
||||
<problem>
|
||||
<file>unreachable.py</file>
|
||||
<line>17</line>
|
||||
<description>This code is unreachable</description>
|
||||
</problem>
|
||||
<problem>
|
||||
<file>unreachable.py</file>
|
||||
<line>26</line>
|
||||
<description>This code is unreachable</description>
|
||||
</problem>
|
||||
<problem>
|
||||
<file>unreachable.py</file>
|
||||
<line>30</line>
|
||||
<description>This code is unreachable</description>
|
||||
</problem>
|
||||
<problem>
|
||||
<file>unreachable.py</file>
|
||||
<line>36</line>
|
||||
<description>This code is unreachable</description>
|
||||
</problem>
|
||||
<problem>
|
||||
<file>unreachable.py</file>
|
||||
<line>46</line>
|
||||
<description>This code is unreachable</description>
|
||||
</problem>
|
||||
<problem>
|
||||
<file>unreachable.py</file>
|
||||
<line>69</line>
|
||||
<description>This code is unreachable</description>
|
||||
</problem>
|
||||
<problem>
|
||||
<file>unreachable.py</file>
|
||||
<line>86</line>
|
||||
<description>This code is unreachable</description>
|
||||
</problem>
|
||||
</problems>
|
||||
@@ -48,6 +48,7 @@ public class PythonAllTestsSuite {
|
||||
PyQuickDocTest.class,
|
||||
PythonInspectionsTest.class,
|
||||
PyTypeCheckerInspectionTest.class,
|
||||
PyUnreachableCodeInspectionTest.class,
|
||||
PyArgumentListInspectionTest.class,
|
||||
CythonInspectionsTest.class,
|
||||
PythonDemorganLawIntentionTest.class,
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user