split test for 'calling non-callable' inspection

This commit is contained in:
Dmitry Jemerov
2011-08-15 19:47:46 +04:00
parent b342044021
commit b42a2f3950
10 changed files with 92 additions and 58 deletions
@@ -0,0 +1,18 @@
# PY-4061
def test_class_as_callable():
class C1(object):
def __init__(self):
pass
def f(self):
pass
class C2(object):
def g(self):
pass
class C3:
pass
c1 = C1() #pass
c2 = C2() #pass
c3 = C3() #pass
c1.__class__().f() #pass
c2.__class__().g() #pass
c3.__class__() #pass
@@ -0,0 +1,11 @@
# PY-4061
def test_class_assignments():
class C():
def __init__(self):
pass
d = C
a = d() #pass
l = list
a = l([]) #pass
d = dict
b = d({}) #pass
@@ -0,0 +1,6 @@
def concealer():
class prog(object):
def __call__(self): pass
pr = prog()
pr()
@@ -0,0 +1,3 @@
def test_module():
import sys
<warning descr="'sys' is not callable">sys()</warning>
@@ -0,0 +1,6 @@
class SM(object):
def my_method(): pass
my_method = staticmethod(my_method)
def q(self):
self.my_method()
@@ -1,50 +0,0 @@
<warning descr="'tuple' object is not callable">(1,2)()</warning>
class SM(object):
def my_method(): pass
my_method = staticmethod(my_method)
def q(self):
self.my_method()
def concealer():
class prog(object):
def __call__(self): pass
pr = prog()
pr()
def test_module():
import sys
<warning descr="'sys' is not callable">sys()</warning>
# PY-4061
def test_class_as_callable():
class C1(object):
def __init__(self):
pass
def f(self):
pass
class C2(object):
def g(self):
pass
class C3:
pass
c1 = C1() #pass
c2 = C2() #pass
c3 = C3() #pass
c1.__class__().f() #pass
c2.__class__().g() #pass
c3.__class__() #pass
# PY-4061
def test_class_assignments():
class C():
def __init__(self):
pass
d = C
a = d() #pass
l = list
a = l([]) #pass
d = dict
b = d({}) #pass
@@ -0,0 +1 @@
<warning descr="'tuple' object is not callable">(1,2)()</warning>
@@ -1,10 +1,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.inspections.*;
import com.jetbrains.python.refactoring.*;
import com.jetbrains.python.refactoring.classes.PyExtractSuperclassTest;
import com.jetbrains.python.refactoring.classes.PyPullUpTest;
@@ -80,6 +77,7 @@ public class PythonAllTestsSuite {
PyCompletionPatternsTest.class,
PyCompatibilityInspectionTest.class,
PyUnresolvedReferencesInspectionTest.class,
PyCallingNonCallableTest.class,
PyUnusedImportTest.class,
PyDeprecationTest.class,
PythonHighlightingLexerTest.class
@@ -233,10 +233,6 @@ public class PythonInspectionsTest extends PyLightFixtureTestCase {
doHighlightingTest(PyCallByClassInspection.class); // ok, we can handle insanely long lines :)
}
public void testPyCallingNonCallableInspection() {
doHighlightingTest(PyCallingNonCallableInspection.class, LanguageLevel.PYTHON26);
}
private void doHighlightingTest(final Class<? extends PyInspection> inspectionClass) {
myFixture.configureByFile("inspections/" + getTestName(false) + "/test.py");
myFixture.enableInspections(inspectionClass);
@@ -0,0 +1,45 @@
package com.jetbrains.python.inspections;
import com.jetbrains.python.fixtures.PyLightFixtureTestCase;
import com.jetbrains.python.psi.LanguageLevel;
/**
* @author yole
*/
public class PyCallingNonCallableTest extends PyLightFixtureTestCase {
public void testTupleNonCallable() {
doTest();
}
public void testStaticMeth() {
doTest();
}
public void testConcealer() {
doTest();
}
public void testModule() {
doTest();
}
public void testClassAsCallable() { // PY-4061
doTest();
}
public void testClassAssignments() { // PY-4061
doTest();
}
private void doTest() {
setLanguageLevel(LanguageLevel.PYTHON26);
try {
myFixture.configureByFile("inspections/PyCallingNonCallableInspection/" + getTestName(true) + ".py");
myFixture.enableInspections(PyCallingNonCallableInspection.class);
myFixture.checkHighlighting(true, false, false);
}
finally {
setLanguageLevel(null);
}
}
}