mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
Rewrite PyPropertyDefinitionInspection tests as highlighting tests
This commit is contained in:
@@ -1,49 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<problems>
|
||||
<problem>
|
||||
<file>prop_test.py</file>
|
||||
<line>15</line>
|
||||
<description>Getter should return something</description>
|
||||
</problem>
|
||||
<problem>
|
||||
<file>prop_test.py</file>
|
||||
<line>15</line>
|
||||
<description>Getter signature should be (self)</description>
|
||||
</problem>
|
||||
<problem>
|
||||
<file>prop_test.py</file>
|
||||
<line>16</line>
|
||||
<description>Setter should not return a value</description>
|
||||
</problem>
|
||||
<problem>
|
||||
<file>prop_test.py</file>
|
||||
<line>16</line>
|
||||
<description>Setter signature should be (self, value)</description>
|
||||
</problem>
|
||||
<problem>
|
||||
<file>prop_test.py</file>
|
||||
<line>17</line>
|
||||
<description>Deleter should not return a value</description>
|
||||
</problem>
|
||||
<problem>
|
||||
<file>prop_test.py</file>
|
||||
<line>18</line>
|
||||
<description>The doc parameter should be a string</description>
|
||||
</problem>
|
||||
<problem>
|
||||
<file>prop_test.py</file>
|
||||
<line>21</line>
|
||||
<description>Setter should not return a value</description>
|
||||
</problem>
|
||||
<problem>
|
||||
<file>prop_test.py</file>
|
||||
<line>21</line>
|
||||
<description>Setter signature should be (self, value)</description>
|
||||
</problem>
|
||||
<problem>
|
||||
<file>prop_test.py</file>
|
||||
<line>48</line>
|
||||
<description>Getter should return something</description>
|
||||
</problem>
|
||||
</problems>
|
||||
|
||||
+11
-11
@@ -12,13 +12,13 @@ class A(object):
|
||||
pass
|
||||
|
||||
x1 = property(__getX, __setX, __delX, "doc of x1")
|
||||
x2 = property(__setX) # should return
|
||||
x3 = property(__getX, __getX) # should not return
|
||||
x4 = property(__getX, fdel=__getX) # should not return
|
||||
x5 = property(__getX, doc=123) # bad doc
|
||||
x2 = property(<warning descr="Getter should return or yield something"><warning descr="Getter signature should be (self)">__setX</warning></warning>)
|
||||
x3 = property(__getX, <warning descr="Setter should not return a value"><warning descr="Setter signature should be (self, value)">__getX</warning></warning>)
|
||||
x4 = property(__getX, fdel=<warning descr="Deleter should not return a value">__getX</warning>)
|
||||
x5 = property(__getX, doc=<warning descr="The doc parameter should be a string">123</warning>)
|
||||
|
||||
x6 = property(lambda self: self._x)
|
||||
x7 = property(lambda self: self._x, lambda self: self._x) # setter should not return
|
||||
x7 = property(lambda self: self._x, <warning descr="Setter should not return a value"><warning descr="Setter signature should be (self, value)">lambda self: self._x</warning></warning>)
|
||||
|
||||
@property
|
||||
def foo(self):
|
||||
@@ -45,7 +45,7 @@ class A(object):
|
||||
pass
|
||||
|
||||
@property
|
||||
def moo(self): # should return
|
||||
def <warning descr="Getter should return or yield something">moo</warning>(self):
|
||||
pass
|
||||
|
||||
@moo.setter
|
||||
@@ -71,9 +71,9 @@ class Ghostbusters(object):
|
||||
gb = Ghostbusters()
|
||||
|
||||
class B(object):
|
||||
x = property(gb) # pass
|
||||
y = property(Ghostbusters()) # pass
|
||||
z = property(Ghostbusters) # pass
|
||||
x = property(gb)
|
||||
y = property(Ghostbusters())
|
||||
z = property(Ghostbusters)
|
||||
|
||||
class Eternal(object):
|
||||
def give(self):
|
||||
@@ -85,5 +85,5 @@ class Eternal(object):
|
||||
while True:
|
||||
x = (yield x)
|
||||
|
||||
one = property(give) # should pass
|
||||
anything = property(giveAndTake) # should pass
|
||||
one = property(give)
|
||||
anything = property(giveAndTake)
|
||||
@@ -1,61 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<problems>
|
||||
<problem>
|
||||
<file>prop_test.py</file>
|
||||
<line>21</line>
|
||||
<description>Names of function and decorator don't match; property accessor is not created</description>
|
||||
</problem>
|
||||
<problem>
|
||||
<file>prop_test.py</file>
|
||||
<line>25</line>
|
||||
<description>Names of function and decorator don't match; property accessor is not created</description>
|
||||
</problem>
|
||||
<problem>
|
||||
<file>prop_test.py</file>
|
||||
<line>30</line>
|
||||
<description>Getter should return something</description>
|
||||
</problem>
|
||||
<problem>
|
||||
<file>prop_test.py</file>
|
||||
<line>34</line>
|
||||
<description>Setter should not return a value</description>
|
||||
</problem>
|
||||
<problem>
|
||||
<file>prop_test.py</file>
|
||||
<line>38</line>
|
||||
<description>Deleter should not return a value</description>
|
||||
</problem>
|
||||
<problem>
|
||||
<file>prop_test.py</file>
|
||||
<line>222</line>
|
||||
<module>light_idea_test_case</module>
|
||||
<entry_point TYPE="file" FQNAME="temp:///src/src/prop_test.py" />
|
||||
<problem_class severity="WARNING" attribute_key="WARNING_ATTRIBUTES">Property definitions</problem_class>
|
||||
<description>Setter should not return a value</description>
|
||||
</problem>
|
||||
<problem>
|
||||
<file>prop_test.py</file>
|
||||
<line>237</line>
|
||||
<module>light_idea_test_case</module>
|
||||
<entry_point TYPE="file" FQNAME="temp:///src/src/prop_test.py" />
|
||||
<problem_class severity="WARNING" attribute_key="WARNING_ATTRIBUTES">Property definitions</problem_class>
|
||||
<description>Setter should not return a value</description>
|
||||
</problem>
|
||||
<problem>
|
||||
<file>prop_test.py</file>
|
||||
<line>268</line>
|
||||
<module>light_idea_test_case</module>
|
||||
<entry_point TYPE="file" FQNAME="temp:///src/src/prop_test.py" />
|
||||
<problem_class severity="WARNING" attribute_key="WARNING_ATTRIBUTES">Property definitions</problem_class>
|
||||
<description>Setter should not return a value</description>
|
||||
</problem>
|
||||
<problem>
|
||||
<file>prop_test.py</file>
|
||||
<line>284</line>
|
||||
<module>light_idea_test_case</module>
|
||||
<entry_point TYPE="file" FQNAME="temp:///src/src/prop_test.py" />
|
||||
<problem_class severity="WARNING" attribute_key="WARNING_ATTRIBUTES">Property definitions</problem_class>
|
||||
<description>Setter should not return a value</description>
|
||||
</problem>
|
||||
</problems>
|
||||
|
||||
+19
-19
@@ -18,24 +18,24 @@ class A(object):
|
||||
def boo(self):
|
||||
return self._x
|
||||
|
||||
@boo.setter # name mismatch
|
||||
<warning descr="Names of function and decorator don't match; property accessor is not created">@boo.setter</warning>
|
||||
def boo1(self, x):
|
||||
self._x = x
|
||||
|
||||
@boo.deleter # name mismatch
|
||||
<warning descr="Names of function and decorator don't match; property accessor is not created">@boo.deleter</warning>
|
||||
def boo2(self):
|
||||
pass
|
||||
|
||||
@property
|
||||
def moo(self): # should return
|
||||
def <warning descr="Getter should return or yield something">moo</warning>(self):
|
||||
pass
|
||||
|
||||
@moo.setter
|
||||
def moo(self, x): # shouldn't return
|
||||
def <warning descr="Setter should not return a value">moo</warning>(self, x):
|
||||
return 1
|
||||
|
||||
@moo.deleter
|
||||
def moo(self): # shouldn't return
|
||||
def <warning descr="Deleter should not return a value">moo</warning>(self):
|
||||
return self._x
|
||||
|
||||
@qoo.setter # unknown qoo is reported in ref inspection
|
||||
@@ -83,7 +83,7 @@ class Test(object):
|
||||
return n
|
||||
self._myprop = inner_func(val)
|
||||
|
||||
myprop = property(get_myprop, set_myprop) # pass
|
||||
myprop = property(get_myprop, set_myprop)
|
||||
|
||||
|
||||
# all flows have exit point
|
||||
@@ -93,13 +93,13 @@ class Test(object):
|
||||
|
||||
def get_myprop(self):
|
||||
if a > b:
|
||||
return self._myprop
|
||||
<error descr="Python versions < 3.3 do not allow 'return' with argument inside generator.">return self._myprop</error>
|
||||
elif a < b:
|
||||
raise self._myprop
|
||||
else:
|
||||
yield self._myprop
|
||||
|
||||
myprop = property(get_myprop) # pass
|
||||
myprop = property(get_myprop)
|
||||
|
||||
|
||||
# some flows have not exit point
|
||||
@@ -113,7 +113,7 @@ class Test(object):
|
||||
elif a < b:
|
||||
raise self._myprop
|
||||
|
||||
myprop = property(get_myprop) # pass
|
||||
myprop = property(get_myprop)
|
||||
|
||||
|
||||
# some flows have not exit point
|
||||
@@ -125,7 +125,7 @@ class Test(object):
|
||||
if a > b:
|
||||
return self._myprop
|
||||
|
||||
myprop = property(get_myprop) # pass
|
||||
myprop = property(get_myprop)
|
||||
|
||||
|
||||
# non-empty for
|
||||
@@ -137,7 +137,7 @@ class Test(object):
|
||||
for i in range(5):
|
||||
yield i
|
||||
|
||||
myprop = property(get_myprop) # pass
|
||||
myprop = property(get_myprop)
|
||||
|
||||
|
||||
# empty for
|
||||
@@ -163,7 +163,7 @@ class Test(object):
|
||||
yield i
|
||||
i += 1
|
||||
|
||||
myprop = property(get_myprop) # pass
|
||||
myprop = property(get_myprop)
|
||||
|
||||
|
||||
# empty while
|
||||
@@ -190,7 +190,7 @@ class Test(object):
|
||||
yield i
|
||||
i += 1
|
||||
|
||||
myprop = property(get_myprop) # pass
|
||||
myprop = property(get_myprop)
|
||||
|
||||
|
||||
# empty while with two conditions
|
||||
@@ -219,7 +219,7 @@ class Test(object):
|
||||
self._myprop = val
|
||||
return 10
|
||||
|
||||
myprop = property(get_myprop, set_myprop) # shouldn't pass
|
||||
myprop = property(get_myprop, <warning descr="Setter should not return a value">set_myprop</warning>)
|
||||
|
||||
|
||||
# setter has exit point
|
||||
@@ -234,7 +234,7 @@ class Test(object):
|
||||
self._myprop = val
|
||||
yield 10
|
||||
|
||||
myprop = property(get_myprop, set_myprop) # shouldn't pass
|
||||
myprop = property(get_myprop, <warning descr="Setter should not return a value">set_myprop</warning>)
|
||||
|
||||
|
||||
# setter has raise statement
|
||||
@@ -249,7 +249,7 @@ class Test(object):
|
||||
self._myprop = val
|
||||
raise NotImplementedError()
|
||||
|
||||
myprop = property(get_myprop, set_myprop) # pass
|
||||
myprop = property(get_myprop, set_myprop)
|
||||
|
||||
|
||||
# setter has exit point in some flow
|
||||
@@ -265,7 +265,7 @@ class Test(object):
|
||||
if a > b:
|
||||
return 10
|
||||
|
||||
myprop = property(get_myprop, set_myprop) # shouldn't pass
|
||||
myprop = property(get_myprop, <warning descr="Setter should not return a value">set_myprop</warning>)
|
||||
|
||||
|
||||
# setter has exit point in some flow
|
||||
@@ -281,7 +281,7 @@ class Test(object):
|
||||
if a > b:
|
||||
yield 10
|
||||
|
||||
myprop = property(get_myprop, set_myprop) # shouldn't pass
|
||||
myprop = property(get_myprop, <warning descr="Setter should not return a value">set_myprop</warning>)
|
||||
|
||||
|
||||
# setter has raise statement in some flow
|
||||
@@ -297,4 +297,4 @@ class Test(object):
|
||||
if a > b:
|
||||
raise NotImplementedError()
|
||||
|
||||
myprop = property(get_myprop, set_myprop) # pass
|
||||
myprop = property(get_myprop, set_myprop)
|
||||
@@ -1,9 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<problems>
|
||||
<problem>
|
||||
<file>prop_test.py</file>
|
||||
<line>3</line>
|
||||
<description>Getter should return or yield something</description>
|
||||
</problem>
|
||||
</problems>
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
class A:
|
||||
@property
|
||||
def normal_property(self):
|
||||
def <warning descr="Getter should return or yield something">normal_property</warning>(self):
|
||||
pass
|
||||
|
||||
@property
|
||||
@@ -240,16 +240,16 @@ public class PythonInspectionsTest extends PyTestCase {
|
||||
}
|
||||
|
||||
public void testPyPropertyDefinitionInspection25() {
|
||||
doTestWithLanguageLevel(getTestName(false), new PyPropertyDefinitionInspection(), LanguageLevel.PYTHON25);
|
||||
doHighlightingTest(PyPropertyDefinitionInspection.class, LanguageLevel.PYTHON25);
|
||||
}
|
||||
|
||||
public void testPyPropertyDefinitionInspection26() {
|
||||
doTestWithLanguageLevel(getTestName(false), new PyPropertyDefinitionInspection(), LanguageLevel.PYTHON26);
|
||||
doHighlightingTest(PyPropertyDefinitionInspection.class, LanguageLevel.PYTHON26);
|
||||
}
|
||||
|
||||
// PY-11426
|
||||
public void testPyPropertyDefinitionInspection33() {
|
||||
doTestWithLanguageLevel(getTestName(false), new PyPropertyDefinitionInspection(), LanguageLevel.PYTHON33);
|
||||
doHighlightingTest(PyPropertyDefinitionInspection.class, LanguageLevel.PYTHON33);
|
||||
}
|
||||
|
||||
public void testInconsistentIndentation() {
|
||||
|
||||
Reference in New Issue
Block a user